Re: [Haskell] type question revisited

2005-06-06 Thread Abraham Egnor
Your first attempt didn't typecheck simply because > in return () means that the return value of the function is monadic, but you did not declare as such. In your second version, the type of shf is *not* a rank-2 type; it's exactly the same type as shw. This can be expressed (with ghc extensions)

[Haskell] type question revisited

2005-06-06 Thread mv
I answered my own question only to raise another - what I wanted to do is this > foo :: (a -> String) -> [a] -> [String] > foo shw x = > let > shf :: ( forall a . a ) -> String > shf o = shw o > > in map shf x the type of shf is a rank 2 type - but how do you map it ? as

[Haskell] Type Question

2005-06-06 Thread mv
what is the type of 'shf' in > foo :: (a -> String) -> a -> () > foo shw x = > let > shf o = shw o > > in return () for it certainly is not 'shf :: a -> String', as this explicit signature will not type check ? Virus checked by G DATA AntiVirusKit Version: AVK 1

Re: a type question

2003-11-26 Thread Brandon Michael Moore
It depends what sort of polymorphism you want theta to have. If your function types involve concrete types you could write something like type IntMap = Int -> Bool -> String and then say theta :: IntMap -> Int -> String If you want the argument function to be completely polymorphic you can say t

Re: a type question

2003-11-26 Thread rui yang
Thanks. What I really want to know is: How to describe a new type (Funcmap) which is itself a function type like a->b- >c so that I can use this new type in other functions? for example, I can define some other functions like: theta :: Functionmap -> d ->e minus :: Funcmap ->.. I can put

Re: a type question

2003-11-26 Thread Lennart Augustsson
rui yang wrote: Suppose I have a function: funcmap :: a->b->c can I use type synonyms to describe a new type like this: Type Funcmap = a->b>c ? First, it's 'type' not 'Type'. Second, you want '->' not '>'. Third, all type variables in the RHS must be on the LHS. So, we get type Funcmap a b c

a type question

2003-11-26 Thread rui yang
Suppose I have a function: funcmap :: a->b->c can I use type synonyms to describe a new type like this: Type Funcmap = a->b>c ? it will give a syntax error message: syntax error in input (unexpected '->'), does anyone know how to define this Funcmap type? rui -

Re: Type question

1999-07-19 Thread Rob MacAulay
> Hi > I am new to Haskell and have a question about types. > > I have defined a type Type > > data Type = D1[Type] > | D2 String String [Type] > | D3 String String > | D4 > | > | D14 > deriving (Show) > > Where D4

Type question

1999-07-19 Thread Anders Nygren
Hi I am new to Haskell and have a question about types. I have defined a type Type data Type = D1 [Type] | D2 String String [Type] | D3 String String | D4 | | D14 deriving (Show) Where D4 - D14 each have 2-5 Strin

Re: type question

1999-01-17 Thread Jon Fairbairn
> > This is a distilled version of a problem that arose in a student's program: > > > f :: a -> a > > f x = g > >where > >g :: a > >g = x > > Reading file "[...]": > Type checking > ERROR "[...]" (line 5): Inferred type is not general enough > *** Expression: g > *** Expected ty

type question

1999-01-17 Thread Hamilton Richards Jr.
This is a distilled version of a problem that arose in a student's program: > f :: a -> a > f x = g >where >g :: a >g = x Reading file "[...]": Type checking ERROR "[...]" (line 5): Inferred type is not general enough *** Expression: g *** Expected type : a *** Inferred type : _2

RE: Haskel Type Question

1998-11-09 Thread Frank A. Christoph
>I have two functions > >> fos:: Num a -> [a] -> [a] >> fos a x = fos' a 0 x > >> fos':: Num a -> a -> [a] -> [a] >> fos' _ _ [] = [] >> fos' a y1 (x:xs) = y : fos' a y xs >>where y = a * y1 + x First of all, I think your type signatures are wrong, unless

RE: Haskel Type Question

1998-11-09 Thread Chris Angus
nly be along these lines. Hope this helps Chris > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On > Behalf Of Matthew Donadio > Sent: Monday, November 09, 1998 2:02 PM > To: Haskell List > Subject: Haskel Type Question > >

Haskel Type Question

1998-11-09 Thread Matthew Donadio
I have two functions > fos:: Num a -> [a] -> [a] > fos a x = fos' a 0 x > fos':: Num a -> a -> [a] -> [a] > fos' _ _ [] = [] > fos' a y1 (x:xs) = y : fos' a y xs >where y = a * y1 + x Why does > fos -0.5 [ 1, 1, 1, 1 ] give me [a] -> b -> [b] -> [b] i