9

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! :-)

Pratik Deoghare
  • 35,497
  • 30
  • 100
  • 146
  • 3
    If you want, you can just think of it as `instance Fluffy (t ->) where`, except operator sections are syntactically illegal in this case. – Justin L. Aug 19 '15 at 00:55

2 Answers2

4

(->) 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)
Lee
  • 142,018
  • 20
  • 234
  • 287
0

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

viorior
  • 1,783
  • 11
  • 16