foo : List(N) + Bool -> N foo x = {? n when x is left (n :: _), 0 if x is left [], 1 when x is right True, 2 when x is right False ?}