Daily Note - 2025-03-22
Hey, I'm Hanno! These are my daily notes on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!
Let's take a closer look at the
automatic application of functions to variant
types. If we have a fallible function f: A
-> variant { B, Error }
, and we follow it
up with another function g: B -> C
. The
compiler could automatically wrap g
in
another function it creates, g': variant { B,
Error } -> variant { C, Error }
.
If the variant happens to be B
, this new
function g'
would just apply g
and wrap its result in another variant. If the variant
is Error
, g'
would return that
unchanged. This is basically railway-oriented programming, but built into the
language.
This whole concept is not new. I believe what I did
above, turning g
into g'
would be called "lifting". But all the examples I could find in the
wild either do this explicitly, or as part of a special
notation. Maybe I'm missing something. But at least
right now, I can't think of a reason why automatic
lifting wouldn't work.