On Dec 20, 2007 5:36 PM, Jules Bean <[EMAIL PROTECTED]> wrote:
> 2. Maybe you want lots of possible different "a"s for each "g". Then you
> make "a" a parameter of the class too.
> 3. Maybe you want just one particular "a" for each "g". I.e. "g"
> determines "a". Then you can proceed as for (2), b
On Dec 20, 2007 5:44 PM, david48 <[EMAIL PROTECTED]> wrote:
> fString :: Int -> FString
> fString n = FString n ""
Oo do I feel dumb for writing this !
Problem solved :)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/m
On Dec 20, 2007 5:26 PM, Tillmann Rendel
<[EMAIL PROTECTED]> wrote:
> at this point fInit has this type:
>FString -> a -> FString
> > fInit (FString n _) s = FString n (take n s)
> but your implementation has this type
>FString -> String -> FString
> These types are incompatible, your fI
Tillmann Rendel wrote:
david48 wrote:
class Gadget g where
fInit :: g -> a -> g
Tillman's two suggestions (below) are probably your answer.
Just to say what everyone else has said in a bunch of different ways:
your class says that for ANY Gadget, fInit will work with ANY OTHER type a.
T
david48 wrote:
class Gadget g where
fInit :: g -> a -> g
data FString = FString !Int !String deriving Show
instance Gadget FString where
at this point fInit has this type:
FString -> a -> FString
fInit (FString n _) s = FString n (take n s)
but your implementation has this type
On Dec 20, 2007 5:03 PM, Claude Heiland-Allen
<[EMAIL PROTECTED]> wrote:
> You're trying to apply 'take n' to a value of type 'a' ('take n'
> requires [a]), moreover putting the value of 'take n s' into the FString
> further constrains its type to be [Char] == String.
First of all, thanks a lot f
david48 wrote:
| I'm really inexperienced at this :
class Gadget g where
fInit :: g -> a -> g
data FString = FString !Int !String deriving Show
instance Gadget FString where
fInit (FString n _) s = FString n (take n s)
The types of:
> fInit :: g -> a -> g
and:
> take :: Int -> [a] ->
I'm really inexperienced at this :
---
{-# OPTIONS_GHC -fglasgow-exts -funbox-strict-fields
-fallow-undecidable-instances -O2 #-}
class Gadget g where
fInit :: g -> a -> g
data FString = FString !Int !String deriving Show
instance Gadget FString where
fInit (FString n _) s = FStrin