notes for general stuff like std. i’ll try to put stuff I changed/added to remember why i did that. hopefully i’ll remember asaaaa aasadkasjd
writeup.md is for more typechecking logic and stuff.
changed ListLike’s from-listlike so that it takes in a Ptr to Array. not sure why it wasn’t like this before. now Slice has a ListLike instance!
thinking about FromString. StrView is a reasonable default (unlike Haskell, which needs the fromString, because the default String is bad)
(FromChar can eval to StrView and ConstStr too, so FromString would be natural…. but stuff like ['a', 'miau'] breaks and we then would need default resolution rules…)
added string matching, but only for a type that has both FromString and Eq. uses FromString + Eq instances. so we create the same type as the compared string.
streq() to compare any type that has a Str instance?eq-strview() function maybe? (with a default impl.)added polymorphic number matching for case expressions. uses FromIntegral, Eq and optionally Negation if the number is negative.
just reordered stuff in the modules. Created Prim.kkc which contains basically everything in teh correct order. and later modules reexport it. this should create a nice interface for the user (all Str functions under Str), but it’s super annoying.
or-fail. I’ve moved Failable to Prim and now Char can depend on Array… but it does not have to use it yet, since all functions that might use it in the future (unscalarize) are also in Prim…(copied from the comment - i made the string literals in case statements behave like string literals in the language in general):
this instance was added due to string matching in case statements.
i just realized, that maybe we should do the same thing as with literals?
for now, no. see this:
case c
'a': ...
'b': ...
'': ... # <- empty string cannot be a char. yet, all the cases of this type added a FromChar instance, yet the last one forces FromString.
the downside of this? FromString Char should not exist.
it's possible to construct an invalid char, which will panic runtime (exactly the situation FromChar *sort-of* prevents (ASCII chars have the same problem wrt normal Chars, but whatever.)).
I'll leave it for now, but maybe we should match the behavior of the rest of the compiler.
# inst FromString Char
# from-string (ptr, count): from-charlike(ptr, count)
added deconstruction with the let .... = <expr>. I know it’s lazy. I don’t want to keep it in the language, but the parsing code, even though it’s not ambiguous, is pretty complitcated to write, which I don’t feel like doing now (compared to the benefits).