ArrayArrays

Simon Peyton Jones simonpj at microsoft.com
Tue Sep 8 12:10:19 UTC 2015


|  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.

Simon


More information about the ghc-devs mailing list