Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. abstracting parametrized record types (Alia)
2. Re: abstracting parametrized record types (Brandon Allbery)
----------------------------------------------------------------------
Message: 1
Date: Thu, 2 Oct 2014 19:31:13 +0000 (UTC)
From: Alia <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] abstracting parametrized record types
Message-ID:
<1043822803.108276.1412278273309.javamail.ya...@jws10733.mail.gq1.yahoo.com>
Content-Type: text/plain; charset="utf-8"
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20141002/08bbe562/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 29 Apr 2015 23:27:16 +0000
From: Brandon Allbery <[email protected]>
To: Alia <[email protected]>, The Haskell-Beginners Mailing List
- Discussion of primarily beginner-level topics related to Haskell
<[email protected]>
Subject: Re: [Haskell-beginners] abstracting parametrized record types
Message-ID:
<cakfcl4vprvyz4cqg5xxr9tcfab1msfkdrkra2db49xibci-...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Thu, Oct 2, 2014 at 7:31 PM, Alia <[email protected]> wrote:
> 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
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150429/043ad377/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 82, Issue 44
*****************************************