[Haskell-cafe] [weird stuff] The Dodgy Diagonal

Conor McBride ctm at Cs.Nott.AC.UK
Sat Jul 14 16:09:48 EDT 2007

Hi Stefan

Thanks for a very enlightening reply.

> In GHC 6.7.20070712 and Yhc, this is perfectly safe.

> In GRIN based systems like Jhc, this is *not* safe, since after
> evaluation comparisons are done using the full tag.

It's now occurred to me that at a cost of some noise, I could have  
done things
a little differently

On 14 Jul 2007, at 20:37, Stefan O'Rear wrote:

> On Sat, Jul 14, 2007 at 12:06:30PM +0100, Conor McBride wrote:
>> A peculiar query for folks who know more about the internals of  
>> Haskell
>> compilers than I do. I attach the full code with all the bits and  
>> pieces,
>> but let me pull out the essentials in order to state the problem.
>>> newtype Id          x = Id x                   -- element
>>> newtype K1 a        x = K1 a                   -- constant

 > newtype Up1 f p q x = U1 (f (p x) (q x))
 > type Sum1 = Up1 Either
 > type Prod1 = Up1 (,)

>>> newtype Fst         x y = Fst x
>>> newtype Snd         x y = Snd y
>>> newtype K2 a        x y = K2 a

 > newtype Up2 f p q x y = U2 (f (p x y) (q x y))
 > type Sum2 = Up2 Either
 > type Prod2 = Up2 (,)

>>> class (Bifunctor b, Functor f) => Diag b f | b -> f where
>>>   diag :: b x x -> f x
>>>   gaid :: f x -> b x x

and then all of my coercions would (recursively) have been between

Would that have more universal traction? I realise, of course that it's
all voodoo, and I shouldn't trust a thing.



More information about the Haskell-Cafe mailing list