How to refer to data type "anything"?

In Milewski’s lecture at [Category Theory 2.2: Monomorphisms, simple types - YouTube], he (Category Theory 2.2: Monomorphisms, simple types - YouTube)
he refers to a data type “anything” and uses the symbol “a”

How can I refer to this data type?
I tried

ff :: Anything -> Int

and it said
“not in scope”

Same question for data type “Unit”

Just use a. For example:

const1 :: a -> Int
const1 = const 1

In Haskell, types that start with a lowercase letter are type variables. Types that start with a capital letter refer to actual types which need to be defined. So your error is coming from the fact that you are trying to reference a type called Anything, but of course that hasn’t been defined yet. And if it was, it wouldn’t be a polymorphic type variable. People often use single letters for type variables, like f :: a -> b -> c -> d, but they don’t have to be, you could write your function ff :: anything -> Int if you wanted to. The point is that in order for the type to be treated as a type variable, it has to start lowercase.

As for Unit, in Haskell the type is called (), as in f :: () -> () is a function from Unit to Unit. () also happens to be the name of the data constructor for the type, which might be confusing.

Honestly, from looking at your last few questions, I would want to say that Bartosz’s lectures are great, but they are not an introduction to Haskell and if you want to apply what you’re learning to the language, then you should really spend some time reading an introduction to Haskell instead of trying to brute force the category theory into it. It’ll take a small amount of more time to start but in the long run you’ll save a massive amount of time by not having to fight with the compiler every time you want to test something because the syntax doesn’t match up 1 to 1.

2 Likes