#$ Just some stress test with polymorphic functions. (expects defined Tuple2 type) # ((1, True), ()) # ((420, 1337), True) # True # 420 # 1337 # 123 # True # False fn fst (t) case t Tuple2(l, r) return l fn snd (t) case t Tuple2(l, r) return r fn swap (t) case t Tuple2(l, r) return Tuple2(r, l) fn print-tuple (tup Tuple2 a b) -> Unit <= Str a, Str b case tup Tuple2(l, r) println(l) println(r) return t = Tuple2(Tuple2(Tuple2(1, True), Unit), Tuple2(Tuple2(420, 1337), True)) print-tuple(t) # get dat bool println(snd(fst(fst(t)))) # now, try to reach 420 println(fst(fst(snd(t)))) # hard mode t' = swap(t) println(snd(fst(snd(t)))) # owo what is this fn map-snd (t, f) case t Tuple2(l, r) return Tuple2(l, f(r)) fn map-fst (t, f) case t Tuple2(l, r) return Tuple2(f(l), r) fn const (a) return fn b: a t'' = map-snd(t, const(123)) println(snd(t'')) fn negate (b) case b True return False False return True t''' = map-snd(t, fn (a): map-snd(a, negate)) println(snd(snd(t))) println(snd(snd(t''')))