This small Haskell project demonstrates how to validate a string of parentheses using monadic folding (foldM
) in polymorphic monads (Maybe
and Either
). It showcases how to use custom MonadFail
instances, pattern matching, and safe error handling in idiomatic Haskell.
stack run
You should see output like:
Running validateBrackets ...
Right "Success"
Just "Success"
Left "Unbalanced parens"