[Haskell-cafe] Re: [Haskell] intent-typing

Brandon Moore brandon_m_moore at yahoo.com
Tue Nov 16 15:04:19 EST 2010





----- Original Message ----
> From: aditya siram <aditya.siram at gmail.com>
> To: Haskell Café <haskell-cafe at haskell.org>
> Cc: haskell at haskell.org; Marcus Sundman <sundman at iki.fi>
> Sent: Tue, November 16, 2010 8:18:33 AM
> Subject: Re: [Haskell-cafe] Re: [Haskell] intent-typing
> 
> That was a great explanation of phantom types and type-families. I'm
> just  getting started on understand type families and I was wondering
> why you  didn't use data families in the truth table structure:
> type family Join a  b
>  type instance Join Safe Safe = Safe
>  type instance Join Safe Unsafe =  Unsafe
>  type instance Join Unsafe Safe = Unsafe
>  type instance Join Unsafe  Unsafe = Unsafe
> 
> My understanding is that since 'type' just produces a  type synonym and
> the last three type instances are "Unsafe", they are  equivalent.
> Wouldn't it be better to have  "data instance Join Safe  Unsafe ..." so
> that the compiler can distinguish between "Join Unsafe Safe",  "Join
> Safe Unsafe" and "Join Unsafe Unsafe" ?

The goal is to have ++ produce an AnnotatedString Safe or an AnnotatedString 
Unsafe,
reflecting the safety level. A data family would maintain the distinction, but 
then
AnnotatedString (Join Unsafe Unsafe) would not be equivalent to AnnotatedString 
Unsafe -
and what if you want to concatenate three pieces?

Brandon



      


More information about the Haskell-Cafe mailing list