Next: Example functions
Up: Polytypic Programming
Previous: Motivation
Datatypes are a complex construct in functional programming languages, combining a number of different features.
- n-ary sums:
data Day = Sun | ... | Sat
- n-ary products:
data Complex = Compled Float Float
- abstraction / polymorphism:
data Maybe
= Nothing | Just
- recursion:
data List
= Nil | Cons
(List
)
- non-uniform recursion / nested datatypes:
data Perfect
= Tip
| Fork (Perfect (
,
))
data Bush
= NilB | ConsB
(Bush (Bush
))
- type-constructor polymorphism:
data GRose
= Branch
(
(GRose
))
data Fix
= In (
(Fix
))
data HFix
= HIn (
(HFix
)
)
Matthew Fluet
2001-11-05