Getting a [(String, TypeRep)] from a Configuration object

This commit is contained in:
Zoe Roux
2021-03-02 11:13:28 +01:00
parent e265ec017a
commit a5a9fb652e
+28
View File
@@ -0,0 +1,28 @@
{-# LANGUAGE DeriveDataTypeable #-}
import Data.Data
import Data.Typeable
data Configuration = Configuration {
rule :: Int,
start :: Maybe Int,
lines :: Maybe Int,
window :: Maybe Int,
move :: Maybe Int
} deriving (Show, Data, Typeable)
argsName :: [String]
argsName = constrFields . head . dataTypeConstrs $ dataTypeOf (undefined :: Configuration)
argsType :: [TypeRep]
argsType = recurse $ typeOf Configuration
where recurse x = let (_, y) = splitTyConApp x in
case y of (z:zs:[]) -> z : recurse zs
[] -> []
args :: [(String, TypeRep)]
args = zip argsName argsType
--getOpt :: [String] -> Configuration
--getOpt [] ->