For example, using GHCi,

ghci> f x = x + 1
ghci> :t f
f :: Num a => a -> a

What is the type of the type signature f :: Num a => a -> a?


I first encountered this question at work. Since I do not want to leak any information pertaining to my employment, I shall present a toy project instead.

Suppose that I have a list of fruits that I want to buy at a farmers' market, e.g.,

Fruits Quantity
Apple 5
Orange 4

Suppose that I save this list in a CSV file. When reading the CSV file, I would like to obtain a data structure in which the names of the fruits are not of type String but, rather, values of, say, the following sum type.

data Fruit = Apple | Coconut | Mango | Orange | Peach | Pear deriving (Eq, Show)

I would like to have a type signature as an input to the function that reads the CSV file — say, something that specifies that Fruits :: Fruit and Quantity :: Integer. However, what is the type of a type signature?

Please do note that this is not a question on how to write the aforementioned function in Haskell. Here, Haskell is used merely for the sake of clarity and succinctness. I am looking for references — books, theses, papers, technical reports, etc.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.