instance Applicative ((->) r) where
This is the implementation of the Applicative typeclass for a function in Haskell. I don't really understand the ((->) r)
and how to read it.
I think it means it is a function that takes one parameter and returns anything (another curried function, a String) but I'm not sure, is that right. Would that not be (r ->)
Here, ->
is a type-level operator; it takes two types and returns a new type (the function type). In ((->) r
, it's partially applied, so you can think of it as a type-level function that takes one type a
and returns the type of functions that take an r
and returns an a
.
((->) r) a == (->) r a -- function application is left-associative
== r -> a -- switch to infix notation
You could say (r ->)
, except Haskell doesn't support type-level sections. (And I don't think there is a GHC extension to enable such support.)
There isn't really a good way to read it, because it exists at a level of abstraction that isn't talked about commonly enough to merit a natural language description.
instance Applicative ((->) r) where
This is the implementation of the Applicative typeclass for a function in Haskell. I don't really understand the ((->) r)
and how to read it.
I think it means it is a function that takes one parameter and returns anything (another curried function, a String) but I'm not sure, is that right. Would that not be (r ->)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.