I was reading the Servant documentation and came across this line:
type UserAPI = "users" :> QueryParam "sortby" SortBy :> Get '[JSON] [User]
What is the '
doing to that list?
It is indeed convention to use a "tick" at the end of a function name to denote a slightly modified version of a previously defined function, but this is nothing other than convention - the apostrophe character has no intrinsic meaning in the Haskell language.
Single quotes means single character, double quotes means character array (string). In Haskell, 'c' is a single character ( Char ), and "c" is a list of characters ( [Char] ).
Quotes are used to distinguish type-level constructors vs. term-level constructors of promoted types.
For instance:
{-# LANGUAGE DataKinds #-}
data Which = One | Two
myPick :: Which -- Type
myPick = One
type MyPick :: Which -- Kind
type MyPick = 'One
By the way, the kind annotation type MyPick :: Which
is not valid Haskell but it gives you an idea of the correspondence between the term and the type level. The closest you can get to this requires turning on another extension:
{-# LANGUAGE TypeFamilies #-}
type family MyPick :: Which where
MyPick = 'One
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With