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
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
I think you want something like this:
{-# Language MultiParamTypeClasses
, FlexibleInstances
, FunctionalDependencies
, UndecidableInstances
, FlexibleContexts
, OverlappingInstances
#-}
data Character a = Character { life :: Int,
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 =
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
>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 =
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
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
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