In other words, you are saying that I want a feature, first class
polymorphism, that is now available in Hugs1.3c and from the docs,
GHC4.0?.

Since I am doing development in Hugs 1.4, I guess the question is when
will Hugs1.4  have this feature and is this feature
compatible with Derive?

Alternatively, since GHC 4.0 is there a way to run just the type-checker
part of GHC 4.0 without waiting for it to compile everything?

Also, has anyone manageed to build GHC4.0 for win32?

-Alex-

___________________________________________________________________
S. Alexander Jacobson                   i2x Media  
1-212-697-0184 voice                    1-212-697-1427 fax


On Mon, 26 Oct 1998, Peter Thiemann wrote:

> >>>>> "Alex" == S Alexander Jacobson <[EMAIL PROTECTED]> writes:
> 
> 
>     Alex> I wrote the following function that attempts to generalize show by
>     Alex> allowing the user to choose the function to stringify constructor
>     Alex> arguments.
> 
>     >> stringArgs' sep stringer1 (MyFoo x i s) = 
>     >> x' ++sep++i' ++ sep ++ s'
>     >> where 
>     >> x'=stringer' x
>     >> i'=stringer'' i
>     >> s'=stringer''' s
>     >> stringer' o=stringer o
>     >> stringer'' o=stringer o
>     >> stringer''' o =stringer o
>     >> stringer o=stringer1 o --!! replacing stringer1 w/ show works!
> 
>     Alex> This function generates a type error because stringer is being used as
>     Int-> Char and as Char->Char.  But, if I replace stringer1 in the last
>     Alex> line, with the function `show`, hugs allows this function.
> 
> OK, show :: forall a . Show a => a -> String [if my memory serves correctly]
> so it is polymorphic in the type a.
> However, the parameters of a function cannot (currently) have a
> polymorphic type. So when you want to pass show to stringArgs you will 
> have to use one particular instance of this type. In the present case, 
> you get Show a => a -> String [note that the forall is gone], but you
> cannot resolve the overloading because you do not know what a is. Hence
> 
>     Alex> However, if I use show and attempt to call this function using foo:
> 
>     >> foo x = stringArgs "\n" show (MyFoo "asd" 12 "asd")
> 
>     Alex> I get an ambiguous type signature error.
> 
> the ambiguity. If Haskell included first-class polymorphism (which is
> on the list for Haskell 2 and which is present in some form in Hugs
> 1.3c) and you provided an explicit signature, then your function and
> your example would work out. Modulo syntax, this is what is would look 
> like:
> 
> stringArgs' :: String -> (forall a . Show a => a -> String) -> MyFooType -> String
> stringArgs' sep stringer (MyFoo x i s) =
>       x' ++sep++i' ++ sep ++ s'
>   where 
>     x'=stringer x
>     i'=stringer i
>     s'=stringer s
> 
> And your function call would look just like the one above.
> 
> -Peter
> 



Reply via email to