format txt xs = concatMap f $ lexer xs
    where
        f x | x `elem` ["import","do","let"] = spn "key" x
        f [x] | x `elem` "(){}[]\\=|" = spn "sym" [x]
        f x | x `elem` ["->","::","<-"] = spn "sym" x
        f (x:xs) | x `elem` "\"\'" = spn "str" $ x:xs
        f x = txt x
format txt xs = concatMap f $ lexer xs
    where
        f x | x `elem` ["import","do","let"] = spn "key" x
        f [x] | x `elem` "(){}[]\\=|" = spn "sym" [x]
        f x | x `elem` ["->","::","<-"] = spn "sym" x
        f (x:xs) | x `elem` "\"\'" = spn "str" $ x:xs
        f x = txt x
format txt xs = concatMap f $ lexer xs
    where
        f x | x `elem` ["import","do","let"] = spn "key" x
        f [x] | x `elem` "(){}[]\\=|" = spn "sym" [x]
        f x | x `elem` ["->","::","<-"] = spn "sym" x
        f (x:xs) | x `elem` "\"\'" = spn "str" $ x:xs
        f x = txt x