
23 Apr
2011
23 Apr
'11
11:01 a.m.
Ketil Malde schrieb:
Maybe is in a sense easier, as 'Maybe a' and 'a' are different types, while there isn't a similarly elegant type distinction between lists that may be empty and lists with at least one element. Maybe is really quite brilliant.
type NonEmptyList a = (a, [a]) data NonEmptyList a = NonEmptyList a [a] I use the second one frequently for quick check testing and especially for testing on infinite lists. Unfortunately, the Prelude functions like 'cycle' (for input and output) and 'group' (for sublists of the result list) do not use that type.