Reputation: 1308
In Haskell :
ghci> :type null
null :: [a] -> Bool
In Frege :
frege> :type null
Empty α => α β -> Bool
How do I interpret this answer and why is there a difference?
(example from real-world haskell as adapted in real-world frege git repo)
Upvotes: 4
Views: 184
Reputation: 36349
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:
Empty
makes testing for the empty value (null
) possible (should probably be a subclass of Monoid, though)ListLike
gives you head
and tail
and (++)
ListSource
is for types that can be viewed as Lists (via operation toList
). Currently, String, Maybe and arrays. Note that list comprehension not only allows [a]
, but instances of ListSource
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.
Upvotes: 5