The Haskell-based toolkit for LukCal language.
./app
- Defines the executablelukcal
./src
- Defines the library/backend forlukcal
./src/CLI
- Defines the CLI interface and handling./src/Language
- Defines the LukCal language tooling
$ stack run -- --help
The lukcal program
lukcal [COMMAND] ... [OPTIONS]
Common flags:
-c --checktypes=ITEM
-i --infertypes=ITEM
-? --help Display help message
-V --version Print version information
lukcal exec [OPTIONS]
-e --eval=ITEM Expression to evaluate
lukcal file [OPTIONS]
-e --eval=FILE File to evaluate
Expression evaluation is based on simple evaluation logic, defined in
./src/Language/Evaluator.hs
$ stack run -- exec --eval "+ 1 (+ 1 2)"
"Right (NumberResult 4)"
$ stack run -- exec --eval "+ cup cake"
"Right (TextResult \"cupcake\")"
$ stack run -- exec --eval "+ 1 cake"
"Left \"Unsupported operator: +, for inputs: Right (NumberResult 1), and Right (TextResult \\\"cake\\\")\""
Type inference is based on simple inference logic, defined in
./src/Language/TypeChecker.hs
$ stack run -- exec --infer "+ 1 (+ 1 2)"
"Just (STypeHint \"Number\")"
$ stack run -- exec --infer "+ cup cake"
"Just (STypeHint \"Text\")"
$ stack run -- exec --infer "+ 1 cake"
"Nothing"
Type inference is based on naive checking logic on top of type-annotated trees, defined in
./src/Language/TypeChecker.hs
$ stack run -- exec --check "+ 1 (+ 1 2)"
"Right (Just (STypeHint \"Number\"),\"Inferred type is: Just (STypeHint \\\"Number\\\")\")"
$ stack run -- exec --check "+ cup cake"
"Right (Just (STypeHint \"Text\"),\"Inferred type is: Just (STypeHint \\\"Text\\\")\")"
$ stack run -- exec --check "+ 1 cake"
"Left (Nothing,\"Inferred type is: Nothing, specified: Nothing\")"
$ stack run -- exec --check "~~ Number + 1 (+ 1 2)"
"Right (Just (STypeHint \"Number\"),\"Inferred type is: Just (STypeHint \\\"Number\\\"), specified: Just (STypeHint \\\"Number\\\")\")"
$ stack run -- exec --check "~~ Text + 1 (+ 1 2)"
"Left (Nothing,\"Inferred type is: Just (STypeHint \\\"Number\\\"), specified: Just (STypeHint \\\"Text\\\")\")"
After this, all examples in section above can replace
stack run --
withlukcal-cli
$ lukcal-cli exec --eval "+ cup cake"
"Right (TextResult \"cupcake\")"
$ lukcal-cli exec --infer "+ 1 (+ 1 2)"
"Just (STypeHint \"Number\")"
$ lukcal-cli exec --check "~~ Text + 1 cake"
"Left (Nothing,\"Inferred type is: Nothing, specified: Just (STypeHint \\\"Text\\\")\")"