
7 Jun
2009
7 Jun
'09
4:20 p.m.
The idea is that fs accepts a polymorphic function as its argument. What type signature can I specify for f in order to compile this code?
As you said yourself, you need to add a type signature to fs:
{-# LANGUAGE RankNTypes #-}
fs :: ((forall a . ((a, a) -> a)) -> t) -> (t, t) fs g = (g fst, g snd)
examples = (fs id, fs repeat, fs (\x -> [x]), fs ((,)id))
Hope this helps, Wouter This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.