Type signature inside an instance declaration
ndmitchell at gmail.com
Tue Dec 16 07:35:47 EST 2008
> 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
pr xs = "[" ++ pr (undefined `asTypeOf` head x) ++ "]"
Or even more simply:
pr xs = "[" ++ pr (head x) ++ "]"
I do believe there is some GHC extension that can be turned on to
refer to variables like you did, but its not standard Haskell.
More information about the Glasgow-haskell-users