[Haskell-cafe] A new type of newtype --- Type-level instance diversification and resolution (tl; dr)
Joachim Breitner
mail at joachim-breitner.de
Tue May 30 00:52:21 UTC 2017
Hi,
Am Donnerstag, den 25.05.2017, 21:26 -0400 schrieb Albert Y. C. Lai:
> class MyOrd (resolver :: k) a where
> mycmp :: p resolver -> a -> a -> Ordering
neat!
Have you considered using Symbol (i.e. type-level strings) instead of
an arbitrary kind k? Would that have any advantages or disadvantages?
I wonder because of
> I thank jadrian from IRC for proposing "named instance":
>
> > so instead of "instance Num n => Monoid (Sum n) where" we'd write
> > e.g.
> > "instance Sum of Num n => Monoid n where" and use it as
> > "Sum.mempty"
and “names” are more often than not “strings”.
But then, arbitary kinds are more flexible, e.g. when you want to
parametrize the resolver:
data PointWise r
instance MyOrd r a -> MyOrd (PointWise r) [a]
Greetings,
Joachim
--
Joachim “nomeata” Breitner
mail at joachim-breitner.de • https://www.joachim-breitner.de/
XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170529/0f071372/attachment.sig>
More information about the Haskell-Cafe
mailing list