Coercible class (Was: newtype wrappers)

Joachim Breitner mail at joachim-breitner.de
Mon Sep 16 08:05:11 UTC 2013


Hi,

Am Montag, den 16.09.2013, 05:53 +0000 schrieb Simon Peyton-Jones:
> > a) A newtype can be casted only if its constructor is visible.
> > b) Casting below a type constructor (instance Coercible a b => Coercible
> >        (Maybe a) (Maybe b)) is possible if the roles allow it; the constructor
> >        does not have to be visible or exposed, except that
> > c) in Safe Haskell code, the constructor or the typecon (and all
> >        constructors of all typecons used in the definition of the typecon) has
> >        to be visible.
> 
> Has anyone talked to David Terei about the Safe Haskell check (c)
> above?

No, not yet. In order to meet the deadline I put in what seems to me the
safest variant to start with.

>   It's not clear to me whether (c) is necessary.  (And it would need
> to recursively check those tycoons, I think.  Are you doing that?)

I do check them recursively. It is necessary because, from what I
understood, we really want the “could I have written this by hand”
property in Safe Haskell. And with 

        data D1 a = MkD1 a
        data D2 a = MkD2 (D1 a)
        
I really need access to both MkD1 and MkD2 to be able to write

        coerceUnderD2 :: (a -> b) -> D2 a -> D2 b.

But I’d be happy to change that check to whatever the Safe Haskell
experts prefer.

Greetings,
Joachim

-- 
Joachim Breitner
  e-Mail: mail at joachim-breitner.de
  Homepage: http://www.joachim-breitner.de
  ICQ#: 74513189
  Jabber-ID: nomeata at joachim-breitner.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130916/ae02514f/attachment.pgp>


More information about the ghc-devs mailing list