Because String
is not [Char]
in Frege, some (maybe half-hearted) attempts have been made to nevertheless guarantee a certain level of compatibility behind the scenes:
- Type class
Empty
makes testing for the empty value (null
) possible (should probably be a subclass of Monoid, though) - Type class
ListLike
gives youhead
andtail
and(++)
- Type class
ListSource
is for types that can be viewed as Lists (via operationtoList
). Currently, String, Maybe and arrays. Note that list comprehension not only allows[a]
, but instances ofListSource
on the right hand side of generators.
Both lists and strings are instances of the above classes and this way certain basic functions do work on both lists and strings, just like in Haskell, though the type of those functions is a bit more general in Frege.
Bottom line: As long as you use simple functions like null
, (++)
, head
, tail
and list comprehension you may not even notice that strings are not lists in Frege.