
7 Dec
2007
7 Dec
'07
9:30 a.m.
On Dec 7, 2007 4:46 PM, Luke Palmer
On Dec 7, 2007 6:27 AM, Victor Nazarov
wrote: nary 0 x [] = x nary n f (x:xs) | n > 0 = nary (n-1) (f $ read x) xs
Sometimes it helps to write type signatures for functions. As in this case, where you'll find you won't be able to... :-)
Luke
Ok :)
{-# OPTIONS -fglasgow-exts #-} {-# OPTIONS -fallow-undecidable-instances #-}
data Zero data Succ a class Nary n x y | n x -> y where nary :: n -> x -> [String] -> y instance Nary Zero x x where nary _ x [] = x instance (Nary n y z, Read x) => Nary (Succ n) (x->y) z where nary _ f (x:xs) = nary (undefined::n) (f $ read x) xs -- vir http://vir.comtv.ru/