Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Tener

Tener/Config.hs Secret

Created January 10, 2012 13:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Tener/4eae297562ae26781b01 to your computer and use it in GitHub Desktop.
Save Tener/4eae297562ae26781b01 to your computer and use it in GitHub Desktop.
quote a module contents with a string literal -- Template Haskell solution
{-# LANGUAGE TemplateHaskell #-}
module Config where
import Language.Haskell.TH
import Data.List.Split (splitOn)
-- START
-- extractCtxs'dumpSize :: Int
-- extractCtxs'dumpSize = 100000
extractCtxs'ctxSize :: Int
extractCtxs'ctxSize = 300
extractCtxs'sparse :: Bool
extractCtxs'sparse = True
selectWords'dropBorder :: Int
selectWords'dropBorder = 20000
selectWords'takeCount :: Int
selectWords'takeCount = 100
-- STOP
config' = $(do
s <- runIO $ readFile "lib/Config.hs"
return $ LitE $ stringL s)
config = head . splitOn "-- STOP" . head . tail . splitOn "-- START" $ config'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment