Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What privileges do functions have over second-class things in Haskell?

Tags:

haskell

I read another question on stackoverflow About first-,second- and third-class value saying that something that is first-class means it has more privileges than second-class things. Since functions are first-class, what privileges do they have over other things in Haskell? I am not sure why I was marked down. Any ideas?

Thanks.

like image 420
Guybrush Threepwood Avatar asked Dec 07 '25 21:12

Guybrush Threepwood


1 Answers

From wikipedia

In programming language design, a first-class citizen (also object, entity, or value) in a given programming language is an entity which supports all the operations generally available to other entities. These operations typically include being passed as a parameter, returned from a function, and assigned to a variable.

This means that in Haskell, functions can be passed as parameters, returned as values, and assigned to variables. The language has built-in mechanics for handling, manipulating, and working with functions in general, such as the compose function (.), the function map, and more.

A second class construct in Haskell is record syntax, as Fixnum has pointed out. You can't construct an anonymous record and pass it into a function, it has to be an instance of a particular data type.

like image 148
bheklilr Avatar answered Dec 09 '25 17:12

bheklilr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!