
There's a number of weirdnesses currently that basically fall out of the
fact that the kinds Constraint and * are treated identically internally.
See https://ghc.haskell.org/trac/ghc/ticket/11715 and stay tuned; it's not
going to be fixed for 8.2 but probably will for 8.4 --- unless more bugs
come crawling out of the woodwork, as has been happening a lot if you look
at the ticket history. :)
On Mon, May 15, 2017 at 5:09 PM, Al Zohali
Dear Cafe!
I've encountered quite strange behaviour in GHC (v8.0.2) and I would like to ask you to give me a hint.
Suppose we have the following functions: ---- foo :: (Show a) => Int -> a -> [String] foo n = replicate n . show
bar :: Int -> (Show a) => a -> [String] bar n = replicate n . show
baz :: Int -> a -> (Show a) => [String] baz n = replicate n . show ----
This won't compile, and that is ok. But if we add `RankNTypes` extension, this will compile and (:t) will give us the same signature for all three functions.
There are two things I cannot get:
1) Why do this even compile? I saw constraints being defined either in the beginning of a signature or right after `forall` expression. I thought that it was a rule (or convention), but it's not. Is this way of declaring constraints (in the middle of a signature) discouraged or can be considered as a bug?
2) Even if this was supposed to be so, why was the constraint in `baz` hoisted to the top? There are at least two ways to interpret that signature: ---- baz :: Int -> a -> forall a. (Show a) => [String] baz :: forall a. (Show a) => Int -> a -> [String] ---- Is there any reason why the second one was chosen? _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net