Type signature inside an instance declaration
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Tue Dec 16 07:26:54 EST 2008
"Kwanghoon Choi" <lazyswamp at gmail.com> wrote:
> =====================================================================
> instance Arg a => Arg [a] where
> pr _ = "[" ++ pr (undefined :: a) ++ "]"
> =====================================================================
You want to use `asTypeOf`, with a lazy pattern to name a value of type 'a'.
pr xs = "[" ++ pr (undefined `asTypeOf` x) ++ "]"
where (x:_) = xs
or
pr ~(x:_) = "[" ++ pr (undefined `asTypeOf` x) ++ "]"
Regards,
Malcolm
More information about the Glasgow-haskell-users
mailing list