[Haskell-cafe] Mutual recursive data types

2008-04-29 Thread rodrigo.bonifacio
Hi all,

I have the following data types:

type Id = String
type Action = String
type State = String
type Response = String

data Scenario = Scenario Description [Step]
data Step = Step Id Scenario Action State Response

So, there is a mutual recursion between Scenario and Step. Now, consider the 
following function:

xmlScenario2Scenario :: XmlScenario - Scenario
xmlScenario2Scenario (XmlScenario description steps) =
 Scenario  description [xmlStep2Step x | x -steps]

How can I send scenario as an argument for xmlStep2Step?

I've tried let and where but I get in a loop.

Thanks a lot,

Rodrigo.



---
Rodrigo Bonifácio de Almeida
Universidade Católica de Brasília
 - Grupo de Engenharia de Software
 - JavaComBr (www.ucb.br/java)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Mutual recursive data types

2008-04-29 Thread Luke Palmer
On Tue, Apr 29, 2008 at 8:54 AM, rodrigo.bonifacio
[EMAIL PROTECTED] wrote:
 Hi all,

  I have the following data types:

  type Id = String
  type Action = String
  type State = String
  type Response = String

  data Scenario = Scenario Description [Step]
  data Step = Step Id Scenario Action State Response

  So, there is a mutual recursion between Scenario and Step. Now, consider the 
 following function:

  xmlScenario2Scenario :: XmlScenario - Scenario
  xmlScenario2Scenario (XmlScenario description steps) =
   Scenario  description [xmlStep2Step x | x -steps]

  How can I send scenario as an argument for xmlStep2Step?

Like this:

   let scenario = Scenario description [xmlStep2Step scenario x | x - steps]
in scenario

  I've tried let and where but I get in a loop.

So it sounds like you already tried what I suggested.  If you get in a
loop, then whatever you are doing is too strict to handle this kind of
self-reference.  But it's hard to give suggestions without seeing more
of the code.

Luke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe