Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is ((->) t ) in haskell?

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

like image 609
Pratik Deoghare Avatar asked Aug 18 '15 14:08

Pratik Deoghare


People also ask

What is a Typeclass in Haskell?

What's a typeclass in Haskell? A typeclass defines a set of methods that is shared across multiple types. For a type to belong to a typeclass, it needs to implement the methods of that typeclass. These implementations are ad-hoc: methods can have different implementations for different types.

What are type signatures in Haskell?

From HaskellWiki. A type signature is a line like. inc :: Num a => a -> a. that tells, what is the type of a variable. In the example inc is the variable, Num a => is the context and a -> a is its type, namely a function type with the kind * -> * .

What does ++ mean in Haskell?

The ++ operator is the list concatenation operator which takes two lists as operands and "combines" them into a single list.


1 Answers

(->) 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)
like image 130
Lee Avatar answered Sep 18 '22 18:09

Lee