
Hi Folks, Here's a problem that's frustrating me: I have defined a parametrized record type which looks like this: data Job a = Job { jobID :: String , jobName :: String , jobTable :: String , jobSource :: IO [a] , jobProcessors :: [a -> a] } where a is a data model type that maps on to a database table, for example: data Person = Person { name :: String , age :: Int } deriving (Show) data Car = Car { brand :: String , value :: Double , year :: Int } deriving (Show) I would like to define a higher-level record type which contains, for configuration purposes, a certain set of jobs for execution. Let's say we call it a JobSet and which could possibly look like this: data JobSet = JobSet { jobsetID :: String , jobsetName :: String , jobs :: [Job] <-- yes I know this is not legal } Is there a legal haskell way to achieve the above objective without having to do something like this which hardcodes the model type into the jobset schema? data JobSet = JobSet { jobsetID :: String , jobsetName :: String , personJobs :: [Job Person] , carJobs :: [Job Car] } Many thanks for any enlightenment on this front. Alia

On Thu, Oct 2, 2014 at 7:31 PM, Alia
I would like to define a higher-level record type which contains, for configuration purposes, a certain set of jobs for execution. Let's say we call it a JobSet and which could possibly look like this:
data JobSet = JobSet { jobsetID :: String , jobsetName :: String , jobs :: [Job] <-- yes I know this is not legal }
Are you sure you don't want data JobSet a = JobSet {jobsetID :: String ,jobsetName :: String ,jobs :: [Job a] } ? -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (2)
-
Alia
-
Brandon Allbery