Re: Elimination of absurd patterns

2011-05-02 Thread Felipe Almeida Lessa
On Mon, May 2, 2011 at 6:20 PM, C Rodrigues  wrote:
> I was experimenting with using GADTs for subtyping when I found something
> interesting.  Hopefully someone can satisfy my curiosity.
> Here are two equivalent GADTs.  My understanding was that GHC would
> translate "Foo" and "Bar" into isomorphic data types.  However, GHC 6.12.3
> generates better code for 'fooName' than for 'barName'.  In 'fooName', there
> is no pattern match against 'FooExtra'.  In 'barName', there is a pattern
> match against 'BarExtra'.  What makes these data types different?

IIRC, GHC 6.12.3 had some problems with type equalities.  Did you try GHC 7.0.3?

Cheers, =)

-- 
Felipe.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Elimination of absurd patterns (reformatted)

2011-05-02 Thread Brent Yorgey
On Mon, May 02, 2011 at 09:25:06PM +, C Rodrigues wrote:
> 
> I'm re-sending this e-mail, hopefully with proper line breaks this time.
> 
> I was experimenting with using GADTs for subtyping when I found something 
> interesting.  Hopefully someone can satisfy my curiosity.
> 
> Here are two equivalent GADTs.  My understanding was that GHC would translate 
> "Foo" and "Bar" into isomorphic data types.
> However, GHC 6.12.3 generates better code for 'fooName' than for 'barName'.  
> In 'fooName', there is no pattern match against 'FooExtra'.
> In 'barName', there is a pattern match against 'BarExtra'.  What
> makes these data types different?

Not a real answer to your question, but have you tried this with GHC
7.0.3? The type checker changed a lot between 6.12 and 7 and it may
now behave more consistently (although I do not know for sure).

-Brent

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Elimination of absurd patterns (reformatted)

2011-05-02 Thread C Rodrigues

I'm re-sending this e-mail, hopefully with proper line breaks this time.

I was experimenting with using GADTs for subtyping when I found something 
interesting.  Hopefully someone can satisfy my curiosity.

Here are two equivalent GADTs.  My understanding was that GHC would translate 
"Foo" and "Bar" into isomorphic data types.
However, GHC 6.12.3 generates better code for 'fooName' than for 'barName'.  In 
'fooName', there is no pattern match against 'FooExtra'.
In 'barName', there is a pattern match against 'BarExtra'.  What makes these 
data types different?


data Tag
data TagExtra



data Foo a where
  Foo :: String -> Foo a
  FooExtra :: IORef String -> Foo TagExtra

-- The cmm code for fooName does not match against 'FooExtra'
fooName :: Foo Tag -> String
fooName (Foo s) = s



data Bar a where
  Bar :: String -> Bar a
  BarExtra :: a ~ TagExtra => IORef String -> Bar a

-- The cmm code for barName will try to pattern-match against 'BarExtra'
barName :: Bar Tag -> String
barName (Bar s) = s
  
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Elimination of absurd patterns

2011-05-02 Thread C Rodrigues

I was experimenting with using GADTs for subtyping when I found something 
interesting.  Hopefully someone can satisfy my curiosity.
Here are two equivalent GADTs.  My understanding was that GHC would translate 
"Foo" and "Bar" into isomorphic data types.  However, GHC 6.12.3 generates 
better code for 'fooName' than for 'barName'.  In 'fooName', there is no 
pattern match against 'FooExtra'.  In 'barName', there is a pattern match 
against 'BarExtra'.  What makes these data types different?

data Tagdata TagExtra

data Foo a where  Foo :: String -> Foo a  FooExtra :: IORef String -> Foo 
TagExtra
-- The cmm code for fooName does not match against 'FooExtra'fooName :: Foo Tag 
-> StringfooName (Foo s) = s

data Bar a where  Bar :: String -> Bar a  BarExtra :: a ~ TagExtra => IORef 
String -> Bar a
-- The cmm code for barName will try to pattern-match against 'BarExtra'barName 
:: Bar Tag -> StringbarName (Bar s) = s
  ___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[no subject]

2011-05-02 Thread hsing-chou chen
http://www.buonviaggioitaly.com/modules/mod_osdonate/myhome.html

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users