[Haskell-cafe] Is a type synonym declaration really a synonym ?

Stefan O'Rear stefanor at cox.net
Sat Dec 22 16:29:37 EST 2007


On Sat, Dec 22, 2007 at 10:22:46PM +0100, alpheccar wrote:
> Can someone confirm me that:
>
> type TA = A :+: B
> type TB = C :+: D
> type T = TA :+: TB
>
> is not equivalent to
>
> type T = A :+: B :+: C :+: D
>
> where I have defined
>
> infixr 6 :+:
> data (f :+: g)
> data A
> data B
> data C
> data D
>
> I have a computation at type level which is working with the later 
> definition of T but not with the former (ghc 6.8.1)

Type synonyms are implicitly parenthetized, and your :+: is
non-associative.  Compare:

s +:+ t = concat["(",s,",",t,")"]

foo = "a" +:+ "b"
bar = "c" +:+ "d"
baz = (foo +:+ bar) == ("a" +:+ "b" +:+ "c" +:+ "d")

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20071222/2cb2c9dd/attachment.bin


More information about the Haskell-Cafe mailing list