Réf. : [Haskell-cafe] Re: circular imports
Henning Thielemann
schlepptop at henning-thielemann.de
Tue Sep 7 10:03:44 EDT 2010
corentin.dupont at ext.mpsa.com schrieb:
> That sort of code (stripped out):
>
> In Game.hs:
>
> data Game = Game { ...
> activeRules :: [Rule]}
>
> applyTo :: Rule -> Game -> Game
> applyTo r gs = ...
>
>
> In Rule.hs:
>
> data Rule = Cond (Obs) Rule Rule
> | many others..
> deriving (Read, Show, Eq, Typeable)
>
> data NamedRule = NamedRule { ...,
> rule :: Rule }
>
> isRuleLegal :: Rule -> NamedRule -> Game -> Bool
> isRuleLegal = ...
>
>
> In Obs.hs:
>
> data Obs a where
> ProposedBy :: Obs Int -- The player that proposed the tested rule
> ...
>
>
> evalObs :: Obs -> NamedRule -> Game -> EvalObsType
> evalObs = ...
As I see there is no cycle in the types. How about defining Game, Rule,
Obs in private modules, like Private.Game, Private.Rule, Private.Obs,
and implementing the functions in public modules like Game, Rule, Obs ?
More information about the Haskell-Cafe
mailing list