I have a constant declaration in Haskell -- can I force this to be evaluated ahead of time? I\'m seeing some code that looks roughly like,
myList = [(a, b), (c,
Generating a compile-time constant using Template Haskell:
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH.Syntax(Lift(..))
test = $(lift $ (map (*20) [0..100] :: [Int]))
lift
takes a Haskell value and lifts it into a TH Exp. The $()
runs the enclosed quote, and splices the generated exp into the code at compile time.