I am learning haskell and i need some advice about writing
functional-style code.
Give the following code below, my question is - how do i setup a
dependency of User on Common?
Obviously what i have there is wrong, because a change in common (i know
it's actually immutable) is not reflected in the version captured by
User. I understand why my current approach has not a chance a of
working, I am using it to, hopefully, illustrate my goal.
Thanks for any suggestions
> data Common = Common {
> cName :: String,
> cValue :: Int
> } deriving (Show)
> data User = User {
> uCommon :: Common
> } deriving (Show)
> makeWorld = (commons, users)
> where
> commons = [Common "A" 1, Common "B" 2]
> users = [User (head commons)]
>
> main = do
> let world = makeWorld
> putStrLn (show world)
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe