Verified Commit b8062717 authored by Camil Staps's avatar Camil Staps 🚀

Use new single-page HTML documentation

parent 4ac02c92
Pipeline #42121 passed with stages
in 10 minutes
......@@ -3,7 +3,7 @@ definition module Builtin.Predef
from Cloogle.DB import :: FunctionEntry, :: ClassEntry, :: TypeDefEntry,
:: CleanLangReportLocation
CLR :: Int String String -> CleanLangReportLocation
CLR :: !String -> CleanLangReportLocation
builtin_functions :: [FunctionEntry]
builtin_classes :: [ClassEntry]
......
......@@ -20,30 +20,27 @@ import Clean.Types
import Cloogle.API
import Cloogle.DB
CLR :: Int String String -> CleanLangReportLocation
CLR f sec h =
{ clr_version = v
, clr_file = "CleanRep." + v + "_" <+ f <+ ".htm"
CLR :: !String -> CleanLangReportLocation
CLR sec =
{ clr_version = "3.0"
, clr_section = sec
, clr_heading = h
}
where v = "2.2"
builtin_functions :: [FunctionEntry]
builtin_functions =
[ { zero
& fe_loc=Builtin "if" [CLR 5 "3.4.2" "_Toc311798001"]
& fe_loc=Builtin "if" [CLR "3.4.2"]
, fe_type=Just $ Func [Type "Bool" [], Var "a", Var "a"] (Var "a") (TypeContext [])
}
, { zero
& fe_loc=Builtin "dynamic" [CLR 10 "8.1" "_Toc311798076"]
& fe_loc=Builtin "dynamic" [CLR "8.1"]
, fe_type=Just $ Func [Var "a"] (Type "Dynamic" []) (TypeContext [Instance "TC" [Var "a"]])
}
]
builtin_classes :: [ClassEntry]
builtin_classes =
[ { ce_loc=Builtin "TC" [CLR 10 "8.1.4" "_Toc311798080"]
[ { ce_loc=Builtin "TC" [CLR "8.1.4"]
, ce_vars=["v"]
, ce_is_meta=False
, ce_context=TypeContext []
......@@ -58,24 +55,24 @@ builtin_classes =
builtin_types :: [TypeDefEntry]
builtin_types =
[ { deft
& tde_loc=Builtin "Bool" [CLR 6 "4.1" "_Toc311798017"]
& tde_loc=Builtin "Bool" [CLR "4.1"]
, tde_typedef.td_name = "Bool"
, tde_typedef.td_rhs = TDRCons False
[ { defc & cons_name="False" }
, { defc & cons_name="True" }
]
}
, { deft & tde_loc=Builtin "Int" [CLR 6 "4.1" "_Toc311798017"], tde_typedef.td_name = "Int"}
, { deft & tde_loc=Builtin "Real" [CLR 6 "4.1" "_Toc311798017"], tde_typedef.td_name = "Real"}
, { deft & tde_loc=Builtin "Char" [CLR 6 "4.1" "_Toc311798017"], tde_typedef.td_name = "Char"}
, { deft & tde_loc=Builtin "Dynamic" [CLR 10 "8" "_Toc311798077"], tde_typedef.td_name = "Dynamic"}
, { deft & tde_loc=Builtin "File" [CLR 6 "4.7" "_Toc311798037"], tde_typedef.td_name = "File"}
, { deft & tde_loc=Builtin "Int" [CLR "4.1"], tde_typedef.td_name = "Int"}
, { deft & tde_loc=Builtin "Real" [CLR "4.1"], tde_typedef.td_name = "Real"}
, { deft & tde_loc=Builtin "Char" [CLR "4.1"], tde_typedef.td_name = "Char"}
, { deft & tde_loc=Builtin "Dynamic" [CLR "8"], tde_typedef.td_name = "Dynamic"}
, { deft & tde_loc=Builtin "File" [CLR "4.7"], tde_typedef.td_name = "File"}
, { deft
& tde_loc=Builtin "String" [CLR 6 "4.7" "_Toc311798037"]
& tde_loc=Builtin "String" [CLR "4.7"]
, tde_typedef.td_name = "String"
, tde_typedef.td_rhs = TDRSynonym (Type "_#Array" [Type "Char" []]) }
, { deft
& tde_loc=Builtin "World" [CLR 6 "4.7" "_Toc311798037"], tde_typedef.td_name = "World"
& tde_loc=Builtin "World" [CLR "4.7"], tde_typedef.td_name = "World"
, tde_typedef.td_uniq = True
, tde_doc = Just
{ TypeDoc | gDefault{|*|}
......@@ -83,7 +80,7 @@ builtin_types =
}
}
, { deft
& tde_loc=Builtin "->" [CLR 6 "4.6" "_Toc311798036"]
& tde_loc=Builtin "->" [CLR "4.6"]
, tde_typedef.td_name = "(->)"
, tde_typedef.td_args = [Var "a", Var "b"]
, tde_doc = Just
......@@ -132,7 +129,7 @@ where
make_list :: [Char] [Char] -> TypeDefEntry
make_list k s =
{ deft
& tde_loc = Builtin higherorder [CLR 6 "4.2" "_Toc311798019"]
& tde_loc = Builtin higherorder [CLR "4.2"]
, tde_typedef.td_name = toString (['_':k] ++ ['List'] ++ s)
, tde_typedef.td_args = [Var "a"]
, tde_doc = Just
......@@ -172,7 +169,7 @@ where
make_array :: [Char] -> TypeDefEntry
make_array k =
{ deft
& tde_loc = Builtin typec [CLR 6 "4.4" "_Toc311798029"]
& tde_loc = Builtin typec [CLR "4.4"]
, tde_typedef.td_name = toString (['_':k] ++ ['Array'])
, tde_typedef.td_args = [Var "a"]
, tde_doc = Just
......@@ -194,7 +191,7 @@ where
make_tuple :: Int -> TypeDefEntry
make_tuple n =
{ deft
& tde_loc = Builtin typec [CLR 6 "4.3" "_Toc311798026"]
& tde_loc = Builtin typec [CLR "4.3"]
, tde_typedef.td_name = "_Tuple" <+ n
, tde_typedef.td_args = [Var $ toString [v:repeatn (n / 26) '`'] \\ v <- cycle ['a'..'z'] & n <- [0..n-1]]
, tde_doc = Just
......
......@@ -98,7 +98,7 @@ bs_basicvalues =
"An escape sequence is a character escape, a hexademical escape (starting with `x`), an octal escape (starting with `0` to `7`) or a decimal escape (starting with `d`).\n\n" +
"Reals can be suffixed by a power of ten in the scientific notation.\n\n" +
"Basic values can also be pattern matched with these notations."
, syntax_doc_locations = [CLR 6 "4.1.1" "_Toc311798017"]
, syntax_doc_locations = [CLR "4.1.1"]
, syntax_examples = map (EXs "rhs")
[ "(42, -42, +42) // Tuple with 42, -42 and 42 in decimal notation"
, "(052, -052, +052) // Tuple with 42, -42 and 42 in octal notation"
......@@ -119,7 +119,7 @@ bs_case =
[ "Pattern match on an expression and do something depending on the alternative of the matching pattern."
, "Both `->` and `=` can be used to separate patterns and alternatives, however, they cannot be mixed."
]
, syntax_doc_locations = [CLR 5 "3.4.2" "_Toc311798001"]
, syntax_doc_locations = [CLR "3.4.2"]
, syntax_examples =
[ add_imports ["StdMaybe"] $ EXs "macro"
"isJust m = case m of\n\tJust _ -> True\n\t_ -> False"
......@@ -136,7 +136,7 @@ bs_class =
, syntax_description =
"Classes are (sets of) overloaded functions. For classes with only one member function, a simplified syntax exists.\n\n" +
"Types can instantiate classes with the {{`instance`}} keyword."
, syntax_doc_locations = [CLR 8 "6.1" "_Toc311798056"]
, syntax_doc_locations = [CLR "6.1"]
, syntax_examples = map EX
[ "class zero a :: a // one member"
, "class Text s // multiple members\nwhere\n\ttextSize :: !s -> Int\n\tconcat :: ![s] -> s\n\t/* etc... */"
......@@ -150,7 +150,7 @@ bs_code =
, syntax_description =
"A code block with raw ABC instructions, which can be used for primitive functions like integer addition, for linking with C, bypassing the type system... welcome down the rabbit hole!\n\n" +
"When `inline` is used, the function will be inlined when applied in a strict context."
, syntax_doc_locations = [CLR 13 "11.2" "_Toc311798115"]
, syntax_doc_locations = [CLR "11.2"]
, syntax_examples = map EX
[ "add :: !Int !Int -> Int // Primitive function\nadd a b = code inline {\n\taddI\n}"
, "sleep :: !Int !*World -> *(!Int, !*World) // Linking with C\nsleep n w = code {\n\tccall sleep \"I:I:A\"\n}"
......@@ -163,7 +163,7 @@ bs_comments =
, syntax_patterns = map exact ["//", "/\\*.*", "\\*/", "comments?"]
, syntax_code = ["// ...", "/* ... */"]
, syntax_description = "`//` adds a single-line comment. `/*` and `*/` encapsulate a multi-line comment. Multi-line comments can be nested."
, syntax_doc_locations = [CLR 15 "B.2" "_Toc311798132"]
, syntax_doc_locations = [CLR "B.2"]
, syntax_examples = map EX
[ "Start = 37 // Single-line comment"
, "Start = /* inline or multi-line comment */ 37"
......@@ -185,7 +185,7 @@ bs_context =
, "The context of a generic function can only contain other generic functions."
, "The generic context is written without kinds and separated by `,` as seen in the example."
]
, syntax_doc_locations = [CLR 8 "6.2" "_Toc311798057"]
, syntax_doc_locations = [CLR "6.2"]
, syntax_examples = map (add_imports ["StdEnv","Data.GenEq"] o EX)
[ "add :: a a -> a | + a // a must instantiate +\nadd x y = x + y"
, "sum :: [a] -> a | zero, + a // a must instantiate zero and +\nsum [] = zero\nsum [x:xs] = x + sum xs"
......@@ -205,7 +205,7 @@ bs_define_constant =
"Defining constants with `=:` at the top level makes sure they are shared through out the program; hence, they are evaluated only once.\n\n" +
"This is the default understanding of `=` in local scope.\n\n" +
"The inverse is {{`=>`}}, which defines an identifier to be a constant function."
, syntax_doc_locations = [CLR 5 "3.6" "_Toc311798007"]
, syntax_doc_locations = [CLR "3.6"]
, syntax_examples = [add_imports ["StdEnum"] $ EXs "macro" "mylist =: [1..10000]"]
}
bs_define_graph =
......@@ -216,7 +216,7 @@ bs_define_graph =
"Defining constants with `=>` makes sure they are interpreted as constant functions; hence, they are evaluated every time they are needed.\n\n" +
"This is the default understanding of `=` in global scope.\n\n" +
"The inverse is {{`=:`}}, which defines an identifier to be a graph."
, syntax_doc_locations = [CLR 5 "3.6" "_Toc311798007"]
, syntax_doc_locations = [CLR "3.6"]
, syntax_examples = [add_imports ["StdEnum"] $ EXs "macro" "mylist => [1..10000]"]
}
......@@ -227,7 +227,7 @@ bs_dotdot =
, syntax_description =
"A shorthand for lists of enumerable types.\n\n" +
"To use these expressions, you must import {{`StdEnum`}}. The underlying functions are defined in {{`_SystemEnum`}}."
, syntax_doc_locations = [CLR 6 "4.2.1" "_Toc311798023"]
, syntax_doc_locations = [CLR "4.2.1"]
, syntax_examples = map (add_imports ["StdEnum"] o EXs "macro")
[ "xs = [0..] // 0, 1, 2, 3, ..."
, "xs = [0,2..] // 0, 2, 4, 6, ..."
......@@ -241,7 +241,7 @@ bs_exists =
, syntax_patterns = map exact ["E", "E\\.*", "existential"]
, syntax_code = [":: ... = E. ...: ..."]
, syntax_description = "Existential quantifiers make it possible to define (recursive) objects of the same type with different types of content."
, syntax_doc_locations = [CLR 7 "5.1.3" "_Toc311798042"]
, syntax_doc_locations = [CLR "5.1.3"]
, syntax_examples = [EX ":: List = E.e: Cons e List | Nil\nStart = Cons 5 (Cons 'a' (Cons \"abc\" Nil))"]
}
......@@ -271,7 +271,7 @@ bs_forall =
, syntax_patterns = map exact ["A", "A\\.*"]
, syntax_code = ["A. ...:"]
, syntax_description = "Explicitly marks polymorphic type variables. Clean does not yet allow universal quantifiers on the topmost level."
, syntax_doc_locations = [CLR 5 "3.7.4" "_Toc311798013"]
, syntax_doc_locations = [CLR "3.7.4"]
, syntax_examples = map (add_imports ["StdEnv"] o EX)
[ "h :: (A.a: [a] -> Int) -> Int // The quantifier is needed to apply the function to both a [Int] and a [Char]\nh f = f [1..100] + f ['a'..'z']"
, ":: T = C (A.a: a -> a) // In a type"
......@@ -288,7 +288,7 @@ bs_foreign =
, syntax_description =
"Exports the Clean function symbol to the binary.\n\n" +
"This is only possible if the function is also in the definition module and all arguments are basic types or tuples and fully strict."
, syntax_doc_locations = [CLR 13 "11.1" "_Toc311798114"]
, syntax_doc_locations = [CLR "11.1"]
, syntax_examples = map EX
[ "foreign export factorial // Export the factorial function"
, "foreign export stdcall factorial // Idem but with the stdcall calling convention"
......@@ -317,7 +317,7 @@ bs_function_definition =
, "Instead of `=`, also {{`=:`}} and {{`=>`}} may be used to separate the pattern from the right-hand side."
, "These have different semantics."
]
, syntax_doc_locations = [CLR 5 "3" "_Toc311797995"]
, syntax_doc_locations = [CLR "3"]
, syntax_examples = map EX
[ "map :: (a -> b) [a] -> [b]\nmap f [] = []\nmap f [x:xs] = [f x:map f xs]"
]
......@@ -335,7 +335,7 @@ bs_guard =
, "To separate the guard from the alternative, both {{`=`}} and {{`=>`}} may be used (with different semantics; see {{`=>`}})."
, "However, one must be consistent with this throughout the function."
]
, syntax_doc_locations = [CLR 5 "3.3" "_Toc311797998"]
, syntax_doc_locations = [CLR "3.3"]
, syntax_examples = map (add_imports ["StdEnv"] o EX)
[ "sign :: !Int -> Int\nsign n\n| n < 0 = -1 // Negative number\n| n == 0 = 0 // Zero\n| otherwise = 1 // Must be positive"
]
......@@ -350,7 +350,7 @@ bs_generic =
, "This avoids very similar code snippets."
, "Generic functions are said to be kind-indexed, i.e., a generic is actually a group of functions with different types depending on the kind of the deriving type."
]
, syntax_doc_locations = [CLR 9 "7.2" "_Toc311798069"]
, syntax_doc_locations = [CLR "7.2"]
, syntax_examples =
[ add_imports ["StdEnv","StdGeneric"] $ EX $
"generic gEq a :: !a !a -> Bool // The type of a generic function\n" +
......@@ -394,7 +394,7 @@ bs_import =
"With the `from` keyword, one can achieve more granularity.\n\n" +
"In case of name clashes, `qualified` can be used (undocumented).\n\n" +
"Moreover, you can import from object files or windows DLLs."
, syntax_doc_locations = [CLR 4 "2.5" "_Toc311797991"]
, syntax_doc_locations = [CLR "2.5"]
, syntax_examples = map EX
[ "import StdEnv // Import all code from the StdEnv definition module"
, "from StdFunc import o // Import only the o function from StdFunc"
......@@ -421,7 +421,7 @@ bs_infix =
"Defines a function with arity 2 that can be used in infix position.\n\n" +
"The following number, if any, determines the precedence.\n\n" +
"`infixl` and `infixr` indicate associativity."
, syntax_doc_locations = [CLR 5 "3.7.2" "_Toc311798011"]
, syntax_doc_locations = [CLR "3.7.2"]
, syntax_examples =
[ EX "(bitor) infixl 6 :: !Int !Int -> Int // Left-associative infix function with precedence 6"
, EXs "macro" "(o) infixr 9 // Infix macro\n(o) f g :== \\x -> f (g x)"
......@@ -434,7 +434,7 @@ bs_instance =
, syntax_patterns = map exact ["instance"]
, syntax_code = ["instance ... ... where ..."]
, syntax_description = "Defines an instantiation of a {{class}} for a type."
, syntax_doc_locations = [CLR 8 "6.1" "_Toc311798056"]
, syntax_doc_locations = [CLR "6.1"]
, syntax_examples = map (add_imports ["StdOverloaded"] o EX)
[ "instance zero Int\nwhere\n\tzero = 0"
, "instance zero Real\nwhere\n\tzero = 0.0"
......@@ -446,7 +446,7 @@ bs_lambda =
, syntax_patterns = map exact ["lambda", "=", "->", "\\."]
, syntax_code = ["\\... -> ...", "\\... . ...", "\\... = ..."]
, syntax_description = "An anonymous, inline function."
, syntax_doc_locations = [CLR 5 "3.4.1" "_Toc311798000"]
, syntax_doc_locations = [CLR "3.4.1"]
, syntax_examples = map (add_imports ["StdList"] o EXs "macro")
[ "(o) f g = \\x -> f (g x) // Simple lambda expression"
, "swapall = map (\\(x,y) -> (y,x)) // Pattern matching in lambda arguments"
......@@ -462,7 +462,7 @@ bs_layout_rule =
"Most Clean programs are written using the layout rule, which means that scopes are indicated with indent levels." +
"The layout sensitive mode can be turned off by adding a semicolon `;` at the end of the {{module}} line." +
"Then, scopes have to be indicated with `{ ... }` and definitions have to end with `;`."
, syntax_doc_locations = [CLR 4 "2.3.3" "_Toc311797989"]
, syntax_doc_locations = [CLR "2.3.3"]
, syntax_examples = [EX $
"module test;\n" +
"import StdEnv;\n" +
......@@ -480,7 +480,7 @@ bs_let =
, syntax_patterns = map exact ["let", "in", "let in"]
, syntax_code = ["let ... in ..."]
, syntax_description = "An expression that introduces new scope."
, syntax_doc_locations = [CLR 5 "3.5.1" "_Toc311798003"]
, syntax_doc_locations = [CLR "3.5.1"]
, syntax_examples =
[ add_imports ["StdEnv"] $
EXs "macro"
......@@ -498,7 +498,7 @@ bs_let_before =
, syntax_patterns = map exact ["#", "#!"]
, syntax_code = ["# ... = ...", "#! ... = ..."]
, syntax_description = "A {{`let`}} expression that can be defined before a guard or function body, which eases the syntax of sequential actions."
, syntax_doc_locations = [CLR 5 "3.5.4" "_Toc311798006"]
, syntax_doc_locations = [CLR "3.5.4"]
, syntax_examples =
[ add_imports ["StdEnv"] $ EX $
"readchars :: *File -> *([Char], *File)\n" +
......@@ -518,7 +518,7 @@ bs_list_expressions =
"A list can be composed of individual elements or a head and a tail. Special syntax is available for creating `[{{Char}}]` lists.\n\n" +
"See also {{dotdot}} expressions.\n\n" +
"The colon is not an operator in Clean, because it must always be surrounded by `[` and `]`. It can therefore not be curried, flipped, etc."
, syntax_doc_locations = [CLR 6 "4.2.1" "_Toc311798021"]
, syntax_doc_locations = [CLR "4.2.1"]
, syntax_examples = map (EXs "macro")
[ "abc = ['a', 'b', 'c'] // Individual elements"
, "abc = ['a':['b':['c':[]]]] // Head and tail, ending with the empty list"
......@@ -534,7 +534,7 @@ bs_macro =
, syntax_description =
"A macro is a compile-time rewrite rule. It can be used for constants, inline subtitutions, renaming functions, conditional compilation, etc.\n\n" +
"Macros can appear in patterns to match on constants."
, syntax_doc_locations = [CLR 12 "10.3" "_Toc311798111"]
, syntax_doc_locations = [CLR "10.3"]
, syntax_examples = map (EXs "macro")
[ "flip f a b :== f b a // Useful for currying"
, "IF_INT_64_OR_32 int64 int32 :== int64 // Conditional compilation"
......@@ -547,7 +547,7 @@ bs_module =
, syntax_patterns = map exact ["module", "definition", "implementation", "system", "definition module", "implementation module", "system module"]
, syntax_code = ["[definition,implementation,system] module ..."]
, syntax_description = "The heading of a Clean file. Definition modules describe what things are exported (dcl files), implementation modules how they are implemented (icl files)."
, syntax_doc_locations = [CLR 4 "2.2" "_Toc311797983"]
, syntax_doc_locations = [CLR "2.2"]
, syntax_examples = map EX
[ "definition module StdList // Exported definitions of list functions"
, "implementation module StdList // The implementations of the functions"
......@@ -574,7 +574,7 @@ bs_overloaded_type_variable =
, syntax_patterns = map exact ["\\^", "\\w\\^"]
, syntax_code = ["... :: ...^"]
, syntax_description = "A pattern match on the type of a dynamic depending on the type of the function."
, syntax_doc_locations = [CLR 10 "8.2.5" "_Toc311798087"]
, syntax_doc_locations = [CLR "8.2.5"]
, syntax_examples =
[ add_imports ["StdMaybe"] $
EX $
......@@ -589,7 +589,7 @@ bs_pattern_named =
, syntax_patterns = map exact ["=:"]
, syntax_code = ["...=:(...)"]
, syntax_description = "Give a name to the expression of a pattern to be able to use the whole expression without creating new graphs."
, syntax_doc_locations = [CLR 5 "3.2" "_Toc311797997"]
, syntax_doc_locations = [CLR "3.2"]
, syntax_examples = map (add_imports ["StdMaybe"] o EX)
[ "isJustU e=:(Just _) = (True, e) // On an ADT"
, ":: Position = {px :: Int, py :: Int}\ngetx p=:{px} = (px, p) // On a record; this has type :: Position -> (Int, Position)"
......@@ -643,7 +643,7 @@ bs_selection_array =
, syntax_patterns = map exact ["\\.\\[\\]", "\\.\\[.*\\]", "\\.\\[,.*\\]", "\\.\\[.*,.*\\]"]
, syntax_code = [".[i]", ".[i,j,...]"]
, syntax_description = "Select an element from a (possibly multidimensional) array. The indexes must have the type {{`Int`}}."
, syntax_doc_locations = [CLR 6 "4.4.1" "_Toc311798033"]
, syntax_doc_locations = [CLR "4.4.1"]
, syntax_examples = map (add_imports ["StdEnv"] o EXs "macro")
[ "five = {!1,2,3,4,5,6,7,8,9,10}.[4] // Arrays are zero-indexed"
, "five = {!{!1,2},{3,4,5},{6,7,8}}.[1,2] // This is equivalent to (...).[1].[2]"
......@@ -654,7 +654,7 @@ bs_selection_array_unique =
, syntax_patterns = map exact ["!\\[\\]", "!\\[.*\\]", "!\\[,.*\\]", "!\\[.*,.*\\]"]
, syntax_code = ["![i]", "![i,j,...]"]
, syntax_description = "Select an element from a (possibly multidimensional, possibly unique) array and return both the element and the array. The indexes must have the type {{`Int`}}."
, syntax_doc_locations = [CLR 6 "4.4.1" "_Toc311798033"]
, syntax_doc_locations = [CLR "4.4.1"]
, syntax_examples = map (add_imports ["StdEnv"] o EXs "macro")
[ "(five,arr) = {!1,2,3,4,5,6,7,8,9,10}![4]"
, "(five,arr) = {!{!1,2},{3,4,5},{6,7,8}}![1,2]"
......@@ -665,7 +665,7 @@ bs_selection_record =
, syntax_patterns = map exact ["\\."]
, syntax_code = ["."]
, syntax_description = "Select a field from a (possibly multilevel) record."
, syntax_doc_locations = [CLR 7 "5.2.1" "_Toc311798050"]
, syntax_doc_locations = [CLR "5.2.1"]
, syntax_examples = map
( add_bootstrap ":: Position = {px :: Int, py :: Int}"
o add_bootstrap ":: Position3D = {pxy :: Position, pz :: Int}"
......@@ -681,7 +681,7 @@ bs_selection_record_unique =
, syntax_patterns = map exact ["!"]
, syntax_code = ["!"]
, syntax_description = "Select a field from a (possibly multilevel, possibly unique) record and return both the field data and the record."
, syntax_doc_locations = [CLR 7 "5.2.1" "_Toc311798050"]
, syntax_doc_locations = [CLR "5.2.1"]
, syntax_examples = map
( add_bootstrap ":: Position = {px :: Int, py :: Int}"
o add_bootstrap ":: Position3D = {pxy :: Position, pz :: Int}"
......@@ -699,7 +699,7 @@ bs_strict =
, syntax_patterns = map exact ["strict", "!"]
, syntax_code = ["!"]
, syntax_description = "Override the lazy evaluation strategy: the argument must be evaluated to head normal form before the function is entered."
, syntax_doc_locations = [CLR 5 "3.7.5" "_Toc311798014", CLR 12 "10" "_Toc311798103"]
, syntax_doc_locations = [CLR "3.7.5", CLR "10"]
, syntax_examples = [EX "acker :: !Int !Int -> Int"]
}
......@@ -708,7 +708,7 @@ bs_synonym =
, syntax_patterns = map exact ["synonym", ":=="]
, syntax_code = [":: ... :== ..."]
, syntax_description = "Defines a new type name for an existing type."
, syntax_doc_locations = [CLR 7 "5.3" "_Toc311798052"]
, syntax_doc_locations = [CLR "5.3"]
, syntax_examples = [EX ":: String :== {#Char}"]
}
bs_synonym_abstract =
......@@ -716,7 +716,7 @@ bs_synonym_abstract =
, syntax_patterns = map exact ["synonym", ":=="]
, syntax_code = [":: ... (:== ...)"]
, syntax_description = "Defines a new type name for an existing type, while the type behaves as an abstract type for the programmer. This allows compiler optimisations on abstract types."
, syntax_doc_locations = [CLR 7 "5.4.1" "_Toc311798054"]
, syntax_doc_locations = [CLR "5.4.1"]
, syntax_examples = [EX ":: Stack a (:== [a])"]
}
......@@ -725,7 +725,7 @@ bs_type_definition =
, syntax_patterns = map exact ["::", "=", "\\|"]
, syntax_code = [":: ..."]
, syntax_description = "Defines a new type. There are too many possibilities to list here; see the documentation."
, syntax_doc_locations = [CLR 7 "5" "_Toc311798038"]
, syntax_doc_locations = [CLR "5"]
, syntax_examples = map EX
[ join "\n\t" [":: Day // An algebraic data type","= Mon","| Tue","| Wed","| Thu","| Fri","| Sat","| Sun"]
, ":: Position = // A record type\n\t{ x :: Int\n\t, y :: Int\n\t}"
......@@ -737,7 +737,7 @@ bs_type_specification =
, syntax_patterns = map exact ["::"]
, syntax_code = ["... :: ..."]
, syntax_description = "Specifies the type of a function."
, syntax_doc_locations = [CLR 5 "3.7" "_Toc311798009"]
, syntax_doc_locations = [CLR "3.7"]
, syntax_examples = map EX
[ "map :: (a -> b) [a] -> [b] // map has arity 2\nmap f [] = []\nmap f [x:xs] = [f x:map f xs]"
, "map :: (a -> b) -> [a] -> [b] // map has arity 1\nmap f = \\xs -> case xs of\n\t[] -> []\n\t[x:xs] -> [f x:map f xs]"
......@@ -762,7 +762,7 @@ bs_unique =
, "Functions have to be split up into arity 1 and the subfunctions must be annotated as well; for instance:"
, "`T = T (Int *Int -> *Int)` has to be `T = T (Int -> *(*Int -> *Int))`."
]
, syntax_doc_locations = [CLR 11 "9.1" "_Toc311798093"]
, syntax_doc_locations = [CLR "9.1"]
, syntax_examples = map (add_imports ["StdEnv"] o EX)
[ "Start :: *World -> *World // World is unique"
, "copyArray :: *(a e) -> *(*a e, *a e) | Array a e // Add parentheses when needed"
......@@ -780,7 +780,7 @@ bs_update_array =
, "{ a & [i]=i \\\\ i <- [0,2..9] } // Fancy things can be done if you combine this with a ZF-expression. E.g. give the first 5 even indices the value of their index"
]
, syntax_description = "Updates an array by creating a copy and replacing one or more elements."
, syntax_doc_locations = [CLR 6 "4.4.1" "_Toc311798032"]
, syntax_doc_locations = [CLR "4.4.1"]
, syntax_examples = []
}
bs_update_record =
......@@ -792,7 +792,7 @@ bs_update_record =
, "# r & f1=x, f2=y, ... // Same as # r = {r & f1=x, f2=y, ...}" // See https://clean.cs.ru.nl/Clean_2.3
]
, syntax_description = "Updates a record by creating a copy and replacing one or more fields."
, syntax_doc_locations = [CLR 7 "5.2.1" "_Toc311798049"]
, syntax_doc_locations = [CLR "5.2.1"]
, syntax_examples = []
}
......@@ -801,7 +801,7 @@ bs_where_class =
, syntax_patterns = map exact ["where"]
, syntax_code = ["where"]
, syntax_description = "Introduces the members of a {{`class`}} definition."
, syntax_doc_locations = [CLR 8 "6.1" "_Toc311798056"]
, syntax_doc_locations = [CLR "6.1"]
, syntax_examples = [EX "class Arith a // Class definition\nwhere\n\t(+) infixl 6 :: a a -> a\n\t(-) infixl 6 :: a a -> a"]
}
bs_where_instance =
......@@ -809,7 +809,7 @@ bs_where_instance =
, syntax_patterns = map exact ["where"]
, syntax_code = ["where"]
, syntax_description = "Introduces the implementation of an {{`instance`}}."
, syntax_doc_locations = [CLR 8 "6.1" "_Toc311798056"]
, syntax_doc_locations = [CLR "6.1"]
, syntax_examples =
[ add_imports ["StdEnv"] $ EX $
":: T = C Int\n" +
......@@ -823,7 +823,7 @@ bs_where_local =
, syntax_patterns = map exact ["where"]
, syntax_code = ["where"]
, syntax_description = "Introduces local definitions. For guard-local definitions, see {{`with`}}."
, syntax_doc_locations = [CLR 5 "3.5.2" "_Toc311798004"]
, syntax_doc_locations = [CLR "3.5.2"]
, syntax_examples =
[ add_imports ["StdEnv"] $
EXs "macro" $
......@@ -838,7 +838,7 @@ bs_with =
, syntax_patterns = map exact ["with"]
, syntax_code = ["with"]
, syntax_description = "Introduces guard-local definitions. For function-local definitions, see {{`where`}}."
, syntax_doc_locations = [CLR 5 "3.5.3" "_Toc311798005"]
, syntax_doc_locations = [CLR "3.5.3"]
, syntax_examples =
[ add_imports ["StdEnv"] $
EXs "macro" $
......@@ -859,7 +859,7 @@ bs_zf =
, "{... \\\\ ... <- ...}"
]
, syntax_description = "Constructs a list or array composed of elements drawn from other lists or arrays. It is possible to use local definitions as well (see {{`let`}})."
, syntax_doc_locations = [CLR 6 "4.2.1" "_Toc311798024", CLR 6 "4.4.1" "_Toc311798032"]
, syntax_doc_locations = [CLR "4.2.1", CLR "4.4.1"]
, syntax_examples = map (add_imports ["StdEnv", "StdMaybe"] o EXs "macro")
[ "cartesian = [(x,y) \\\\ x <- [1,2,3], y <- [10,20]] // Cartesian product: (1,10), (1,20), (2,10), (2,20), (3,10), (3,20)"
, "zip xs ys = [(x,y) \\\\ x <- xs & y <- ys] // Pairwise zip through the lists"
......
Subproject commit bf824ab422841292c9952035588435cf994e6dd0
Subproject commit 399f0baf1f02d0cc89a3f52b5b037e2194aa55f8
......@@ -460,7 +460,7 @@ function getResults(str, libs, include_builtins, include_core, include_apps, pag
if (i != 0)
doc += '; ';
doc += '<a target="_blank" ' +
'href="/doc/#' + loc.clr_file + ';jump=' + loc.clr_heading + '">' +
'href="/doc/#_' + loc.clr_section + '">' +
loc.clr_section + '</a>';
}
doc += '.';
......
......@@ -26,10 +26,6 @@ curl -Ls https://ftp.cs.ru.nl/Clean/builds/linux-x64/clean-base-linux-x64-latest
ln -s ../libs.json
../util/fetch_libs.sh /opt/clean/lib
# Temporary fix for /doc
cd /opt/clean/doc
git clone https://gitlab.science.ru.nl/clean-compiler-and-rts/language-report.git CleanLangRep
# Build common problems index
apt-get install -qq python3 ca-certificates git
git clone https://gitlab.science.ru.nl/cloogle/common-problems /tmp/common-problems
......
@font-face {
/* For the language report on /doc */
font-family: 'courier';
src:
url('fonts/courier.woff2') format('woff2'),
url('fonts/courier.woff') format('woff'),
url('fonts/courier.otf') format('opentype');
font-display: auto;
font-style: normal;
font-weight: 400;
}
body {
color: #222;
font-family: sans-serif;
......@@ -143,11 +155,12 @@ a.more-info {
padding-left: .5em;
}
#sidebar br:last-child, #viewer br:last-child {
#sidebar > p:last-child, #viewer > p:last-child {
margin-top: 8em;
}
#viewer {
box-sizing: border-box;
height: 100%;
overflow: auto;
}
......
<?php
define('CLEANHOME', '/opt/clean');
$dom = new DOMDocument;
$dom->loadHTMLFile(CLEANHOME . '/doc/CleanLangRep/CleanRep.2.2_1.htm');
function readContentsLevel($dom, $level) {
}
function isToc($class) {
return preg_match('/^MsoToc\d$/', $class) === 1;
}
function cleanToc($name) {
$name = preg_replace(['/[\r\x80-\xff]+/', '/\n/'], ['', ' '], $name);
$matches = [];
if (preg_match_all('/^([\d\.]+)?\s*(.+?)\s+[iv\d]+$/', $name, $matches) === 1)
return [
'index' => $matches[1][0],
'title' => preg_replace('/Chapter \d+\s+/', '', $matches[2][0]),
];
else
return null;
}
$toc = [];
foreach ($dom->getElementsByTagName('p') as $p) {
if (isToc($p->getAttribute('class'))) {
$elem = cleanToc($p->textContent);
if ($elem != null) {
$elem['level'] = (int) str_replace('MsoToc', '', $p->getAttribute('class'));
$elem['link'] = str_replace('#', ';jump=', $p->getElementsByTagName('a')[0]->getAttribute('href'));
$toc[] = $elem;
}
}
}
class Toc {
protected $title = '';
protected $link = '';
protected $ref = null;
protected $children = [];
public static function factory($level, $elems) {
$toc = new Toc;
while (count($elems) > 0) {
$elem = array_shift($elems);
if ($elem['level'] <= $level) {
$deeper = [];
while ($elems[0]['level'] > $level)
$deeper[] = array_shift($elems);
$child = Toc::factory($level + 1, $deeper);
$child->title = $elem['title'];
$child->link = $elem['link'];