[Haskell-beginners] how to feel free of the Implementation of Data structure

吴兴博 wuxb45 at gmail.com
Fri Mar 25 05:32:43 CET 2011


:) Thanks.

2011/3/24 Brent Yorgey <byorgey at seas.upenn.edu>:
> On Thu, Mar 24, 2011 at 06:34:57PM +0800, 吴兴博 wrote:
>>
>> 2.
>> f1 :: (Integral a) => a -> String
>> f2 :: (Integral a) => String -> a
>>
>> pipe = f1 . f2
>> It is clear that pipe is String -> String,
>
> Actually, this code will give an "ambiguous type" error, since the
> compiler cannot figure out what type 'a' should be.  And the type that
> is chosen may make a difference for the behavior.
>
>> but.(1)How can I know what instance that 'a' is.
>>     (2)How can I determine what instance of 'a' is.
>
> If you know what type you want to use for 'a' you can specify it with
> a type annotation, like this:
>
>  pipe = f1 . (f2 :: String -> Int)
>
> -Brent
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
----------------
吴兴博



More information about the Beginners mailing list