[Haskell-cafe] Curry and uncurry
Dan Weston
westondan at imageworks.com
Thu Oct 4 22:36:43 EDT 2007
Here is one trick I have found useful on occasion:
Prelude> :t let f = undefined :: (Num a) => (a,a) -> a in curry f
let f = undefined :: (Num a) => (a,a) -> a in
curry f :: (Num a) => a -> a -> a
undefined (also called bottom) is an element of every type, so if you
just need "something" with a given type, you can write
undefined :: YOUR_TYPE_HERE
If you're having typing troubles in a complex expression, stick in
annotated (i.e. the suffix :: SOME_TYPE) unknowns as placeholders, then
replace them until the type breaks. Use parentheses (undefined :: TYPE)
to be sure, since the binding strength of :: is not high.
PR Stanley wrote:
> No, still no idea!
> I tried curry f
> where f :: (Num a) => (a, a) -> a
> and it didn't like it.
> For some reason I'm finding this a little chalenging.
> Thanks, Paul
> At 17:03 03/10/2007, you wrote:
>> On 10/3/07, PR Stanley
>> <<mailto:prstanley at ntlworld.com>prstanley at ntlworld.com> wrote:
>> I didn't even know about the curry and uncurry functions. I'm not
>> looking for the answer but some guidance would be much appreciated.
>> Thanks, Paul
>>
>>
>> You can look at the types without seeing the implementation, too. Just
>> start up GHCI and type:
>>
>> :t curry
>>
>> or
>>
>> :t uncurry
>>
>> Justin
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
More information about the Haskell-Cafe
mailing list