~jojo/Carth

ref: 749208029494a7c48ce04444a513424f4b998416 Carth/src d---------
Add class Select

Pass some params implicitly when doing selections
Update stackage release & use default-extensions in cabal file

Also, fix some minor breakages caused by ghc update, fix the
literate.org example, fix some new warnings, and get rid of the need
for a bunch of Data implementations by using basic parsing functions
in SystemSpec.hs.
remove no longer applicable TODOs
Fix bug when getting free vars of non-rec Let in Monomorphic

Was using fvLet for both recursive and nonrecursive bindings, but for
nonrecursive let:s, the LHS should not be subtracted from the RHS FV set.
std-rs: use native-tls inst of rustls. Better for gemini

Rustls is too strict for non-web, self signed, TOFU use, so use rustls
instead. Right now, TLS does no verification, but we'll fix this.
Less desugaring in Parse (do in Infer instead), more concrete Parsed.

Step towards improving error messages. Among others, the function-related ones can
end up misleading due to bad SrcPos:s given to nodes generated from desugaring.
Add patterns & declaration of literals in macros

Example of a do-notation-like macro using the new features:

    (defmacro do (<-)
      (case (do-bind ma) ma)
      (case (do-bind (<- a ma) mbs ...)
            (do-bind (fun (a) (do do-bind mbs ...)) ma))
      (case (do-bind ma mbs ...)
            (do-bind (fun (_) (do do-bind mbs ...)) ma)))

which can be used like

    (do list/bind
        (<- i (list 1 2 3))
        (<- j (list 1 2 3))
        (if (< i j)
            (list/singleton [i j])
          list/nil))
Codegen: Don't put every var on stack. Keep small things in regs

Some things, like integers, seldom need to be on the stack, so
`alloca`ing space for them and needing to load them when it's time to
e.g. add them together is wasteful. Instead, use `passByRef` as a
heuristic to not needlessly put values on the stack that will probably
never need to be used as such. On the other hand, it's still good to
keep larger structs on the stack. As the LLVM docs say, load/store on
individual struct members is to be prefered over
insertvalue/extractvalue due to performance reasons.
Codegen: Do more at Val & ptr level everywhere. getelemementptr etc.

The website said to "avoid loads and stores of large aggregate type"
to improve performance. This seems like solid advice, so this commit
changes a bunch of different stuff in the codegen to keep structs in
pointers for as long as possible and use getelementptr instead of
extractvalue/insertvalue. Particularly in the pattern matching stuff,
change the selection stuff to operate on Val instead of operand, using
new convenience functions like genIndexStruct which does extractvalue
if the Val is a local, and getelementptr if it's a stack var.

Performance improvement is not obviously noticable for my small
programs, but it seems less code is generated overall. .dbg.ll of
Fizzbuzz decreased from like 1700 to 1500 lines or something. That's
at least a 10% improvement.

https://llvm.org/docs/Frontend/PerformanceTips.html#avoid-loads-and-stores-of-large-aggregate-type
Use private linkage for internal items

Haven't noticed much difference, but should in theory allow the
compiler to optimize more, like inlining and stuff.
Explicitly mark extern calls with notail

Not sure if it actually makes a difference, but it probably doesn't
hurt to be explicit.
Include target triple in llvm module

Should allow for more specific optimizations
Include macro expansion trace in SrcPos. Better err msgs!

    POS1: Error:
      CODE
    MESSAGE

    POS2: Note:
      CODE
    In expansion of macro.
More human readable names for implicit type vars

Before: #2760, #2454
After: •ca44, •zb7
std: rename mod Memo back to Lazy & make Lazy thread safe

The evaluation and store of the computation of a Lazy is now
considered a critical section and locked behind a Mutex, which means
we will be able to share the same lazy value between threads, and they
will all be able to read it, and it will only be evaluated once.
Add macro rules and ellipsis (...) macro operator
Fix undefined macros due to imports not being imported in order

Basically, changed lexModules (now lexModule) to use depth first
search instead of breadth first search. Maybe worse performance, but
important currently where order of macro defs matters.
Lex: Don't revisit files bc of non-absolute file paths

Say we compile std.carth and it imports itself. The first time, the
path will be "std.carth", but the second it will be
"$CARTH_MODULE_PATH/std.carth", and they will not be equal in the
Set. Use makeAbsolute to fix this.
Add primitive, single pattern macros

E.g. `(defmacro (plus a b) (+ a b))`
Infer: Minor refactor
Next