Re: [Haskell-cafe] Stacking data types

2011-04-11 Thread Job Vranish
Yep you probably don't need the fundep, you just might need to provide more signatures. It does imply one 'b' for an 'a' which probably isn't what you want. On Wed, Apr 6, 2011 at 6:13 PM, Yves Parès wrote: > Thank you all, > > In fact, Brandon, I knew about Datatypes a la carte, I just found it

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread Yves Parès
Thank you all, In fact, Brandon, I knew about Datatypes a la carte, I just found it overly complicated. Thanks for you solution, Job. However (and even if it doesn't work without it) I fail to see why you need the functional dependency on Has... Doesn't it implies here that for one 'a' there can

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread Job Vranish
I think you want something like this: {-# Language MultiParamTypeClasses , FlexibleInstances , FunctionalDependencies , UndecidableInstances , FlexibleContexts , OverlappingInstances #-} data Character a = Character { life :: Int,

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread Serguey Zefirov
I think I should suggest HList from Oleg Kiseliov. http://hackage.haskell.org/package/HList That way you will have something along those lines: -- fields descriptors: data Character data Gun data Armor data Life -- values for fields: data Vulcan = Vulcan { vulcanAmmoCount :: Int} data Player =

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread Richard Senington
On 06/04/11 20:32, Brandon Moore wrote: From: Yves Parès Sent: Wed, April 6, 2011 1:57:51 PM Hello Café, I'm trying to get some modular data types. The idea that came to me is that I could stack them, for instance : data Character a = Character { life :: Int, cha

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread Brandon Moore
>From: Yves Parès >Sent: Wed, April 6, 2011 1:57:51 PM > >Hello Café, > >I'm trying to get some modular data types. >The idea that came to me is that I could stack them, for instance : > >data Character a = Character { life :: Int, > charaInner :: a } > >data Gun a =

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread KC
What about record types? On Wed, Apr 6, 2011 at 11:58 AM, Yves Parès wrote: > I meant: > > chara = Character 100 $ Armor 40 $ Gun 12 () > > 2011/4/6 Yves Parès >> >> Hello Café, >> >> I'm trying to get some modular data types. >> The idea that came to me is that I could stack them, for instance

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread Yves Parès
I meant: chara = Character 100 $ Armor 40 $ Gun 12 *()* 2011/4/6 Yves Parès > Hello Café, > > I'm trying to get some modular data types. > The idea that came to me is that I could stack them, for instance : > > data Character a = Character { life :: Int, >charaIn

[Haskell-cafe] Stacking data types

2011-04-06 Thread Yves Parès
Hello Café, I'm trying to get some modular data types. The idea that came to me is that I could stack them, for instance : data Character a = Character { life :: Int, charaInner :: a } data Gun a = Gun { firepower :: Int, gunInner :: a } data Ar