[Haskell-cafe] Defining a type depending on the word size of platform

Robert Clausecker fuzxxl at gmail.com
Sun Jan 2 13:45:13 CET 2011

Hi guys!

I'm working on a random generator package and want to ask, whether it's
possible to generate a type like Int, that can have different sizes at


The package ships to generators, one for 32 (lets name it MyGen32) and
one for 64 bits (MyGen64). As it is not good for performance to use the
wrong one, I also want to provide a type MyGen, that is either a type
synonym for MyGen32 or MyGen64, depending on the platform. Any ideas how
to do this at compile time? I want this to compile with Cabal so that
anybody can download it as a package.

I guess the easiest way would be to use CPP, but is there any flag for
the wordsize?

Yours, Robert Clausecker

More information about the Haskell-Cafe mailing list