type5 is much more first principles based, so we get a lot
of weird quirks removed:
- FromLiteral no longer needs to understand AST
- Type unifications works more like Haskell
- Function types are just ordinary types, saving a lot of
manual busywork
and more.
Previously, it was hardcoded at 'compile' time (in as much
Python has that). This would make it more difficult to add
stuff to it. Also, in a lot of places we made assumptions
about prelude instead of checking properly.
By default, we add a lot of build in functions that may
never get called.
This commit adds a simple reachability graph algorithm
to remove functions that can't be called from outside.
Also, unmarks a lot of functions as being exported. It
was the default to export - now it's the default to not
export.
Also, some general cleanup to the wasm statement calls.
Now both dynamic and static arrays can be fully fold'ed.
Also adds support for type classes that have a function
argument.
Also, various usability improvements to WasmGenerator.
Also, integration tests now don't dump their stuff without
VERBOSE=1, this speeds up the tests suite by a factor of 9.
Also, tests can now set with_traces to add a number of
tracing functions for help debugging your code.
This also removes the InternalPassAsPointer experiment.
This also fixes that u8 values were stores as 32 bits
in structs and tuples (but not dynamic arrays since that
is special cased as bytes).
Also, fixes allocation issue wi th dynamic arrays, it
would allocate quadratic amount of memory.
bytes continues to be the preferred name for u8[...].
Also, putting bytes values into the VM and taking them
out still uses Python bytes values.
This also lets used use the len function on them, for
whatever that's worth.
Foldable take a TypeConstructor. The first argument must be a
NatNum.
The FunctionSignatureRouter wasn't completely on point, instead
this commit adds an TypeClassArgsRouter lookup router. This
makes sense since the only available arguments we have to find
a router is the list of type class arguments.
Before this commit, finding the implementation for a type
class method was done with a simple lookup table.
This commit adds a router based on function signature.
This also paves the way for adding type constructor
arguments in function signatures.
And it removes quite a few references to the prelude out
of the compiler.
Also adds a bunch of helper methods to render signatures
as strings.
By annotating types with the constructor application
that was used to create them.
Later on we can use the router to replace compiler's
INSTANCES or for user defined types.
A lot of isinstance checks no longer did anything, since
the referred to variable was always a type.
In some places, we used it to check if a type was internal,
it's unclear if we will need to rebuild those checks in
the future.
Before, a type class was a property of a type.
But that doesn't make any sense for multi parameter
type classes.
Had to make a hacky way for type classes with
type constructors.
They look a lot like placeholders, but they exist before
the typing system takes place. And there's a (much smaller)
context to deal with.
For now, removes Placeholders in user function definitions
as they were not implemented.
Adds signature to function to try to get them closer to
type class methods. Already seeing some benefit in the
constraint generator.
Stricter zipping for safety.
Also adds the remaining unexposed WebAssembly opcodes as
comments (eqz, clz, ctz, popcnt, copysign).
This also means that BinaryOp.operator is now always
a type class method.
"An arithmetic shift is usually equivalent to
multiplying the number by a positive or a negative
integral power of the radix." -- Federal Standard 1037C
"This is the same as multiplying x by 2**y."
"A right shift by n bits is defined as floor division
by pow(2,n). A left shift by n bits is defined as
multiplication with pow(2,n)."