[Haskell-beginners] Fwd: Re: Multiple letters between -> ->
Marcus Manning
iconsize at gmail.com
Thu Nov 30 11:37:12 UTC 2017
Sorry again fo the long break,
and thanks for explanation.
Three Questions:
1.) Because (->) is defined with itself, it is also a Meta Type
Constructor (TYPE == variable Rank Type == a Meta Type ?)
2.) How do I define a function which takes a 3-Kinded Type:
let f:: h (g a); f a = a
where g * -> * and h (*->*)->*, but it did not work as:
h is deduced to be h * -> *.
Prelude> let f:: h (g a); f a = a
<interactive>:42:18: error:
• Couldn't match type ‘h’ with ‘(->) (g a)’
‘h’ is a rigid type variable bound by
the type signature for:
f :: forall (h :: * -> *) (g :: * -> *) a. h (g a)
at <interactive>:42:5-15
Expected type: h (g a)
Actual type: g a -> g a
• The equation(s) for ‘f’ have one argument,
but its type ‘h (g a)’ has none
• Relevant bindings include
f :: h (g a) (bound at <interactive>:42:18)
What can I do?
3.)
Is there any tool in Haskel where I can see which function parameter is
bound to the given input, for instance something like a function showBinds:
showBinds const (\c -> "s") (\(b,c) -> "c")
Prelude> Param a gets (\c -> "s")
b gets (\(b,c) -> "c")
This is a simple example, but it gets more complicated with massive use
of autocurrying.
On 11/25/2017 05:39 PM, Francesco Ariis wrote:
> On Sat, Nov 25, 2017 at 04:19:04PM +0100, Marcus Manning wrote:
>> But why I can call g with Just:
>>
>>
>> let g :: h a b -> h a b; g a = a
>>
>> g Just
>>
>> but Just is a->Maybe a
> Because (->) is a type constructor itself, just with
> convenient infix syntax:
>
> λ> :k (->)
> (->) :: TYPE q -> TYPE r -> *
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20171130/282dfdf7/attachment.html>
More information about the Beginners
mailing list