fun sflat ls = foldr (fn (Solution x, _) => Solution x | (Nothing,v) => v) Nothing ls; fun smap _ Nothing = Nothing | smap f (Solution x) = Solution (f x)