parse :: FilePattern -> [Pat]
parse = f False True . lexer
    where
        -- str = I have ever seen a Str go past (equivalent to "can I be satisfied by no paths")
        -- slash = I am either at the start, or my previous character was Slash
        f str slash = \case
            [] -> [Lit "" | slash]
            Str "**":xs -> Skip : f True False xs
            Str x:xs -> parseLit x : f True False xs
            SlashSlash:Slash:xs | not str -> Skip1 : f str True xs
            SlashSlash:xs -> Skip : f str False xs
            Slash:xs -> [Lit "" | not str] ++ f str True xs
parse :: FilePattern -> [Pat]
parse = f False True . lexer
    where
        -- str = I have ever seen a Str go past (equivalent to "can I be satisfied by no paths")
        -- slash = I am either at the start, or my previous character was Slash
        f str slash = \case
            [] -> [Lit "" | slash]
            Str "**":xs -> Skip : f True False xs
            Str x:xs -> parseLit x : f True False xs
            SlashSlash:Slash:xs | not str -> Skip1 : f str True xs
            SlashSlash:xs -> Skip : f str False xs
            Slash:xs -> [Lit "" | not str] ++ f str True xs
parse = f False True . lexer
    where
        -- str = I have ever seen a Str go past (equivalent to "can I be satisfied by no paths")
        -- slash = I am either at the start, or my previous character was Slash
        f str slash = \case
            [] -> [Lit "" | slash]
            Str "**":xs -> Skip : f True False xs
            Str x:xs -> parseLit x : f True False xs
            SlashSlash:Slash:xs | not str -> Skip1 : f str True xs
            SlashSlash:xs -> Skip : f str False xs
            Slash:xs -> [Lit "" | not str] ++ f str True xs