Help with coercion & roles?

Simon Peyton Jones simonpj at
Mon Apr 14 09:45:40 UTC 2014

I think you need a ‘Sub’.

A cast  (e `cast` g) requires a representational coercion.  I think you have given it a (stronger) nominal one.  Sub gets from one to t’other.


From: Glasgow-haskell-users [mailto:glasgow-haskell-users-bounces at] On Behalf Of Conal Elliott
Sent: 14 April 2014 06:00
To: ghc-devs at; glasgow-haskell-users at
Subject: Help with coercion & roles?

I’m working on a GHC plugin (as part of my Haskell-to-hardware work) and running into trouble with coercions & roles. Error message from Core Lint:

Warning: In the expression:


    @ (GHC.Types.Bool → GHC.Types.Bool → GHC.Types.Bool → GHC.Types.Bool)

    @ (Simple.HasIf GHC.Types.Bool)



        @ (GHC.Types.Bool → GHC.Types.Bool → GHC.Types.Bool → GHC.Types.Bool)


     `cast` (<LambdaCCC.Lambda.EP>_N (Sym (Simple.NTCo:HasIf[0] <GHC.Types.Bool>_N))

             ∷ LambdaCCC.Lambda.EP


                   → GHC.Types.Bool → GHC.Types.Bool → GHC.Types.Bool)


                LambdaCCC.Lambda.EP (Simple.HasIf GHC.Types.Bool)))

Role incompatibility: expected nominal, got representational

in <LambdaCCC.Lambda.EP>_N (Sym (Simple.NTCo:HasIf[0] <GHC.Types.Bool>_N))

Do you see anything inconsistent/incompatible in the coercions or roles above? I constructed the nominal EP Refl coercion, and applied it (AppCo) an existing coercion of a simpler type.

-- Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Glasgow-haskell-users mailing list