happy: intToInt16# vs narrow16Int#

Ken Shan ken@digitas.harvard.edu
Tue, 28 Aug 2001 10:23:26 -0400


--n8g4imXOkfNTN/H1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2001-08-27T11:27:45+0100, Simon Marlow wrote:
> We're still using Happy from before your changes to make it not
> dependent on the word size, and that version still works with both 5.02
> and 5.00.2 because it doesn't use either intToInt16# or narrowInt16#.=20

Ah!  (smacks head)

> Unfortunately we can't just use conditional compilation in the template
> to pick the right one, because we can't force the generated parser to
> require -cpp to compile.  Or perhaps we should? Happy can put the flag
> automatically in the OPTIONS pragma at the top of the file.  Then we
> have to figure out how to quote these cpp directives in GenericTemplate
> so they don't get processed by the first pass of cpp.
>=20
> And for GHC >=3D 5.00, we really should be using indexInt16OffAddr#.

Another idea:

    import GlaExts
    import Int

    our_narrow16Int# :: Int# -> Int#
    our_narrow16Int# i#
      =3D case fromIntegral (fromIntegral (I# i#) :: Int16) of
        I# i16# -> i16#

But would this work with sufficiently earlier versions of GHC?

--=20
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
"Enjoy. It's dreadful, but it's quite short"
 - Dylan Moran, "Black Books"

--n8g4imXOkfNTN/H1
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7i6lezjAc4f+uuBURAh92AKDoR0Xeo2wqxEgjSMGOQh4qrn3oEQCgknn9
RAbDHWzsdPfMub2aUGGXsbg=
=gEAl
-----END PGP SIGNATURE-----

--n8g4imXOkfNTN/H1--