[Haskell-cafe] Mild confusion around type family

Nicholls, Mark nicholls.mark at vimn.com
Sun Jun 21 12:06:42 UTC 2015

ugly...but effective.


From: adam vogt [vogt.adam at gmail.com]
Sent: 20 June 2015 16:34
To: Richard Eisenberg
Cc: haskell-cafe; Nicholls, Mark
Subject: Re: [Haskell-cafe] Mild confusion around type family

On Jun 19, 2015 2:29 PM, "Richard Eisenberg" <eir at cis.upenn.edu<mailto:eir at cis.upenn.edu>> wrote:
> With a closed family, you could always do something like this:
> > type family Error (msg :: Symbol)     -- no instances!
> > type family Sub a b where
> >   -- real work
> >   Sub a b = Error "Sub is undefined here"
> Would that help? It still doesn't immediately error (there's no way to do that currently), but it's perhaps more telling to have an error string.

Ghc does error out right away if you give it an infinite loop:

type family Fail (x::k) (a :: *) where
  Fail x a = Fail x (Fail "don't raise the context stack please" a)

-- defining f leads to compile failure, and the message includes the "msg"
f :: Fail "msg" ()
f = undefined

But it would be nice to have a less hacky solution, especially as this one gives error messages that suggest giving the type checker more resources.


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://mail.haskell.org/pipermail/haskell-cafe/attachments/20150621/d03e1e90/attachment.html>

More information about the Haskell-Cafe mailing list