[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 the above
gives
thise error in hugs:

Use of shf requires at least 1 argument





Virus checked by G DATA AntiVirusKit
Version: AVK 12.0.37 from 06.12.2002
Virus news: www.antiviruslab.com

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


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) as

 foo :: (a - String) - [a] - [String]
 foo (shw :: t) x =
 let shf :: t
 shf o = shw o
 in map shf x

or equivalently

 foo :: (a - String) - [a] - [String]
 foo (shw :: t - String) x =
 let shf :: t - String
 shf o = shw o
 in map shf x

The essential aspect is that the 'a' from the type signature is *not*
in scope for the let-bound type signature; you have to bring the
appropriate variable 't' in by using an in-line type signature for
'shw'.

Abe

On 6/3/05, mv [EMAIL PROTECTED] wrote:
 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 the above
 gives
 thise error in hugs:
 
 Use of shf requires at least 1 argument
 
 
 
 
 
 Virus checked by G DATA AntiVirusKit
 Version: AVK 12.0.37 from 06.12.2002
 Virus news: www.antiviruslab.com
 
 ___
 Haskell mailing list
 Haskell@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell