Skip to content

Instantly share code, notes, and snippets.

@yihuang
Created May 12, 2018 20:28
Show Gist options
  • Select an option

  • Save yihuang/866c5045572b0bb09bb3aad4b7945e91 to your computer and use it in GitHub Desktop.

Select an option

Save yihuang/866c5045572b0bb09bb3aad4b7945e91 to your computer and use it in GitHub Desktop.
Minimal demo for Data.Reflection usage.
{-# LANGUAGE FlexibleContexts, RecordWildCards, ConstraintKinds #-}
import System.Environment
import Data.Reflection
newtype Config = Config{
cfgCount :: Int
}
type HasConfig = Given Config
test :: HasConfig => Int
test = cfgCount given
main = do
(n:_) <- getArgs
print $ give (Config (read n)) test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment