Type signature inside an instance declaration
Kwanghoon Choi
lazyswamp at gmail.com
Tue Dec 16 10:22:58 EST 2008
Many thanks for your helps.
Kwanghoon
On Tue, Dec 16, 2008 at 11:22 PM, Thomas Schilling
<nominolo at googlemail.com>wrote:
> {-# LANGUAGE ScopedTypeVariables #-}
>
> 2008/12/16 Neil Mitchell <ndmitchell at gmail.com>:
> > Hi
> >
> >> 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
> >
> > I prefer:
> >
> > 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.
> >
> > Thanks
> >
> > Neil
> > _______________________________________________
> > Glasgow-haskell-users mailing list
> > Glasgow-haskell-users at haskell.org
> > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
> >
>
>
>
> --
> Push the envelope. Watch it bend.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20081217/d8ba6503/attachment.htm
More information about the Glasgow-haskell-users
mailing list