[Haskell-cafe] Mutually recursive types?

2008-04-16 Thread Ron Alford
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

Re: [Haskell-cafe] Mutually recursive types?

2008-04-16 Thread Ryan Ingram
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

Re: [Haskell-cafe] Mutually recursive types?

2008-04-16 Thread Ryan Ingram
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

[Haskell-cafe] mutually recursive types

2007-08-08 Thread rodrigo.bonifacio
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

Re: [Haskell-cafe] mutually recursive types

2007-08-08 Thread Tillmann Rendel
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

Re: [Haskell-cafe] mutually recursive types

2007-08-08 Thread Brent Yorgey
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