The introduction of the servant paper contains the following example API type:
type Echo = "echo"
:> ReqBody ’[PlainText] String
:> Get ’[PlainText] String
I am attempting to understand this example. It appears to be defining a type synonym, but seems to involve some things that I have not seen before.
Here are three questions that I have about it:
- How is there a string literal in the definition of a type?
"echo"
is a string literal. I thought these were only used to define specific strings and don't know what this means when used in a type declaration.
- What is the symbol
:>
?
The definition of this symbol in the 'servant' package appears to be defined here and looks like this:
data (path :: k) :> a
deriving (Typeable)
infixr 9 :>
I would guess that :>
corresponds to a /
in an api string, but do not see how this definition would make that happen.
This is the first time I am seeing a non-alphanumeric type other than the function type ->
.
- What does the apostrophe before the list type mean?
[PlainText]
I would understand to simply represent a list of PlainText elements, but in contrast I do not understand what ’[PlainText]
means.