Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of defining Hask?

Tags:

haskell

Occasionally I will see reference to Hask.

Which is described as:

Hask is the category of Haskell types and functions.

Which is a fair enough thing to try to define. If one likes to try and find ways to describe things. But generally when doing so one hopes to gain particular insights in the nature of the thing, or otherwise produce something from it.

  • What is the purpose of defining Hask?
  • Are there good examples of insights gained from this?
  • Does it just serve as a way to talk about certain things that would otherwise be hard to concisely define?
like image 638
Lyndon White Avatar asked Dec 22 '19 23:12

Lyndon White


Video Answer


1 Answers

The reason to do that is not so much to talk about Hask itself.

Many things we do talk about a lot – functors, monads, natural transformations... – aren't programming-specific let alone Haskell-specific, but come from maths – from category theory. Now, in maths, if you say “F is a functor” people will first ask “a functor between which categories?” In practice mathematicians might e.g. consider functors from the category of topological spaces to the category of abelian groups. Such a functor is quite a different beast from the kind of functors we're using in Haskell; yet it shares the very general properties of the “abstract nonsense” category theory.

To apply the maths rigorously to what we want to do in Haskell, we need to be explicit, and that's where the term Hask comes in:

Haskell functors are functors from the category Hask to itself.

You could of course “inline” the definition of Hask here

Haskell functors are functors from the category of Haskell types (with Haskell functions as morphisms) onto itself.

but that would get cumbersome quickly.

like image 135
leftaroundabout Avatar answered Oct 13 '22 20:10

leftaroundabout