Here's the setup:
I have a series of problems that use various logical connectives. The
problem is that they're not all the same. So instead of creating one
giant datatype (or duplicating much code), I'd like to assemble them
like toy blocks.
I've boiled down an example here:
data
You probably want to look at this:
http://wadler.blogspot.com/2008/02/data-types-la-carte.html
which refers to a paper about this exact problem.
The main types you want are:
newtype Fix a = In { out :: a (Fix a) }
data (f :+: g) x = Inl (f x) | Inr (g x)
Yes, you end up with a ton of
minor correction:
test = and [empty, empty]
On 4/16/08, Ryan Ingram [EMAIL PROTECTED] wrote:
You probably want to look at this:
http://wadler.blogspot.com/2008/02/data-types-la-carte.html
which refers to a paper about this exact problem.
The main types you want are:
newtype Fix a = In
Hi, I am learning the haskell programming language and had tried to define the
following types:
type Scenario = (String, String, [Step])
type Step = (String, Scenario, String, String, String)
Notice that Scenario depends on a list of steps and Step has a dependence with
scenario. I know that
Rodrigo wrote:
type Scenario = (String, String, [Step])
type Step = (String, Scenario, String, String, String)
Recursive types are not supported by type-declarations. use data
declarations instead:
data Scenario = Scenario String String [Step]
data Step = Step String Scenario String
Notice that Scenario depends on a list of steps and Step has a dependence
with scenario. I know that this is a kind of bad smell in Haskell, are
there any pattern or language idiom to deal with cyclical dependences?
Just a little something to add, this is not a bad smell at all... in