[Haskell-cafe] Global Arrays

Ketil Malde ketil at malde.org
Mon Mar 12 08:48:48 CET 2012


Clark Gaebel <cgaebel at csclub.uwaterloo.ca> writes:

> In Haskell, what's the canonical way of declaring a top-level array
> (Data.Vector of a huge list of doubles, in my case)? Performance is
> key in my case.
>
> The straightforward way would just be something like:
>
> globalArray :: V.Vector Double
> globalArray = V.fromList [ huge list of doubles ]
> {-# NOINLINE globalArray #-}
>
> However, I don't want to have to run the fromList at runtime.

I think GHC will convert it to an array (and in general evaluate
constants) at compile time (probably requires -O).

-k



More information about the Haskell-Cafe mailing list