[Haskell-cafe] working my way through Data.Type.Equality...my head hurts...

Nicholls, Mark nicholls.mark at vimn.com
Tue Jan 13 12:39:23 UTC 2015


Full code here…
https://github.com/goldfirere/nyc-hug-oct2014/blob/master/Equality.hs

Lets start at the beginning…


Ø  data a :~: b where

Ø  Refl :: a :~: a

Looks reasonable….” a :~: b” is inhabited by 1 value…of type “a :~: a”



Ø  sym :: (a :~: b) -> (b :~: a)

Ø  sym Refl = Refl

hmmm… (a :~: b) implies that a is b
so (b :~: a)
brilliant


Ø  -- | Transitivity of equality

Ø  trans :: (a :~: b) -> (b :~: c) -> (a :~: c)

Ø  trans Refl Refl = Refl


Ø  -- | Type-safe cast, using propositional equality

Ø  castWith :: (a :~: b) -> a -> b

Ø  castWith Refl x = x

fine….

But….


Ø  -- | Generalized form of type-safe cast using propositional equality

Ø  gcastWith :: (a :~: b) -> ((a ~ b) => r) -> r

Ø  gcastWith Refl x = x

I don’t even understand the signature

What does “~” mean…(it’s something that comes out in error messages when my types are all messed up)….and then there’s a “=>” going on…in the middle of a signature….I know “=>” in the context of “Num a => a -> a -> a”

What would a value of type “((a ~ b) => r)” look like?




CONFIDENTIALITY NOTICE

This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited.

While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data.

Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us.

MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe.  MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20150113/ea3d8352/attachment.html>


More information about the Haskell-Cafe mailing list