1
votes

I understand haskell's function type declaration like,

length :: String -> Int
prefix :: Int -> String -> String

But sometimes, the types on the right side are not simple types like String, Integer but it contains multiple literal words, and the words that look like custom defined etc.

For example, these types defined on this post,

withLocation :: Q Exp -> Q Exp

What does Q, Exp mean?

formatLoc :: Loc -> String

What does Loc mean? Is it part of haskell library?

1
You're asking three questions in a single post. Limit posts to a single question.rightfold
The answer to most of your question is: you have something called kinds in Haskell - it's one step above types - so your String here has kind * and your Q has kind * -> * meaning: you have to give Q a type (something of kind *) and it will result in something of kind * (another type) - this is why you have to put both there - it's almost the same as with functions / partial application, ...Random Dev
for the other: there are a couple of types named Loc that Hayoo will find - if you look at the question it will be the one in Language.Haskell.TH I think - how to get emacs to work here is quite another question that depends on your emacs installation and your environment there ... this might be a lot of pain (and I usually don't care - use Hadock instead)Random Dev

1 Answers

3
votes

The types Q, Exp and Loc are types from the Template Haskell module imported at the beginning of the source file.

Q is a parameterized type, just like, say, Maybe or IO from the prelude, which is here applied to Exp.

How to do goto defintion from emacs editor?

This can be achieved using Scion, but that won't help you for this use case as it does not allow you to jump into external libraries (which may not be available in source form anyway).