Can the Haskell prelude functions be reduced to a set of core functions, such that all other functions can be defined in terms of the core set? If so, what are the core functions?
Prelude is a module that contains a small set of standard definitions and is included automatically into all Haskell modules.
Immutability and purity. Most programming languages out there default to mutability: a variable or field in a data structure can be changed at any time. Haskell is different in two ways: Values are immutable by default, and mutability must be explicitly indicated with a variable type.
drop :: number-of-elements-to-drop -> list -> shorter-list. drop removes the first N elements from a given list.
Unlike some other functional programming languages Haskell is pure. It doesn't allow any side-effects. This is probably the most important feature of Haskell.
I have just walked through the Prelude
documentation on Hackage. The only two operations I couldn't imagine implementing in "unadorned" Haskell are error
and seq
. In the case of error
, I could even imagine implementing something in unadorned Haskell with the right denotational semantics, but which did not share the operational semantics of printing to the console.
There would of course need to be some cooperation between the execution engine for IO
actions and the implementation of IO
operations, but the operations themselves could reasonably be implemented in unadorned Haskell, e.g. with a free monad over the actions available in the Prelude.
It should not be surprising that such a tiny core is possible; after all, even the boring old lambda calculus can emulate all manner of interesting data types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With