Reputation: 37172
I am doing 20 intermediate Haskell exercises.
After finishing first 2 exercise there is this strange thing.
I would like to know what is ((->) t)
?
-- Exercise 3
-- Relative Difficulty: 5
instance Fluffy ((->) t) where
furry = error "todo"
Thanks! :-)
Upvotes: 9
Views: 190
Reputation: 1803
You should read prefix (->) t a
as infix t -> a
.
If we have
instance Fluffy Maybe where
for Maybe a
type (and * -> *
kind), then
instance Fluffy ((->) t) where
is for (->) t a == t -> a
type (and * -> *
kind) - for any function with 1 argument
Upvotes: 0
Reputation: 144126
(->)
is the type constructor for functions which has kind * -> * -> *
so it requires two type parameters - the input and result type of the function. ((->) t
is a partial application of this constructor so it is functions with an argument type of t
i.e. (t -> a) for some type a
.
If you substitute that into the type of the furry
function you get:
furry :: (a -> b) -> (t -> a) -> (t -> b)
Upvotes: 4