Simon Marlow marlowsd at
Tue Sep 8 14:58:38 UTC 2015

On 08/09/2015 13:10, Simon Peyton Jones wrote:
> |  Without any unlifted kind, we need
> |    - ArrayArray#
> |    - a set of new/read/write primops for every element type,
> |      either built-in or made from unsafeCoerce#
> |
> |  With the unlifted kind, we would need
> |    - ArrayArray#
> |    - one set of new/read/write primops
> |
> |  With levity polymorphism, we would need
> |    - none of this, Array# can be used
> I don't think levity polymorphism will work here.  The code for a function needs to know whether an intermediate value of type 'a' is strict or not. It HAS to choose (unless we compile two versions of every function).  So I don't see how to be polymorphic over a type variable that can range over both lifted and unlifted types.
> The only reason that 'error' is levity-polymorphic over both lifted and unlifted types is that it never returns!
>    error :: forall (a :: AnyKind).  String -> a
> the code for error never manipulates a value of type 'a', so all is well.  But it's an incredibly special case.

I think there's a bit of confusion here, Ed's email a bit earlier 
described the proposal for the third option above:

For generalising these primops it would be fine, there are no thunks 
being built.


More information about the ghc-devs mailing list