20 Commits

Author SHA1 Message Date
Johan B.W. de Vries
f6b4f7c20a First attempts 2025-07-12 17:28:52 +02:00
Johan B.W. de Vries
74a0d700f3 Notes 2025-07-12 11:31:05 +02:00
Johan B.W. de Vries
38294497cb Moves the prelude to runtime
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.
2025-05-29 16:43:37 +02:00
Johan B.W. de Vries
46b06dbcf1 Cleanup: TYPE_INFO_MAP
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.
2025-05-19 21:04:13 +02:00
Johan B.W. de Vries
83186cce78 Reworks bytes into dynamic array
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.
2025-05-18 15:37:13 +02:00
Johan B.W. de Vries
a72bd60de2 Adds functions as passable values 2025-05-17 19:43:52 +02:00
Johan B.W. de Vries
b5f0fda133 Implements sum for Foldable types
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.
2025-05-12 18:36:37 +02:00
Johan B.W. de Vries
6c627bca01 Reworks function lookup
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.
2025-05-10 19:42:17 +02:00
Johan B.W. de Vries
f8d107f4fa Replaces did_construct with a proper router
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.
2025-05-10 16:49:10 +02:00
Johan B.W. de Vries
a2e1dfd799 Reworks type class instantiation
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.
2025-04-27 17:45:13 +02:00
Johan B.W. de Vries
faaf7912b1 Various cleanup to type system
- Make struct into a type constuctor
- Rework placeholders
- Got rid of 'PrimitiveType' as a concept
- Moved out the prelude to its own folder
2025-04-21 16:49:04 +02:00
Johan B.W. de Vries
234bfaa8df Changes AppliedType to TypeConstructor
First to be more in line with how the literature
treats these types. But also to make them workable with
type classes.
2025-04-21 11:14:30 +02:00
Johan B.W. de Vries
20c507a9ec Adds the Bits type class
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.
2025-04-09 15:40:20 +02:00
Johan B.W. de Vries
94c8f9388c Implements the Ord type class 2025-04-09 12:44:32 +02:00
Johan B.W. de Vries
7544055a94 Split Num into NatNum and IntNum
This is because Haskell defines negate, abs and signum
for Num, but they don't work with our unsigned number
types. (abs would be a noop.) Haskell has Word32 / Word64,
but there negate doesn't make much sense to me.

Implemented neg and abs.

Implemented a type class inheritance check.

Removed Integral from u8 and i8 since it wasn't implemented.
2025-04-06 16:12:36 +02:00
Johan B.W. de Vries
74ab3b47fd Adds Floating type class with sqrt as method 2025-04-06 14:02:45 +02:00
Johan B.W. de Vries
be28450658 Converted fractional, fixed integral 2025-04-06 12:58:40 +02:00
Johan B.W. de Vries
4001b086db Cleanup, got rid of OPERATOR_MAP 2025-04-06 12:58:40 +02:00
Johan B.W. de Vries
ffd11c4f72 Started on a type class system 2025-04-06 12:58:40 +02:00
Johan B.W. de Vries
205897101f Adds a typing system to Phasm 2023-01-07 16:24:50 +01:00