fn id(x): x # this one is for stuff like this: # prev =& pane&.cursor <- i didn't want to get the reference to the cursor, # i wanted to copy it, then make it accessible only as a reference. # we got a reference to the pane&.cursor value, which caused me to modify the og value. # `own` is to force a copy. # so, finally, it would be: # prev =& pane&.cursor own() fn own(x): x fn fst(Tuple2(l, _)): l fn snd(Tuple2(_, r)): r fn is-just(m Maybe a) -> Bool case m None return False Just(_) return True fn is-none (m Maybe a) case m None return True Just(_) return False fn and-maybe(m Maybe a, fun a -> Maybe b) -> Maybe b case m None return None Just(x) return fun(x) fn fmap-maybe (x Maybe a, fun a -> b) -> Maybe b case x None return None Just(y) return Just(fun(y)) fn maybe (x Maybe a, fun a -> b, default b) -> b: (case x) Just(y): fun(y) _: default fn if-just (x Maybe a, fun a -> ()) -> () case x Just(xx) fun(xx) None pass # I should add a Deallocatable/Freeable class to this and then I don't need to provide a deallocatable function! fn with (res a, free-fun a -> Unit, fun a -> b) -> b ret = fun(res) free-fun(res) return ret fn flip(fun (a, b) -> c) -> (b, a) -> c: fn(l, r): fun(r, l)