Commit f074af39 authored by Mart Lubbers's avatar Mart Lubbers
Browse files

Add functional dependencies as syntax builtin

parent 68e31e13
...@@ -23,6 +23,7 @@ builtin_syntax = ...@@ -23,6 +23,7 @@ builtin_syntax =
, bs_exists , bs_exists
, bs_forall , bs_forall
, bs_foreign , bs_foreign
, bs_funcdep
, bs_generic , bs_generic
, bs_import , bs_import
, bs_infix , bs_infix
...@@ -179,6 +180,26 @@ bs_foreign = ...@@ -179,6 +180,26 @@ bs_foreign =
] ]
} }
bs_funcdep =
{ syntax_title = "functional dependency"
, syntax_patterns = ["~"]
, syntax_code =
[ "class c a ~b"
]
, syntax_description =
"Lets you point the type checker to the type that determines the other types.\n\n" +
"Most often this is the return type (undocumented and experimental)"
, syntax_doc_locations = []
, syntax_examples = map (EX "Function")
[ "class plus a b c :: a b -> c"
, "instance plus Int Int Int where plus x y = x + y"
, "Start = plus 1 (plus 1 1) // Results in: internal overloading of \"plus\" could not be solved because the compiler doesn't know the type of the intermediate result."
, "class plus a b ~c :: a b -> c"
, "instance plus Int Int Int where plus x y = x + y"
, "Start = plus 1 (plus 1 1) // Works! because we told the compiler that c determines the other types."
]
}
bs_generic = bs_generic =
{ syntax_title = "generic function definition" { syntax_title = "generic function definition"
, syntax_patterns = ["generic", "derive", "of", "{|*|}"] // This * matches everything, which is intentional , syntax_patterns = ["generic", "derive", "of", "{|*|}"] // This * matches everything, which is intentional
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment