mirror of
https://github.com/pavelchristof/syntax.git
synced 2024-10-03 21:47:21 +03:00
Added some combinators.
This commit is contained in:
parent
558eb65a75
commit
156a969caa
25
Data/Syntax/Combinator.hs
Normal file
25
Data/Syntax/Combinator.hs
Normal file
@ -0,0 +1,25 @@
|
||||
{- |
|
||||
Module : Data.Syntax.Combinator
|
||||
Description : Combinators that work with any sequence type.
|
||||
Copyright : (c) Paweł Nowak
|
||||
License : MIT
|
||||
|
||||
Maintainer : Paweł Nowak <pawel834@gmail.com>
|
||||
Stability : experimental
|
||||
|
||||
Combinators that work with any sequence type.
|
||||
-}
|
||||
module Data.Syntax.Combinator where
|
||||
|
||||
import Control.Lens.Cons
|
||||
import Control.Lens.Empty
|
||||
import Data.SemiIsoFunctor
|
||||
|
||||
-- | Zero or more occurences of v separated by s.
|
||||
sepBy :: SemiIsoAlternative f => f a -> f () -> f [a]
|
||||
sepBy v s = sepBy1 v s
|
||||
/|/ sipure _Empty
|
||||
|
||||
-- | One or more occurences of v separated by s.
|
||||
sepBy1 :: SemiIsoAlternative f => f a -> f () -> f [a]
|
||||
sepBy1 v s = _Cons /$/ v /*/ (s */ sepBy1 v s /|/ sipure _Empty)
|
@ -1,5 +1,5 @@
|
||||
name: syntax
|
||||
version: 0.1.0.0
|
||||
version: 0.1.1.0
|
||||
synopsis: Abstract syntax descriptions for parsing and pretty-printing.
|
||||
description: Write single syntax description, get both parser and pretty-printer.
|
||||
.
|
||||
@ -24,5 +24,6 @@ source-repository head
|
||||
library
|
||||
exposed-modules: Data.Syntax
|
||||
Data.Syntax.Char
|
||||
Data.Syntax.Combinator
|
||||
build-depends: base >= 4 && < 5, mono-traversable, lens, semi-iso
|
||||
default-language: Haskell2010
|
||||
|
Loading…
Reference in New Issue
Block a user