GHCJS

Victor Nazarov asviraspossible at gmail.com
Thu Aug 4 22:24:05 CEST 2011


On Fri, Aug 5, 2011 at 12:02 AM, Simon Peyton-Jones
<simonpj at microsoft.com> wrote:
> |  data LiteralDesugaring m =
> |    LiteralDesugaring
> |      { desugarInt :: MonadThings m => Integer -> m CoreExpr
> |      , desugarWord :: MonadThings m => Integer -> m CoreExpr
> ...
>
> I am not sure why you want to control the desugaring of literals.  Why literals?  And why is literals enough?
>

I'm not sure if literals are enough, but literals essentially as
dependencies on ghc-prim package:

    5

is desugared to something like

    GHC.Num.fromInteger (GHC.Integer.SmallInteger (5# :: Int#))

and

    "Hello"

is desugared to something like

    GHC.String.unpackCString ("Hello"# :: Addr#)

Fore backends other than
drop-in-replacement-for-current-native-code-ghc-backend we may want
an alternative desugarings. For example,
 * we may want to use some very simple Integer implementation. We can
use doubles instead of integers at first to get things rolling.
 * in javascript we better use other "unpacking" function for strings,
since Javascript strings doesn't have terminating NUL and have length
built-in.

-- 
Victor Nazarov



More information about the Glasgow-haskell-users mailing list