[Haskell-cafe] Confused about type seen in the wild
Jason Dagit
dagitj at gmail.com
Thu Apr 10 17:28:21 UTC 2014
On Thu, Apr 10, 2014 at 10:21 AM, Kim-Ee Yeoh <ky3 at atamo.com> wrote:
> No problems here:
>
> # ghci
> GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
> Loading package ghc-prim ... linking ... done.
> Loading package integer-gmp ... linking ... done.
> Loading package base ... linking ... done.
> Prelude> let whee :: Show a => Eq a => a => Bool; whee x = x == x && null
> (show x)
> Prelude> :t whee
> whee :: (Eq a, Show a) => a -> Bool
>
It seems to be an issue with giving everything on a single line:
$ ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude λ> let whee x = x == x && null (show x) :: Show a => Eq a => a =>
Bool
<interactive>:2:14:
Couldn't match expected type `a -> Bool' with actual type `Bool'
In the expression:
x == x && null (show x) :: Show a => Eq a => a => Bool
In an equation for `whee':
whee x = x == x && null (show x) :: Show a => Eq a => a => Bool
I see now to make it work as a one liner I could do it this way:
Prelude λ> :t (\x -> x == x && null (show x)) :: Show a => Eq a => a => Bool
(\x -> x == x && null (show x)) :: Show a => Eq a => a => Bool
:: (Eq a, Show a) => a -> Bool
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140410/67982f3d/attachment.html>
More information about the Haskell-Cafe
mailing list