macro ( ('let x y) )
( (λ x . ()) y );
macro ('match t ps) (tail(
(let (uuid term) (maybe-deref t))
(match-pats( (uuid term) ps (fail 'PatternMatchFailure_s) ))
));
macro ('match-pats( term () remainder )) (
remainder
);
macro ('match-pats( term (ps (lhs rhs)) remainder )) (
(match-pats( term ps
(if (match-pats-arm( term lhs )) rhs remainder)
))
);
macro ('match-pats-arm( term (:Variable: v) )) (
(tail( (let v term) (branchtrue()) ))
);
macro ('match-pats-arm( term (:Literal: l) )) (
(tail( (let (uuid v) term) (==( (uuid v) l )) ))
);
macro ('match-pats-arm( term (:Tag: l lt) )) (
(tail( (let (uuid v) term) (==( (.0( (uuid v) )) l )) ))
);
macro ('match-pats-arm( term ((:Tag: l lt) ( x1 )) )) (
(tail(
(let (uuid v) term)
(let (uuid m) 0_u8)
(if (==( (.0( (uuid v) )) l ))
(if (match-pats-arm( (maybe-deref(.1( (as (uuid v) lt) ))) x1 ))
(set (uuid m) 1_u8)
()
)
()
)
(==( (uuid m) 1_u8 ))
))
);
macro ('match-pats-arm( term ((:Tag: l lt) ( x2 x1 )) )) (
(tail(
(let (uuid v) term)
(let (uuid m) 0_u8)
(if (==( (.0( (uuid v) )) l ))
(if (match-pats-arm( (maybe-deref(.1( (as (uuid v) lt) ))) x1 ))
(if (match-pats-arm( (maybe-deref(.2( (as (uuid v) lt) ))) x2 ))
(set (uuid m) 1_u8)
()
)
()
)
()
)
(==( (uuid m) 1_u8 ))
))
);