Better Typing #22
arendsee
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The main changes since the 0.43.0 release are the addition of typeclasses, basic value checking, and explicit function type parameters.
Typeclasses cannot yet be used as explicit constraints in function signatures, so their value in modeling data is limited. But at least we can now have one
add
function name for both integers and doubles. Also, packing and unpacking has been re-implemented using a newPackable
type class. This means we no longer need the specialpack
andunpack
descriptors in signatures.Value checking is important since
morloc
can define multiple definitions for one term. For example, it is legal to write:This would not redefine
x
, as is done in many languages, but would rather associate both values with the variable name and attempt to disambiguate them later (which in the past implementation would have arbitrarily picked the last one). Now I have a very rudimentary value checker that will check for contradictions between primitives. It cannot descend past a source function call. In the future, I will need to extend the value checker to compare different sourced functions. This will likely have an LLM solution.Explicit function parameters are now added to function signatures to provide an order for the generic type variables. For example:
This deviates from Haskell syntax, but clarifies the relationship between the
morloc
type signature and type signatures in other languages, such as the C++ prototype:This also allows us to conveniently refer to functions as parameterized types, e.g.:
snd Int Bool
. Possibly such type functions could be used in signatures as well. I will explore this later.This discussion was created from the release Better Typing.
Beta Was this translation helpful? Give feedback.
All reactions