[Haskell-cafe] GADTs and pattern matching

2013-06-19 Thread Francesco Mazzoli
Hi list, I have stumbled upon a strange annoyance: {-# LANGUAGE GADTs #-} data Foo v where Foo :: Foo (Maybe v) -- This doesn't work foo1 :: a - Foo a - Int foo1 Nothing Foo = undefined foo1 (Just x) Foo = undefined -- This does foo2 :: a - Foo

Re: [Haskell-cafe] GADTs and pattern matching

2013-06-19 Thread AntC
Francesco Mazzoli f at mazzo.li writes: I have stumbled upon a strange annoyance: {-# LANGUAGE GADTs #-} Hi Francesco, I think you'll find that the 'annoyance' is nothing to do with GADTs. I suggest you take the type signature off of foo1, and see what type ghc infers for it. It

Re: [Haskell-cafe] GADTs and pattern matching

2013-06-19 Thread Francesco Mazzoli
At Wed, 19 Jun 2013 10:03:27 + (UTC), AntC wrote: Hi Francesco, I think you'll find that the 'annoyance' is nothing to do with GADTs. I suggest you take the type signature off of foo1, and see what type ghc infers for it. It isn't :: a - Foo a - Int. [...] Yep, that message explains

Re: [Haskell-cafe] GADTs and pattern matching

2013-06-19 Thread Brent Yorgey
On Wed, Jun 19, 2013 at 11:11:16AM +0100, Francesco Mazzoli wrote: At Wed, 19 Jun 2013 10:03:27 + (UTC), AntC wrote: Hi Francesco, I think you'll find that the 'annoyance' is nothing to do with GADTs. I suggest you take the type signature off of foo1, and see what type ghc infers for

Re: [Haskell-cafe] GADTs and pattern matching

2013-06-19 Thread Francesco Mazzoli
At Wed, 19 Jun 2013 06:59:00 -0400, Brent Yorgey wrote: Yes, I was going to suggest switching the argument order before reading your message. This is an interesting way in which you can observe that Haskell does not really have multi-argument functions. All multi-argument functions are really

Re: [Haskell-cafe] GADTs and pattern matching

2013-06-19 Thread Felipe Almeida Lessa
Brent, maybe I'm misunderstanding what you're saying, but I don't think that the order of the arguments is playing any role here besides defining the order in which the pattern matches are desugared. To illustrate, -- This does work foo1' :: a - Foo a - Int foo1' m Foo = case m of

Re: [Haskell-cafe] GADTs and pattern matching

2013-06-19 Thread Brent Yorgey
Good point. I stand corrected. -Brent On Wed, Jun 19, 2013 at 11:42:23AM -0300, Felipe Almeida Lessa wrote: Brent, maybe I'm misunderstanding what you're saying, but I don't think that the order of the arguments is playing any role here besides defining the order in which the pattern matches