module Data.Syntax.Combinator where
import Control.Lens
import Control.Lens.SemiIso
import Data.SemiIsoFunctor
sepBy :: SemiIsoAlternative f => f a -> f () -> f [a]
sepBy v s = sepBy1 v s
/|/ sipure _Empty
sepBy1 :: SemiIsoAlternative f => f a -> f () -> f [a]
sepBy1 v s = _Cons /$/ v /*/ (s */ sepBy1 v s /|/ sipure _Empty)
optional :: SemiIsoAlternative f => f a -> f (Maybe a)
optional f = _Just /$/ f /|/ sipure _Nothing
opt :: SemiIsoAlternative f => f () -> f ()
opt f = f /|/ sipure id
opt_ :: SemiIsoAlternative f => f () -> f ()
opt_ f = semiIso (const (Left "opt_")) Right /$/ f
/|/ sipure id