Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the Haskell prelude functions be reduced to a set of core functions?

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?

like image 727
S0rin Avatar asked Dec 02 '15 15:12

S0rin


People also ask

What does prelude do in Haskell?

Prelude is a module that contains a small set of standard definitions and is included automatically into all Haskell modules.

What makes Haskell different from the languages that came before it?

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.

What does drop function do in Haskell?

drop :: number-of-elements-to-drop -> list -> shorter-list. drop removes the first N elements from a given list.

What makes Haskell special?

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.


1 Answers

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.

like image 123
Daniel Wagner Avatar answered Oct 10 '22 07:10

Daniel Wagner