0 | module Idris.Doc.Brackets
4 | import Idris.Doc.Annotations
9 | getDocsForBracket : BracketType -> Doc IdrisDocAnn
10 | getDocsForBracket IdiomBrackets = vcat $
11 | header "Idiom brackets" :: ""
14 | Idiom brackets allow for easier application of `Applicative`s
16 | Adding two `Maybe Int`s can be written using `<*>` and `pure`
19 | addMaybe : Maybe Int -> Maybe Int -> Maybe Int
20 | addMaybe x y = pure (+) <*> x <*> y
23 | This can be expressed more concisely as:
26 | addMaybe : Maybe Int -> Maybe Int -> Maybe Int
27 | addMaybe x y= [| x + y |]
30 | getDocsForBracket NameQuote = vcat $
31 | header "Name quotes" :: ""
34 | Name quotes convert a raw name into a representation of a name.
35 | This allows elaborator scripts to refer to names the user provides.
38 | import Language.Reflection
39 | %language ElabReflection
42 | nameOfMaybe = `{Maybe}
45 | Names can be qualified, however no disambiguation of names occurs when
46 | quoting them, so if you need a disambiguated name consider using
47 | `Language.Reflection.getType`.
49 | getDocsForBracket TermQuote = vcat $
50 | header "Term quotes" :: ""
53 | These allow an expression to be interpreted as a syntax tree rather than
54 | an actual expression, so it can be processed by an elaborator script
55 | for compile time codegen or meta-programming.
58 | import Language.Reflection
59 | %language ElabReflection
62 | helloWorld = `(putStrLn "hello world")
65 | getDocsForBracket DeclQuote = vcat $
66 | header "Declaration quotes" :: ""
69 | Declarations quotes allow multiple declaration
70 | (e.g. type declarations or function definitions) to be quoted
72 | These can then be passed to a elaborator script for compile time
73 | codegen or meta-programming.
76 | import Language.Reflection
77 | %language ElabReflection
79 | myProgram : List Decl
81 | data Bool = False | True
84 | main = putStrLn "hello world"
88 | In this example, `main : IO ()` and
89 | `main = putStrLn "hello world"` are different `Decl`s