Puzzled by GHC.Types.LiftedRep

Simon Peyton Jones simonpj at microsoft.com
Wed Apr 24 08:05:05 UTC 2019


Try this paper<https://www.microsoft.com/en-us/research/publication/levity-polymorphism/>

The function type constructor actually has type
               (->) :: forall (r1::RuntimeRep) (r2::RuntimeRep).  TYPE r1 -> TYPE r2 -> TYPE LiftedRep

But when it appears applied to two argument, thus ((->) r1 r2 t1 t2), we print it infix (t1 -> t2).

So   (-> 'GHC.Types.LiftedRep 'GHC.Types.LiftedRep thing thing)
is the same as (thing -> thing).

I cannot explain why it is being printed in that non-infix way, but your email doesn’t give enough context to know.

I hope this helps a bit.  Where did you look for information? I’d like to add pointers that would have been helpful to you.

Simon


From: Ranjit Jhala <jhala at cs.ucsd.edu>
Sent: 24 April 2019 04:56
To: ghc-devs at haskell.org; Simon Peyton Jones <simonpj at microsoft.com>
Subject: Puzzled by GHC.Types.LiftedRep

Hi all,

Consider the following program:

```
import Control.Arrow (second)
import qualified Control.Monad.Trans.Reader as R

myLocal :: (r -> r) -> R.ReaderT r m a -> R.ReaderT r m a
myLocal = undefined

foo :: (thing -> thing) -> R.ReaderT (d, thing) m a -> R.ReaderT (d, thing) m a
foo arg = myLocal (second arg)
```

When compiled with GHC 8.6.4, I get the odd behavior that
at the call `second arg`, the type of `arg` is just:

   thing -> thing

but the *input* type of `second` (after applying the
various type  and dictionary parameters) is something
that looks like

while the *input* type of `second` (after the various type and dictionary applications etc.) is the mysterious (to me):

  (-> 'GHC.Types.LiftedRep 'GHC.Types.LiftedRep thing thing)

Can someone explain or point me to some documentation or
paper that describes what the above means? Specifically,
how/why does GHC "equate" the two things above in order
to consider the core well-formed?

Many thanks in advance!

- Ranjit.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20190424/4d93e80b/attachment.html>


More information about the ghc-devs mailing list