packages feed

boomerang 1.3.4 → 1.3.4.1

raw patch · 9 files changed

+158/−181 lines, 9 filesnew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Text.Boomerang.Prim: Boomerang :: Parser e tok (a -> b) -> (b -> [(tok -> tok, a)]) -> Boomerang e tok a b
- Text.Boomerang.Prim: data Boomerang e tok a b
- Text.Boomerang.Prim: instance Category (Boomerang e tok)
- Text.Boomerang.Prim: instance Monoid (Boomerang e tok a b)
- Text.Boomerang.Prim: type PrinterParser = Boomerang
- Text.Boomerang.String: instance a ~ b => IsString (Boomerang StringError String a b)
- Text.Boomerang.String: type StringBoomerang = Boomerang StringError String
- Text.Boomerang.Strings: instance a ~ b => IsString (Boomerang StringsError [String] a b)
- Text.Boomerang.TH: makeBoomerangs :: Name -> Q [Dec]
- Text.Boomerang.Texts: instance a ~ b => IsString (Boomerang TextsError [Text] a b)
+ Text.Boomerang.Prim: PrinterParser :: Parser e tok (a -> b) -> (b -> [(tok -> tok, a)]) -> PrinterParser e tok a b
+ Text.Boomerang.Prim: data PrinterParser e tok a b
+ Text.Boomerang.Prim: instance Category (PrinterParser e tok)
+ Text.Boomerang.Prim: instance Monoid (PrinterParser e tok a b)
+ Text.Boomerang.String: instance a ~ b => IsString (PrinterParser StringError String a b)
+ Text.Boomerang.Strings: instance a ~ b => IsString (PrinterParser StringsError [String] a b)
+ Text.Boomerang.Texts: instance a ~ b => IsString (PrinterParser TextsError [Text] a b)
- Text.Boomerang.Combinators: chainl :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r
+ Text.Boomerang.Combinators: chainl :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r r
- Text.Boomerang.Combinators: chainl1 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- (a :- r)) (a :- r) -> Boomerang e tok r (a :- r)
+ Text.Boomerang.Combinators: chainl1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- (a :- r)) (a :- r) -> PrinterParser e tok r (a :- r)
- Text.Boomerang.Combinators: chainr :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r
+ Text.Boomerang.Combinators: chainr :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r r
- Text.Boomerang.Combinators: chainr1 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- (a :- r)) (a :- r) -> Boomerang e tok r (a :- r)
+ Text.Boomerang.Combinators: chainr1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- (a :- r)) (a :- r) -> PrinterParser e tok r (a :- r)
- Text.Boomerang.Combinators: duck :: Boomerang e tok r1 r2 -> Boomerang e tok (h :- r1) (h :- r2)
+ Text.Boomerang.Combinators: duck :: PrinterParser e tok r1 r2 -> PrinterParser e tok (h :- r1) (h :- r2)
- Text.Boomerang.Combinators: duck1 :: Boomerang e tok r1 (a :- r2) -> Boomerang e tok (h :- r1) (a :- (h :- r2))
+ Text.Boomerang.Combinators: duck1 :: PrinterParser e tok r1 (a :- r2) -> PrinterParser e tok (h :- r1) (a :- (h :- r2))
- Text.Boomerang.Combinators: manyl :: Boomerang e tok r r -> Boomerang e tok r r
+ Text.Boomerang.Combinators: manyl :: PrinterParser e tok r r -> PrinterParser e tok r r
- Text.Boomerang.Combinators: manyr :: Boomerang e tok r r -> Boomerang e tok r r
+ Text.Boomerang.Combinators: manyr :: PrinterParser e tok r r -> PrinterParser e tok r r
- Text.Boomerang.Combinators: opt :: Boomerang e tok r r -> Boomerang e tok r r
+ Text.Boomerang.Combinators: opt :: PrinterParser e tok r r -> PrinterParser e tok r r
- Text.Boomerang.Combinators: printAs :: Boomerang e [tok] a b -> tok -> Boomerang e [tok] a b
+ Text.Boomerang.Combinators: printAs :: PrinterParser e [tok] a b -> tok -> PrinterParser e [tok] a b
- Text.Boomerang.Combinators: push :: (Eq a, Error e) => a -> Boomerang e tok r (a :- r)
+ Text.Boomerang.Combinators: push :: (Eq a, Error e) => a -> PrinterParser e tok r (a :- r)
- Text.Boomerang.Combinators: rBool :: Boomerang e tok a r -> Boomerang e tok a r -> Boomerang e tok a (Bool :- r)
+ Text.Boomerang.Combinators: rBool :: PrinterParser e tok a r -> PrinterParser e tok a r -> PrinterParser e tok a (Bool :- r)
- Text.Boomerang.Combinators: rCons :: Boomerang e tok (a :- ([a] :- r)) ([a] :- r)
+ Text.Boomerang.Combinators: rCons :: PrinterParser e tok (a :- ([a] :- r)) ([a] :- r)
- Text.Boomerang.Combinators: rEither :: Boomerang e tok r (a :- r) -> Boomerang e tok r (b :- r) -> Boomerang e tok r (Either a b :- r)
+ Text.Boomerang.Combinators: rEither :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (b :- r) -> PrinterParser e tok r (Either a b :- r)
- Text.Boomerang.Combinators: rFalse :: Boomerang e tok r (:- Bool r)
+ Text.Boomerang.Combinators: rFalse :: PrinterParser e tok r (:- Bool r)
- Text.Boomerang.Combinators: rFilter :: (a -> Bool) -> Boomerang e tok () (a :- ()) -> Boomerang e tok r (a :- r)
+ Text.Boomerang.Combinators: rFilter :: (a -> Bool) -> PrinterParser e tok () (a :- ()) -> PrinterParser e tok r (a :- r)
- Text.Boomerang.Combinators: rJust :: Boomerang e tok (:- a_a2GT r) (:- (Maybe a_a2GT) r)
+ Text.Boomerang.Combinators: rJust :: PrinterParser e tok (:- a_a2GT r) (:- (Maybe a_a2GT) r)
- Text.Boomerang.Combinators: rLeft :: Boomerang e tok (:- a_a59t r) (:- (Either a_a59t b_a59u) r)
+ Text.Boomerang.Combinators: rLeft :: PrinterParser e tok (:- a_a59s r) (:- (Either a_a59s b_a59t) r)
- Text.Boomerang.Combinators: rList :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r)
+ Text.Boomerang.Combinators: rList :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r)
- Text.Boomerang.Combinators: rList1 :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r)
+ Text.Boomerang.Combinators: rList1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r)
- Text.Boomerang.Combinators: rListSep :: Boomerang e tok r (a :- r) -> Boomerang e tok ([a] :- r) ([a] :- r) -> Boomerang e tok r ([a] :- r)
+ Text.Boomerang.Combinators: rListSep :: PrinterParser e tok r (a :- r) -> PrinterParser e tok ([a] :- r) ([a] :- r) -> PrinterParser e tok r ([a] :- r)
- Text.Boomerang.Combinators: rMaybe :: Boomerang e tok r (a :- r) -> Boomerang e tok r (Maybe a :- r)
+ Text.Boomerang.Combinators: rMaybe :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (Maybe a :- r)
- Text.Boomerang.Combinators: rNil :: Boomerang e tok r ([a] :- r)
+ Text.Boomerang.Combinators: rNil :: PrinterParser e tok r ([a] :- r)
- Text.Boomerang.Combinators: rNothing :: Boomerang e tok r (:- (Maybe a_a2GT) r)
+ Text.Boomerang.Combinators: rNothing :: PrinterParser e tok r (:- (Maybe a_a2GT) r)
- Text.Boomerang.Combinators: rPair :: Boomerang e tok (f :- (s :- r)) ((f, s) :- r)
+ Text.Boomerang.Combinators: rPair :: PrinterParser e tok (f :- (s :- r)) ((f, s) :- r)
- Text.Boomerang.Combinators: rRight :: Boomerang e tok (:- b_a59u r) (:- (Either a_a59t b_a59u) r)
+ Text.Boomerang.Combinators: rRight :: PrinterParser e tok (:- b_a59t r) (:- (Either a_a59s b_a59t) r)
- Text.Boomerang.Combinators: rTrue :: Boomerang e tok r (:- Bool r)
+ Text.Boomerang.Combinators: rTrue :: PrinterParser e tok r (:- Bool r)
- Text.Boomerang.Combinators: rUnit :: Boomerang e tok r (() :- r)
+ Text.Boomerang.Combinators: rUnit :: PrinterParser e tok r (() :- r)
- Text.Boomerang.Combinators: somel :: Boomerang e tok r r -> Boomerang e tok r r
+ Text.Boomerang.Combinators: somel :: PrinterParser e tok r r -> PrinterParser e tok r r
- Text.Boomerang.Combinators: somer :: Boomerang e tok r r -> Boomerang e tok r r
+ Text.Boomerang.Combinators: somer :: PrinterParser e tok r r -> PrinterParser e tok r r
- Text.Boomerang.Error: (<?>) :: Boomerang (ParserError p) tok a b -> String -> Boomerang (ParserError p) tok a b
+ Text.Boomerang.Error: (<?>) :: PrinterParser (ParserError p) tok a b -> String -> PrinterParser (ParserError p) tok a b
- Text.Boomerang.Prim: (.~) :: Boomerang e tok a b -> Boomerang e tok b c -> Boomerang e tok a c
+ Text.Boomerang.Prim: (.~) :: PrinterParser e tok a b -> PrinterParser e tok b c -> PrinterParser e tok a c
- Text.Boomerang.Prim: parse :: InitialPosition e => Boomerang e tok () a -> tok -> [Either e (a, tok)]
+ Text.Boomerang.Prim: parse :: InitialPosition e => PrinterParser e tok () a -> tok -> [Either e (a, tok)]
- Text.Boomerang.Prim: parse1 :: (ErrorPosition e, InitialPosition e, Show e, Ord (Pos e)) => (tok -> Bool) -> Boomerang e tok () (a :- ()) -> tok -> Either [e] a
+ Text.Boomerang.Prim: parse1 :: (ErrorPosition e, InitialPosition e, Show e, Ord (Pos e)) => (tok -> Bool) -> PrinterParser e tok () (a :- ()) -> tok -> Either [e] a
- Text.Boomerang.Prim: prs :: Boomerang e tok a b -> Parser e tok (a -> b)
+ Text.Boomerang.Prim: prs :: PrinterParser e tok a b -> Parser e tok (a -> b)
- Text.Boomerang.Prim: ser :: Boomerang e tok a b -> b -> [(tok -> tok, a)]
+ Text.Boomerang.Prim: ser :: PrinterParser e tok a b -> b -> [(tok -> tok, a)]
- Text.Boomerang.Prim: unparse :: tok -> Boomerang e tok () url -> url -> [tok]
+ Text.Boomerang.Prim: unparse :: tok -> PrinterParser e tok () url -> url -> [tok]
- Text.Boomerang.Prim: unparse1 :: tok -> Boomerang e tok () (a :- ()) -> a -> Maybe tok
+ Text.Boomerang.Prim: unparse1 :: tok -> PrinterParser e tok () (a :- ()) -> a -> Maybe tok
- Text.Boomerang.Prim: val :: Parser e tok a -> (a -> [tok -> tok]) -> Boomerang e tok r (a :- r)
+ Text.Boomerang.Prim: val :: Parser e tok a -> (a -> [tok -> tok]) -> PrinterParser e tok r (a :- r)
- Text.Boomerang.Prim: xmap :: (a -> b) -> (b -> Maybe a) -> Boomerang e tok r a -> Boomerang e tok r b
+ Text.Boomerang.Prim: xmap :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok r a -> PrinterParser e tok r b
- Text.Boomerang.Prim: xmaph :: (a -> b) -> (b -> Maybe a) -> Boomerang e tok i (a :- o) -> Boomerang e tok i (b :- o)
+ Text.Boomerang.Prim: xmaph :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok i (a :- o) -> PrinterParser e tok i (b :- o)
- Text.Boomerang.Prim: xpure :: (a -> b) -> (b -> Maybe a) -> Boomerang e tok a b
+ Text.Boomerang.Prim: xpure :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok a b
- Text.Boomerang.String: alpha :: StringBoomerang r (Char :- r)
+ Text.Boomerang.String: alpha :: StringPrinterParser r (Char :- r)
- Text.Boomerang.String: anyChar :: StringBoomerang r (Char :- r)
+ Text.Boomerang.String: anyChar :: StringPrinterParser r (Char :- r)
- Text.Boomerang.String: char :: Char -> StringBoomerang r (Char :- r)
+ Text.Boomerang.String: char :: Char -> StringPrinterParser r (Char :- r)
- Text.Boomerang.String: digit :: StringBoomerang r (Char :- r)
+ Text.Boomerang.String: digit :: StringPrinterParser r (Char :- r)
- Text.Boomerang.String: int :: StringBoomerang r (Int :- r)
+ Text.Boomerang.String: int :: StringPrinterParser r (Int :- r)
- Text.Boomerang.String: integer :: StringBoomerang r (Integer :- r)
+ Text.Boomerang.String: integer :: StringPrinterParser r (Integer :- r)
- Text.Boomerang.String: lit :: String -> StringBoomerang r r
+ Text.Boomerang.String: lit :: String -> StringPrinterParser r r
- Text.Boomerang.String: parseString :: StringBoomerang () (r :- ()) -> String -> Either StringError r
+ Text.Boomerang.String: parseString :: StringPrinterParser () (r :- ()) -> String -> Either StringError r
- Text.Boomerang.String: satisfy :: (Char -> Bool) -> StringBoomerang r (Char :- r)
+ Text.Boomerang.String: satisfy :: (Char -> Bool) -> StringPrinterParser r (Char :- r)
- Text.Boomerang.String: space :: StringBoomerang r (Char :- r)
+ Text.Boomerang.String: space :: StringPrinterParser r (Char :- r)
- Text.Boomerang.String: type StringPrinterParser = StringBoomerang
+ Text.Boomerang.String: type StringPrinterParser = PrinterParser StringError String
- Text.Boomerang.String: unparseString :: StringBoomerang () (r :- ()) -> r -> Maybe String
+ Text.Boomerang.String: unparseString :: StringPrinterParser () (r :- ()) -> r -> Maybe String
- Text.Boomerang.Strings: (</>) :: Boomerang StringsError [String] b c -> Boomerang StringsError [String] a b -> Boomerang StringsError [String] a c
+ Text.Boomerang.Strings: (</>) :: PrinterParser StringsError [String] b c -> PrinterParser StringsError [String] a b -> PrinterParser StringsError [String] a c
- Text.Boomerang.Strings: alpha :: Boomerang StringsError [String] r (Char :- r)
+ Text.Boomerang.Strings: alpha :: PrinterParser StringsError [String] r (Char :- r)
- Text.Boomerang.Strings: anyChar :: Boomerang StringsError [String] r (Char :- r)
+ Text.Boomerang.Strings: anyChar :: PrinterParser StringsError [String] r (Char :- r)
- Text.Boomerang.Strings: anyString :: Boomerang StringsError [String] r (String :- r)
+ Text.Boomerang.Strings: anyString :: PrinterParser StringsError [String] r (String :- r)
- Text.Boomerang.Strings: char :: Char -> Boomerang StringsError [String] r (Char :- r)
+ Text.Boomerang.Strings: char :: Char -> PrinterParser StringsError [String] r (Char :- r)
- Text.Boomerang.Strings: digit :: Boomerang StringsError [String] r (Char :- r)
+ Text.Boomerang.Strings: digit :: PrinterParser StringsError [String] r (Char :- r)
- Text.Boomerang.Strings: eos :: Boomerang StringsError [String] r r
+ Text.Boomerang.Strings: eos :: PrinterParser StringsError [String] r r
- Text.Boomerang.Strings: int :: Boomerang StringsError [String] r (Int :- r)
+ Text.Boomerang.Strings: int :: PrinterParser StringsError [String] r (Int :- r)
- Text.Boomerang.Strings: integer :: Boomerang StringsError [String] r (Integer :- r)
+ Text.Boomerang.Strings: integer :: PrinterParser StringsError [String] r (Integer :- r)
- Text.Boomerang.Strings: lit :: String -> Boomerang StringsError [String] r r
+ Text.Boomerang.Strings: lit :: String -> PrinterParser StringsError [String] r r
- Text.Boomerang.Strings: parseStrings :: Boomerang StringsError [String] () (r :- ()) -> [String] -> Either StringsError r
+ Text.Boomerang.Strings: parseStrings :: PrinterParser StringsError [String] () (r :- ()) -> [String] -> Either StringsError r
- Text.Boomerang.Strings: readshow :: (Read a, Show a) => Boomerang StringsError [String] r (a :- r)
+ Text.Boomerang.Strings: readshow :: (Read a, Show a) => PrinterParser StringsError [String] r (a :- r)
- Text.Boomerang.Strings: satisfy :: (Char -> Bool) -> Boomerang StringsError [String] r (Char :- r)
+ Text.Boomerang.Strings: satisfy :: (Char -> Bool) -> PrinterParser StringsError [String] r (Char :- r)
- Text.Boomerang.Strings: satisfyStr :: (String -> Bool) -> Boomerang StringsError [String] r (String :- r)
+ Text.Boomerang.Strings: satisfyStr :: (String -> Bool) -> PrinterParser StringsError [String] r (String :- r)
- Text.Boomerang.Strings: space :: Boomerang StringsError [String] r (Char :- r)
+ Text.Boomerang.Strings: space :: PrinterParser StringsError [String] r (Char :- r)
- Text.Boomerang.Strings: unparseStrings :: Boomerang e [String] () (r :- ()) -> r -> Maybe [String]
+ Text.Boomerang.Strings: unparseStrings :: PrinterParser e [String] () (r :- ()) -> r -> Maybe [String]
- Text.Boomerang.Texts: (</>) :: Boomerang TextsError [Text] b c -> Boomerang TextsError [Text] a b -> Boomerang TextsError [Text] a c
+ Text.Boomerang.Texts: (</>) :: PrinterParser TextsError [Text] b c -> PrinterParser TextsError [Text] a b -> PrinterParser TextsError [Text] a c
- Text.Boomerang.Texts: alpha :: Boomerang TextsError [Text] r (Char :- r)
+ Text.Boomerang.Texts: alpha :: PrinterParser TextsError [Text] r (Char :- r)
- Text.Boomerang.Texts: anyChar :: Boomerang TextsError [Text] r (Char :- r)
+ Text.Boomerang.Texts: anyChar :: PrinterParser TextsError [Text] r (Char :- r)
- Text.Boomerang.Texts: anyText :: Boomerang TextsError [Text] r (Text :- r)
+ Text.Boomerang.Texts: anyText :: PrinterParser TextsError [Text] r (Text :- r)
- Text.Boomerang.Texts: char :: Char -> Boomerang TextsError [Text] r (Char :- r)
+ Text.Boomerang.Texts: char :: Char -> PrinterParser TextsError [Text] r (Char :- r)
- Text.Boomerang.Texts: digit :: Boomerang TextsError [Text] r (Char :- r)
+ Text.Boomerang.Texts: digit :: PrinterParser TextsError [Text] r (Char :- r)
- Text.Boomerang.Texts: digits :: Boomerang TextsError [Text] r (Text :- r)
+ Text.Boomerang.Texts: digits :: PrinterParser TextsError [Text] r (Text :- r)
- Text.Boomerang.Texts: eos :: Boomerang TextsError [Text] r r
+ Text.Boomerang.Texts: eos :: PrinterParser TextsError [Text] r r
- Text.Boomerang.Texts: int :: Boomerang TextsError [Text] r (Int :- r)
+ Text.Boomerang.Texts: int :: PrinterParser TextsError [Text] r (Int :- r)
- Text.Boomerang.Texts: integer :: Boomerang TextsError [Text] r (Integer :- r)
+ Text.Boomerang.Texts: integer :: PrinterParser TextsError [Text] r (Integer :- r)
- Text.Boomerang.Texts: integral :: (Integral a, Show a) => Boomerang TextsError [Text] r (a :- r)
+ Text.Boomerang.Texts: integral :: (Integral a, Show a) => PrinterParser TextsError [Text] r (a :- r)
- Text.Boomerang.Texts: lit :: Text -> Boomerang TextsError [Text] r r
+ Text.Boomerang.Texts: lit :: Text -> PrinterParser TextsError [Text] r r
- Text.Boomerang.Texts: parseTexts :: Boomerang TextsError [Text] () (r :- ()) -> [Text] -> Either TextsError r
+ Text.Boomerang.Texts: parseTexts :: PrinterParser TextsError [Text] () (r :- ()) -> [Text] -> Either TextsError r
- Text.Boomerang.Texts: rEmpty :: Boomerang e [Text] r (Text :- r)
+ Text.Boomerang.Texts: rEmpty :: PrinterParser e [Text] r (Text :- r)
- Text.Boomerang.Texts: rText :: Boomerang e [Text] r (Char :- r) -> Boomerang e [Text] r (Text :- r)
+ Text.Boomerang.Texts: rText :: PrinterParser e [Text] r (Char :- r) -> PrinterParser e [Text] r (Text :- r)
- Text.Boomerang.Texts: rText1 :: Boomerang e [Text] r (Char :- r) -> Boomerang e [Text] r (Text :- r)
+ Text.Boomerang.Texts: rText1 :: PrinterParser e [Text] r (Char :- r) -> PrinterParser e [Text] r (Text :- r)
- Text.Boomerang.Texts: rTextCons :: Boomerang e tok (Char :- (Text :- r)) (Text :- r)
+ Text.Boomerang.Texts: rTextCons :: PrinterParser e tok (Char :- (Text :- r)) (Text :- r)
- Text.Boomerang.Texts: readshow :: (Read a, Show a) => Boomerang TextsError [Text] r (a :- r)
+ Text.Boomerang.Texts: readshow :: (Read a, Show a) => PrinterParser TextsError [Text] r (a :- r)
- Text.Boomerang.Texts: satisfy :: (Char -> Bool) -> Boomerang TextsError [Text] r (Char :- r)
+ Text.Boomerang.Texts: satisfy :: (Char -> Bool) -> PrinterParser TextsError [Text] r (Char :- r)
- Text.Boomerang.Texts: satisfyStr :: (Text -> Bool) -> Boomerang TextsError [Text] r (Text :- r)
+ Text.Boomerang.Texts: satisfyStr :: (Text -> Bool) -> PrinterParser TextsError [Text] r (Text :- r)
- Text.Boomerang.Texts: signed :: Boomerang TextsError [Text] a (Text :- r) -> Boomerang TextsError [Text] a (Text :- r)
+ Text.Boomerang.Texts: signed :: PrinterParser TextsError [Text] a (Text :- r) -> PrinterParser TextsError [Text] a (Text :- r)
- Text.Boomerang.Texts: space :: Boomerang TextsError [Text] r (Char :- r)
+ Text.Boomerang.Texts: space :: PrinterParser TextsError [Text] r (Char :- r)
- Text.Boomerang.Texts: unparseTexts :: Boomerang e [Text] () (r :- ()) -> r -> Maybe [Text]
+ Text.Boomerang.Texts: unparseTexts :: PrinterParser e [Text] () (r :- ()) -> r -> Maybe [Text]

Files

Text/Boomerang.hs view
@@ -42,15 +42,15 @@ >     | Baz Int Char >       deriving (Eq, Show) -Then we generate some combinators for the type:+Then we derive some combinators for the type: -> $(makeBoomerangs ''Foo)+> $(derivePrinterParsers ''Foo)  The combinators will be named after the constructors, but with an r prefixed to them. In this case, @rBar@ and @rBaz@.  Now we can define a grammar: -> foo :: StringBoomerang () (Foo :- ())+> foo :: StringPrinterParser () (Foo :- ()) > foo = >     (  rBar >     <> rBaz . "baz-" . int . "-" . alpha
Text/Boomerang/Combinators.hs view
@@ -1,5 +1,5 @@ -- | a collection of generic parsing combinators that can work with any token and error type.-{-# LANGUAGE CPP, TemplateHaskell, TypeOperators #-}+{-# LANGUAGE TemplateHaskell, TypeOperators #-} module Text.Boomerang.Combinators     ( (<>), duck, duck1, opt     , manyr, somer, chainr, chainr1, manyl, somel, chainl, chainl1@@ -14,78 +14,73 @@ import Control.Category    (Category((.), id)) import Control.Monad       (guard) import Control.Monad.Error (Error)-import Text.Boomerang.Prim    (Parser(..), Boomerang(..), (.~), val, xpure)-import Text.Boomerang.HStack   ((:-)(..), arg, hhead)-import Text.Boomerang.TH      (makeBoomerangs)--#if MIN_VERSION_base(4,5,0)-import Data.Monoid         (Monoid(mappend), (<>))-#else import Data.Monoid         (Monoid(mappend))+import Text.Boomerang.Prim    (Parser(..), PrinterParser(..), (.~), val, xpure)+import Text.Boomerang.HStack   ((:-)(..), arg, hhead)+import Text.Boomerang.TH      (derivePrinterParsers) -infixr 6 <>+infixr 8 <>  -- | Infix operator for 'mappend'. (<>) :: Monoid m => m -> m -> m (<>) = mappend-#endif  -- | Convert a router to do what it does on the tail of the stack.-duck :: Boomerang e tok r1 r2 -> Boomerang e tok (h :- r1) (h :- r2)-duck r = Boomerang+duck :: PrinterParser e tok r1 r2 -> PrinterParser e tok (h :- r1) (h :- r2)+duck r = PrinterParser   (fmap (\f (h :- t) -> h :- f t) $ prs r)   (\(h :- t) -> map (second (h :-)) $ ser r t)  -- | Convert a router to do what it does on the tail of the stack.-duck1 :: Boomerang e tok r1 (a :- r2) -> Boomerang e tok (h :- r1) (a :- h :- r2)-duck1 r = Boomerang+duck1 :: PrinterParser e tok r1 (a :- r2) -> PrinterParser e tok (h :- r1) (a :- h :- r2)+duck1 r = PrinterParser   (fmap (\f (h :- t) -> let a :- t' = f t in a :- h :- t') $ prs r)   (\(a :- h :- t) -> map (second (h :-)) $ ser r (a :- t))  -- | Make a router optional.-opt :: Boomerang e tok r r -> Boomerang e tok r r+opt :: PrinterParser e tok r r -> PrinterParser e tok r r opt = (id <>)  -- | Repeat a router zero or more times, combining the results from left to right.-manyr :: Boomerang e tok r r -> Boomerang e tok r r+manyr :: PrinterParser e tok r r -> PrinterParser e tok r r manyr = opt . somer  -- | Repeat a router one or more times, combining the results from left to right.-somer :: Boomerang e tok r r -> Boomerang e tok r r+somer :: PrinterParser e tok r r -> PrinterParser e tok r r somer p = p . manyr p  -- | @chainr p op@ repeats @p@ zero or more times, separated by @op@. --   The result is a right associative fold of the results of @p@ with the results of @op@.-chainr :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r+chainr :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r r chainr p op = opt (manyr (p .~ op) . p)  -- | @chainr1 p op@ repeats @p@ one or more times, separated by @op@. --   The result is a right associative fold of the results of @p@ with the results of @op@.-chainr1 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- a :- r) (a :- r) -> Boomerang e tok r (a :- r)+chainr1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- a :- r) (a :- r) -> PrinterParser e tok r (a :- r) chainr1 p op = manyr (duck p .~ op) . p  -- | Repeat a router zero or more times, combining the results from right to left.-manyl :: Boomerang e tok r r -> Boomerang e tok r r+manyl :: PrinterParser e tok r r -> PrinterParser e tok r r manyl = opt . somel  -- | Repeat a router one or more times, combining the results from right to left.-somel :: Boomerang e tok r r -> Boomerang e tok r r+somel :: PrinterParser e tok r r -> PrinterParser e tok r r somel p = p .~ manyl p  -- | @chainl1 p op@ repeats @p@ zero or more times, separated by @op@. --   The result is a left associative fold of the results of @p@ with the results of @op@.-chainl :: Boomerang e tok r r -> Boomerang e tok r r -> Boomerang e tok r r+chainl :: PrinterParser e tok r r -> PrinterParser e tok r r -> PrinterParser e tok r r chainl p op = opt (p .~ manyl (op . p))  -- | @chainl1 p op@ repeats @p@ one or more times, separated by @op@. --   The result is a left associative fold of the results of @p@ with the results of @op@.-chainl1 :: Boomerang e tok r (a :- r) -> Boomerang e tok (a :- a :- r) (a :- r) -> Boomerang e tok r (a :- r)+chainl1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok (a :- a :- r) (a :- r) -> PrinterParser e tok r (a :- r) chainl1 p op = p .~ manyl (op . duck p)  -- | Filtering on routers. -- -- TODO: We remove any parse errors, not sure if the should be preserved. Also, if the predicate fails we silently remove the element, but perhaps we should replace the value with an error message?-rFilter :: (a -> Bool) -> Boomerang e tok () (a :- ()) -> Boomerang e tok r (a :- r)+rFilter :: (a -> Bool) -> PrinterParser e tok () (a :- ()) -> PrinterParser e tok r (a :- r) rFilter p r = val ps ss     where       ps = Parser $ \tok pos ->@@ -97,52 +92,52 @@ --   and if it does, instead serializes as @s@. -- -- TODO: can this be more general so that it can work on @tok@ instead of @[tok]@-printAs :: Boomerang e [tok] a b -> tok -> Boomerang e [tok] a b+printAs :: PrinterParser e [tok] a b -> tok -> PrinterParser e [tok] a b printAs r s = r { ser = map (first (const (s :))) . take 1 . ser r }  -- | Push a value on the stack (during parsing, pop it from the stack when serializing).-push :: (Eq a, Error e) => a -> Boomerang e tok r (a :- r)+push :: (Eq a, Error e) => a -> PrinterParser e tok r (a :- r) push a = xpure (a :-) (\(a' :- t) -> guard (a' == a) >> Just t) -rNil :: Boomerang e tok r ([a] :- r)+rNil :: PrinterParser e tok r ([a] :- r) rNil = xpure ([] :-) $ \(xs :- t) -> do [] <- Just xs; Just t -rCons :: Boomerang e tok (a :- [a] :- r) ([a] :- r)+rCons :: PrinterParser e tok (a :- [a] :- r) ([a] :- r) rCons = xpure (arg (arg (:-)) (:)) $ \(xs :- t) -> do a:as <- Just xs; Just (a :- as :- t)  -- | Converts a router for a value @a@ to a router for a list of @a@.-rList :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r)+rList :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r) rList r = manyr (rCons . duck1 r) . rNil  -- | Converts a router for a value @a@ to a router for a list of @a@.-rList1 :: Boomerang e tok r (a :- r) -> Boomerang e tok r ([a] :- r)+rList1 :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r ([a] :- r) rList1 r = somer (rCons . duck1 r) . rNil  -- | Converts a router for a value @a@ to a router for a list of @a@, with a separator.-rListSep :: Boomerang e tok r (a :- r) -> Boomerang e tok ([a] :- r) ([a] :- r) -> Boomerang e tok r ([a] :- r)+rListSep :: PrinterParser e tok r (a :- r) -> PrinterParser e tok ([a] :- r) ([a] :- r) -> PrinterParser e tok r ([a] :- r) rListSep r sep = chainr (rCons . duck1 r) sep . rNil -rPair :: Boomerang e tok (f :- s :- r) ((f, s) :- r)+rPair :: PrinterParser e tok (f :- s :- r) ((f, s) :- r) rPair = xpure (arg (arg (:-)) (,)) $ \(ab :- t) -> do (a,b) <- Just ab; Just (a :- b :- t) -$(makeBoomerangs ''Either)+$(derivePrinterParsers ''Either)  -- | Combines a router for a value @a@ and a router for a value @b@ into a router for @Either a b@.-rEither :: Boomerang e tok r (a :- r) -> Boomerang e tok r (b :- r) -> Boomerang e tok r (Either a b :- r)+rEither :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (b :- r) -> PrinterParser e tok r (Either a b :- r) rEither l r = rLeft . l <> rRight . r -$(makeBoomerangs ''Maybe)+$(derivePrinterParsers ''Maybe)  -- | Converts a router for a value @a@ to a router for a @Maybe a@.-rMaybe :: Boomerang e tok r (a :- r) -> Boomerang e tok r (Maybe a :- r)+rMaybe :: PrinterParser e tok r (a :- r) -> PrinterParser e tok r (Maybe a :- r) rMaybe r = rJust . r <> rNothing -$(makeBoomerangs ''Bool)+$(derivePrinterParsers ''Bool) -rBool :: Boomerang e tok a r -- ^ 'True' parser-      -> Boomerang e tok a r -- ^ 'False' parser-      -> Boomerang e tok a (Bool :- r)+rBool :: PrinterParser e tok a r -- ^ 'True' parser+      -> PrinterParser e tok a r -- ^ 'False' parser+      -> PrinterParser e tok a (Bool :- r) rBool t f = rTrue . t <> rFalse . f -rUnit :: Boomerang e tok r (() :- r)+rUnit :: PrinterParser e tok r (() :- r) rUnit = xpure ((:-) ()) (\ (() :- x) -> Just x)
Text/Boomerang/Error.hs view
@@ -1,4 +1,4 @@--- | An Error handling scheme that can be used with 'Boomerang'+-- | An Error handling scheme that can be used with 'PrinterParser' {-# LANGUAGE DeriveDataTypeable, TypeFamilies #-} module Text.Boomerang.Error where @@ -55,7 +55,7 @@ -- | annotate a parse error with an additional 'Expect' message -- -- > satisfy isUpper <?> 'an uppercase character'-(<?>) :: Boomerang (ParserError p) tok a b -> String -> Boomerang (ParserError p) tok a b+(<?>) :: PrinterParser (ParserError p) tok a b -> String -> PrinterParser (ParserError p) tok a b router <?> msg =     router { prs = Parser $ \tok pos ->         map (either (\(ParserError mPos errs) -> Left $ ParserError mPos ((Expect msg) : errs)) Right) (runParser (prs router) tok pos) }
Text/Boomerang/Prim.hs view
@@ -1,10 +1,10 @@ {-# LANGUAGE FlexibleContexts, ScopedTypeVariables, TypeOperators, TypeFamilies #-} module Text.Boomerang.Prim     ( -- * Types-    Parser(..), Boomerang(..), PrinterParser, (.~)+    Parser(..), PrinterParser(..), (.~)     -- * Running routers     , parse, parse1, unparse, unparse1, bestErrors-    -- * Constructing / Manipulating Boomerangs+    -- * Constructing / Manipulating PrinterParsers     , xpure, val, xmap     -- heterogeneous list functions     , xmaph@@ -88,73 +88,70 @@ bestErrors [] = [] bestErrors errs = maximumsBy (compare `on` getPosition) errs --- | A @Boomerang a b@ takes an @a@ to parse a URL and results in @b@ if parsing succeeds.+-- | A @PrinterParser a b@ takes an @a@ to parse a URL and results in @b@ if parsing succeeds. --   And it takes a @b@ to serialize to a URL and results in @a@ if serializing succeeds.-data Boomerang e tok a b = Boomerang+data PrinterParser e tok a b = PrinterParser   { prs :: Parser e tok (a -> b)   , ser :: b -> [(tok -> tok, a)]   } -type PrinterParser = Boomerang-{-# DEPRECATED PrinterParser "Use Boomerang instead" #-}--instance Category (Boomerang e tok) where-  id = Boomerang+instance Category (PrinterParser e tok) where+  id = PrinterParser     (return id)     (\x -> [(id, x)]) -  ~(Boomerang pf sf) . ~(Boomerang pg sg) = Boomerang+  ~(PrinterParser pf sf) . ~(PrinterParser pg sg) = PrinterParser     (composeP (.) pf pg)     (compose (.) sf sg) -instance Monoid (Boomerang e tok a b) where-  mempty = Boomerang+instance Monoid (PrinterParser e tok a b) where+  mempty = PrinterParser     mzero     (const mzero) -  ~(Boomerang pf sf) `mappend` ~(Boomerang pg sg) = Boomerang+  ~(PrinterParser pf sf) `mappend` ~(PrinterParser pg sg) = PrinterParser     (pf `mplus` pg)     (\s -> sf s `mplus` sg s)  infixr 9 .~ -- | Reverse composition, but with the side effects still in left-to-right order.-(.~) :: Boomerang e tok a b -> Boomerang e tok b c -> Boomerang e tok a c-~(Boomerang pf sf) .~ ~(Boomerang pg sg) = Boomerang+(.~) :: PrinterParser e tok a b -> PrinterParser e tok b c -> PrinterParser e tok a c+~(PrinterParser pf sf) .~ ~(PrinterParser pg sg) = PrinterParser   (composeP (flip (.)) pf pg)   (compose (flip (.)) sg sf)  -- | Map over routers.-xmap :: (a -> b) -> (b -> Maybe a) -> Boomerang e tok r a -> Boomerang e tok r b-xmap f g (Boomerang p s) = Boomerang p' s'+xmap :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok r a -> PrinterParser e tok r b+xmap f g (PrinterParser p s) = PrinterParser p' s'     where       p' = fmap (fmap f) p       s' url = maybe mzero s (g url)  -- | Lift a constructor-destructor pair to a pure router.-xpure :: (a -> b) -> (b -> Maybe a) -> Boomerang e tok a b+xpure :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok a b xpure f g = xmap f g id  -- | Like "xmap", but only maps over the top of the stack.-xmaph :: (a -> b) -> (b -> Maybe a) -> Boomerang e tok i (a :- o) -> Boomerang e tok i (b :- o)+xmaph :: (a -> b) -> (b -> Maybe a) -> PrinterParser e tok i (a :- o) -> PrinterParser e tok i (b :- o) xmaph f g = xmap (hdMap f) (hdTraverse g) --- | lift a 'Parser' and a printer into a 'Boomerang'-val :: forall e tok a r. Parser e tok a -> (a -> [tok -> tok]) -> Boomerang e tok r (a :- r)-val rs ss = Boomerang rs' ss'+-- | lift a 'Parser' and a printer into a 'PrinterParser'+val :: forall e tok a r. Parser e tok a -> (a -> [tok -> tok]) -> PrinterParser e tok r (a :- r)+val rs ss = PrinterParser rs' ss'     where       rs' :: Parser e tok (r -> (a :- r))       rs' = fmap (:-) rs       ss' =  (\(a :- r) -> map (\f -> (f, r)) (ss a))  -- | Give all possible parses or errors.-parse :: forall e a p tok. (InitialPosition e) => Boomerang e tok () a -> tok -> [Either e (a, tok)]+parse :: forall e a p tok. (InitialPosition e) => PrinterParser e tok () a -> tok -> [Either e (a, tok)] parse p s =     map (either Left (\((f, tok), _) -> Right (f (), tok))) $ runParser (prs p) s (initialPos (Nothing :: Maybe e)) --- | Give the first parse, for Boomerangs with a parser that yields just one value.+-- | Give the first parse, for PrinterParsers with a parser that yields just one value. -- Otherwise return the error (or errors) with the highest error position. parse1 :: (ErrorPosition e, InitialPosition e, Show e, Ord (Pos e)) =>-          (tok -> Bool) -> Boomerang e tok () (a :- ()) -> tok -> Either [e] a+          (tok -> Bool) -> PrinterParser e tok () (a :- ()) -> tok -> Either [e] a parse1 isComplete r paths =     let results = parse r paths     in case [ a | (Right (a,tok)) <- results, isComplete tok ] of@@ -162,11 +159,11 @@          _             -> Left $ bestErrors [ e | Left e <- results ]  -- | Give all possible serializations.-unparse :: tok -> Boomerang e tok () url -> url -> [tok]+unparse :: tok -> PrinterParser e tok () url -> url -> [tok] unparse tok p = (map (($ tok) . fst)) . ser p --- | Give the first serialization, for Boomerangs with a serializer that needs just one value.-unparse1 :: tok -> Boomerang e tok () (a :- ()) -> a -> Maybe tok+-- | Give the first serialization, for PrinterParsers with a serializer that needs just one value.+unparse1 :: tok -> PrinterParser e tok () (a :- ()) -> a -> Maybe tok unparse1 tok p a =     case unparse tok p (a :- ()) of       [] -> Nothing
Text/Boomerang/String.hs view
@@ -1,13 +1,13 @@--- | a 'Boomerang' library for working with a 'String'+-- | a 'PrinterParser' library for working with a 'String' {-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances, TemplateHaskell, TypeFamilies, TypeSynonymInstances, TypeOperators #-} module Text.Boomerang.String     (     -- * Types-      StringBoomerang, StringPrinterParser, StringError+      StringPrinterParser, StringError     -- * Combinators     , alpha, anyChar, char, digit, int     , integer, lit, satisfy, space-    -- * Running the 'Boomerang'+    -- * Running the 'PrinterParser'     , isComplete, parseString, unparseString     )     where@@ -22,20 +22,17 @@ import Text.Boomerang.Error       (ParserError(..),ErrorMsg(..), (<?>), condenseErrors, mkParserError) import Text.Boomerang.HStack       ((:-)(..)) import Text.Boomerang.Pos         (InitialPosition(..), MajorMinorPos(..), incMajor, incMinor)-import Text.Boomerang.Prim        (Parser(..), Boomerang(..), parse1, xmaph, unparse1, val)+import Text.Boomerang.Prim        (Parser(..), PrinterParser(..), parse1, xmaph, unparse1, val)  type StringError         = ParserError MajorMinorPos-type StringBoomerang = Boomerang StringError String--type StringPrinterParser = StringBoomerang-{-# DEPRECATED StringPrinterParser "Use StringBoomerang instead" #-}+type StringPrinterParser = PrinterParser StringError String  instance InitialPosition StringError where     initialPos _ = MajorMinorPos 0 0  -- | a constant string-lit :: String -> StringBoomerang r r-lit l = Boomerang pf sf+lit :: String -> StringPrinterParser r r+lit l = PrinterParser pf sf     where       pf = Parser $ \tok pos ->            case tok of@@ -50,11 +47,11 @@     | l /= s    = mkParserError pos [UnExpect (show s), Expect (show l)]     | otherwise = parseLit ls ss (if l == '\n' then incMajor 1 pos else incMinor 1 pos) -instance a ~ b => IsString (Boomerang StringError String a b) where+instance a ~ b => IsString (PrinterParser StringError String a b) where     fromString = lit  -- | statisfy a 'Char' predicate-satisfy :: (Char -> Bool) -> StringBoomerang r (Char :- r)+satisfy :: (Char -> Bool) -> StringPrinterParser r (Char :- r) satisfy p = val   (Parser $ \tok pos ->        case tok of@@ -68,24 +65,24 @@   (\c -> [ \paths -> (c:paths) | p c ])  -- | ascii digits @\'0\'..\'9\'@-digit :: StringBoomerang r (Char :- r)+digit :: StringPrinterParser r (Char :- r) digit = satisfy isDigit <?> "a digit 0-9"  -- | matches alphabetic Unicode characters (lower-case, upper-case and title-case letters, -- plus letters of caseless scripts and modifiers letters).  (Uses 'isAlpha')-alpha :: StringBoomerang r (Char :- r)+alpha :: StringPrinterParser r (Char :- r) alpha = satisfy isAlpha <?> "an alphabetic Unicode character"  -- | matches white-space characters in the Latin-1 range. (Uses 'isSpace')-space :: StringBoomerang r (Char :- r)+space :: StringPrinterParser r (Char :- r) space = satisfy isSpace <?> "a white-space character"  -- | any character-anyChar :: StringBoomerang r (Char :- r)+anyChar :: StringPrinterParser r (Char :- r) anyChar = satisfy (const True)  -- | matches the specified character-char :: Char -> StringBoomerang r (Char :- r)+char :: Char -> StringPrinterParser r (Char :- r) char c = satisfy (== c) <?> show [c]  readIntegral :: (Read a, Eq a, Num a) => String -> a@@ -96,11 +93,11 @@       _   -> error "readIntegral: ambiguous parse"  -- | matches an 'Int'-int :: StringBoomerang r (Int :- r)+int :: StringPrinterParser r (Int :- r) int = xmaph readIntegral (Just . show) (opt (rCons . char '-') . (rList1 digit))  -- | matches an 'Integer'-integer :: StringBoomerang r (Integer :- r)+integer :: StringPrinterParser r (Integer :- r) integer = xmaph readIntegral (Just . show) (opt (rCons . char '-') . (rList1 digit))  -- | Predicate to test if we have parsed all the strings.@@ -115,7 +112,7 @@ -- Returns the first complete parse or a parse error. -- -- > parseString (rUnit . lit "foo") ["foo"]-parseString :: StringBoomerang () (r :- ())+parseString :: StringPrinterParser () (r :- ())              -> String              -> Either StringError r parseString pp strs =@@ -124,5 +121,5 @@ -- | run the printer -- -- > unparseString (rUnit . lit "foo") ()-unparseString :: StringBoomerang () (r :- ()) -> r -> Maybe String+unparseString :: StringPrinterParser () (r :- ()) -> r -> Maybe String unparseString pp r = unparse1 [] pp r
Text/Boomerang/Strings.hs view
@@ -1,4 +1,4 @@--- | a 'Boomerang' library for working with '[String]'+-- | a 'PrinterParser' library for working with '[String]' {-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances, TemplateHaskell, TypeFamilies, TypeSynonymInstances, TypeOperators #-} module Text.Boomerang.Strings     (@@ -7,7 +7,7 @@     -- * Combinators     , (</>), alpha, anyChar, anyString, char, digit, eos, int     , integer, lit, readshow, satisfy, satisfyStr, space-    -- * Running the 'Boomerang'+    -- * Running the 'PrinterParser'     , isComplete, parseStrings, unparseStrings      )@@ -24,19 +24,19 @@ import Text.Boomerang.Error       (ParserError(..),ErrorMsg(..), (<?>), condenseErrors, mkParserError) import Text.Boomerang.HStack       ((:-)(..)) import Text.Boomerang.Pos         (InitialPosition(..), MajorMinorPos(..), incMajor, incMinor)-import Text.Boomerang.Prim        (Parser(..), Boomerang(..), parse1, xmaph, unparse1, val)+import Text.Boomerang.Prim        (Parser(..), PrinterParser(..), parse1, xmaph, unparse1, val)  type StringsError = ParserError MajorMinorPos  instance InitialPosition StringsError where     initialPos _ = MajorMinorPos 0 0 -instance a ~ b => IsString (Boomerang StringsError [String] a b) where+instance a ~ b => IsString (PrinterParser StringsError [String] a b) where     fromString = lit  -- | a constant string-lit :: String -> Boomerang StringsError [String] r r-lit l = Boomerang pf sf+lit :: String -> PrinterParser StringsError [String] r r+lit l = PrinterParser pf sf     where       pf = Parser $ \tok pos ->            case tok of@@ -52,12 +52,12 @@  infixr 9 </> -- | equivalent to @f . eos . g@-(</>) :: Boomerang StringsError [String] b c -> Boomerang StringsError [String] a b -> Boomerang StringsError [String] a c+(</>) :: PrinterParser StringsError [String] b c -> PrinterParser StringsError [String] a b -> PrinterParser StringsError [String] a c f </> g = f . eos . g  -- | end of string-eos :: Boomerang StringsError [String] r r-eos = Boomerang+eos :: PrinterParser StringsError [String] r r+eos = PrinterParser        (Parser $ \path pos -> case path of                    []      -> [Right ((id, []), incMajor 1 pos)] --                   [] -> mkParserError pos [EOI "input"]@@ -67,7 +67,7 @@        (\a -> [(("" :), a)])  -- | statisfy a 'Char' predicate-satisfy :: (Char -> Bool) -> Boomerang StringsError [String] r (Char :- r)+satisfy :: (Char -> Bool) -> PrinterParser StringsError [String] r (Char :- r) satisfy p = val   (Parser $ \tok pos ->        case tok of@@ -85,7 +85,7 @@ -- | satisfy a 'String' predicate. -- -- Note: must match the entire remainder of the 'String' in this segment-satisfyStr :: (String -> Bool) -> Boomerang StringsError [String] r (String :- r)+satisfyStr :: (String -> Bool) -> PrinterParser StringsError [String] r (String :- r) satisfyStr p = val   (Parser $ \tok pos ->        case tok of@@ -101,27 +101,27 @@   -- | ascii digits @\'0\'..\'9\'@-digit :: Boomerang StringsError [String] r (Char :- r)+digit :: PrinterParser StringsError [String] r (Char :- r) digit = satisfy isDigit <?> "a digit 0-9"  -- | matches alphabetic Unicode characters (lower-case, upper-case and title-case letters, -- plus letters of caseless scripts and modifiers letters).  (Uses 'isAlpha')-alpha :: Boomerang StringsError [String] r (Char :- r)+alpha :: PrinterParser StringsError [String] r (Char :- r) alpha = satisfy isAlpha <?> "an alphabetic Unicode character"  -- | matches white-space characters in the Latin-1 range. (Uses 'isSpace')-space :: Boomerang StringsError [String] r (Char :- r)+space :: PrinterParser StringsError [String] r (Char :- r) space = satisfy isSpace <?> "a white-space character"  -- | any character-anyChar :: Boomerang StringsError [String] r (Char :- r)+anyChar :: PrinterParser StringsError [String] r (Char :- r) anyChar = satisfy (const True)  -- | matches the specified character-char :: Char -> Boomerang StringsError [String] r (Char :- r)+char :: Char -> PrinterParser StringsError [String] r (Char :- r) char c = satisfy (== c) <?> show [c] --- | lift 'Read'/'Show' to a 'Boomerang'+-- | lift 'Read'/'Show' to a 'PrinterParser' -- -- There are a few restrictions here: --@@ -131,7 +131,7 @@ -- --  2. it is (currently) not safe to use 'readshow' on integral values --  because the 'Read' instance for 'Int', 'Integer', etc,-readshow :: (Read a, Show a) => Boomerang StringsError [String] r (a :- r)+readshow :: (Read a, Show a) => PrinterParser StringsError [String] r (a :- r) readshow =     val readParser s     where@@ -159,13 +159,13 @@ -- | matches an 'Int' -- -- Note that the combinator @(rPair . int . int)@ is ill-defined because the parse can not tell where it is supposed to split the sequence of digits to produced two ints.-int :: Boomerang StringsError [String] r (Int :- r)+int :: PrinterParser StringsError [String] r (Int :- r) int = xmaph readIntegral (Just . show) (opt (rCons . char '-') . (rList1 digit))  -- | matches an 'Integer' -- -- Note that the combinator @(rPair . integer . integer)@ is ill-defined because the parse can not tell where it is supposed to split the sequence of digits to produced two ints.-integer :: Boomerang StringsError [String] r (Integer :- r)+integer :: PrinterParser StringsError [String] r (Integer :- r) integer = xmaph readIntegral (Just . show) (opt (rCons . char '-') . (rList1 digit))  -- | matches any 'String'@@ -185,7 +185,7 @@ -- > parseStrings (rPair . anyString . anyString)  ["foobar"] -- -- We will get @Right ("foobar","")@ instead of the original @Right ("foo","bar")@-anyString :: Boomerang StringsError [String] r (String :- r)+anyString :: PrinterParser StringsError [String] r (String :- r) anyString = val ps ss     where       ps = Parser $ \tok pos ->@@ -212,7 +212,7 @@ -- Returns the first complete parse or a parse error. -- -- > parseStrings (rUnit . lit "foo") ["foo"]-parseStrings :: Boomerang StringsError [String] () (r :- ())+parseStrings :: PrinterParser StringsError [String] () (r :- ())              -> [String]              -> Either StringsError r parseStrings pp strs =@@ -221,5 +221,5 @@ -- | run the printer -- -- > unparseStrings (rUnit . lit "foo") ()-unparseStrings :: Boomerang e [String] () (r :- ()) -> r -> Maybe [String]+unparseStrings :: PrinterParser e [String] () (r :- ()) -> r -> Maybe [String] unparseStrings pp r = unparse1 [] pp r
Text/Boomerang/TH.hs view
@@ -1,40 +1,28 @@ {-# LANGUAGE TemplateHaskell, TypeOperators #-}-module Text.Boomerang.TH-    ( makeBoomerangs-    -- * Backwards-compatibility-    , derivePrinterParsers-    ) where+module Text.Boomerang.TH (derivePrinterParsers) where  import Control.Monad       (liftM, replicateM) import Language.Haskell.TH import Text.Boomerang.HStack   ((:-)(..), arg)-import Text.Boomerang.Prim    (xpure, Boomerang)+import Text.Boomerang.Prim    (xpure, PrinterParser) --- | Make a 'Boomerang' router for each constructor in a datatype. For--- example:+-- | Derive routers for all constructors in a datatype. For example: -----   @$(makeBoomerangs \'\'Sitemap)@-makeBoomerangs :: Name -> Q [Dec]-makeBoomerangs name = do+--   @$(derivePrinterParsers \'\'Sitemap)@+derivePrinterParsers :: Name -> Q [Dec]+derivePrinterParsers name = do   info <- reify name   case info of     TyConI (DataD _ tName tBinds cons _)   ->-      concat `liftM` mapM (deriveBoomerang (tName, tBinds)) cons+      concat `liftM` mapM (derivePrinterParser (tName, tBinds)) cons     TyConI (NewtypeD _ tName tBinds con _) ->-      deriveBoomerang (tName, tBinds) con+      derivePrinterParser (tName, tBinds) con     _ ->       fail $ show name ++ " is not a datatype." --- | Old name for 'makeBoomerangs', since renamed to reflect the fact--- that it's not actually deriving instances for any type class, but rather--- generates top-level definitions for routers of type 'Boomerang'.-derivePrinterParsers :: Name -> Q [Dec]-derivePrinterParsers = makeBoomerangs-{-# DEPRECATED derivePrinterParsers "Use makeBoomerangs instead" #-}- -- Derive a router for a single constructor.-deriveBoomerang :: (Name, [TyVarBndr]) -> Con -> Q [Dec]-deriveBoomerang (tName, tParams) con =+derivePrinterParser :: (Name, [TyVarBndr]) -> Con -> Q [Dec]+derivePrinterParser (tName, tParams) con =   case con of     NormalC name tys -> go name (map snd tys)     RecC name tys -> go name (map (\(_,_,ty) -> ty) tys)@@ -45,10 +33,10 @@     takeName (PlainTV n) = n     takeName (KindedTV n _) = n     go name tys = do-      let name' = mkBoomerangName name+      let name' = mkPrinterParserName name       let tok' = mkName "tok"       let e' = mkName "e"-      let ppType = AppT (AppT (ConT ''Boomerang) (VarT e')) (VarT tok')+      let ppType = AppT (AppT (ConT ''PrinterParser) (VarT e')) (VarT tok')       let r' = mkName "r"       let inT = foldr (\a b -> AppT (AppT (ConT ''(:-)) a) b) (VarT r') tys       let outT = AppT (AppT (ConT ''(:-))@@ -104,8 +92,8 @@   -- Derive the name of a router based on the name of the constructor in question.-mkBoomerangName :: Name -> Name-mkBoomerangName name = mkName ('r' : nameBase name)+mkPrinterParserName :: Name -> Name+mkPrinterParserName name = mkName ('r' : nameBase name)   -- Retrieve the name of a constructor.
Text/Boomerang/Texts.hs view
@@ -1,4 +1,4 @@--- | a 'Boomerang' library for working with '[Text]'+-- | a 'PrinterParser' library for working with '[Text]' {-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances, TemplateHaskell, TypeFamilies, TypeSynonymInstances, TypeOperators #-} module Text.Boomerang.Texts     (@@ -8,7 +8,7 @@     , (</>), alpha, anyChar, anyText, char, digit, digits, signed, eos, integral, int     , integer, lit, readshow, satisfy, satisfyStr, space     , rTextCons, rEmpty, rText, rText1-    -- * Running the 'Boomerang'+    -- * Running the 'PrinterParser'     , isComplete, parseTexts, unparseTexts     )     where@@ -24,19 +24,19 @@ import Text.Boomerang.Error       (ParserError(..),ErrorMsg(..), (<?>), condenseErrors, mkParserError) import Text.Boomerang.HStack      ((:-)(..), arg) import Text.Boomerang.Pos         (InitialPosition(..), MajorMinorPos(..), incMajor, incMinor)-import Text.Boomerang.Prim        (Parser(..), Boomerang(..), parse1, xmaph, xpure, unparse1, val)+import Text.Boomerang.Prim        (Parser(..), PrinterParser(..), parse1, xmaph, xpure, unparse1, val)  type TextsError = ParserError MajorMinorPos  instance InitialPosition TextsError where     initialPos _ = MajorMinorPos 0 0 -instance a ~ b => IsString (Boomerang TextsError [Text] a b) where+instance a ~ b => IsString (PrinterParser TextsError [Text] a b) where     fromString = lit . Text.pack  -- | a constant string-lit :: Text -> Boomerang TextsError [Text] r r-lit l = Boomerang pf sf+lit :: Text -> PrinterParser TextsError [Text] r r+lit l = PrinterParser pf sf     where       pf = Parser $ \tok pos ->            case tok of@@ -53,12 +53,12 @@  infixr 9 </> -- | equivalent to @f . eos . g@-(</>) :: Boomerang TextsError [Text] b c -> Boomerang TextsError [Text] a b -> Boomerang TextsError [Text] a c+(</>) :: PrinterParser TextsError [Text] b c -> PrinterParser TextsError [Text] a b -> PrinterParser TextsError [Text] a c f </> g = f . eos . g  -- | end of string-eos :: Boomerang TextsError [Text] r r-eos = Boomerang+eos :: PrinterParser TextsError [Text] r r+eos = PrinterParser        (Parser $ \path pos -> case path of                    []      -> [Right ((id, []), incMajor 1 pos)] --                   [] -> mkParserError pos [EOI "input"]@@ -69,7 +69,7 @@        (\a -> [((Text.empty :), a)])  -- | statisfy a 'Char' predicate-satisfy :: (Char -> Bool) -> Boomerang TextsError [Text] r (Char :- r)+satisfy :: (Char -> Bool) -> PrinterParser TextsError [Text] r (Char :- r) satisfy p = val   (Parser $ \tok pos ->        case tok of@@ -89,7 +89,7 @@ -- | satisfy a 'Text' predicate. -- -- Note: must match the entire remainder of the 'Text' in this segment-satisfyStr :: (Text -> Bool) -> Boomerang TextsError [Text] r (Text :- r)+satisfyStr :: (Text -> Bool) -> PrinterParser TextsError [Text] r (Text :- r) satisfyStr p = val   (Parser $ \tok pos ->        case tok of@@ -104,27 +104,27 @@   (\str -> [ \strings -> case strings of [] -> [str] ; (s:ss) -> ((str `Text.append` s):ss) | p str ])  -- | ascii digits @\'0\'..\'9\'@-digit :: Boomerang TextsError [Text] r (Char :- r)+digit :: PrinterParser TextsError [Text] r (Char :- r) digit = satisfy isDigit <?> "a digit 0-9"  -- | matches alphabetic Unicode characters (lower-case, upper-case and title-case letters, -- plus letters of caseless scripts and modifiers letters).  (Uses 'isAlpha')-alpha :: Boomerang TextsError [Text] r (Char :- r)+alpha :: PrinterParser TextsError [Text] r (Char :- r) alpha = satisfy isAlpha <?> "an alphabetic Unicode character"  -- | matches white-space characters in the Latin-1 range. (Uses 'isSpace')-space :: Boomerang TextsError [Text] r (Char :- r)+space :: PrinterParser TextsError [Text] r (Char :- r) space = satisfy isSpace <?> "a white-space character"  -- | any character-anyChar :: Boomerang TextsError [Text] r (Char :- r)+anyChar :: PrinterParser TextsError [Text] r (Char :- r) anyChar = satisfy (const True)  -- | matches the specified character-char :: Char -> Boomerang TextsError [Text] r (Char :- r)+char :: Char -> PrinterParser TextsError [Text] r (Char :- r) char c = satisfy (== c) <?> show [c] --- | lift 'Read'/'Show' to a 'Boomerang'+-- | lift 'Read'/'Show' to a 'PrinterParser' -- -- There are a few restrictions here: --@@ -134,7 +134,7 @@ -- --  2. it is (currently) not safe to use 'readshow' on integral values --  because the 'Read' instance for 'Int', 'Integer', etc,-readshow :: (Read a, Show a) => Boomerang TextsError [Text] r (a :- r)+readshow :: (Read a, Show a) => PrinterParser TextsError [Text] r (a :- r) readshow =     val readParser s     where@@ -162,7 +162,7 @@   -- | the empty string-rEmpty :: Boomerang e [Text] r (Text :- r)+rEmpty :: PrinterParser e [Text] r (Text :- r) rEmpty = xpure (Text.empty :-) $               \(xs :- t) ->                   if Text.null xs@@ -170,7 +170,7 @@                      else Nothing  -- | the first character of a 'Text'-rTextCons :: Boomerang e tok (Char :- Text :- r) (Text :- r)+rTextCons :: PrinterParser e tok (Char :- Text :- r) (Text :- r) rTextCons =     xpure (arg (arg (:-)) (Text.cons)) $           \(xs :- t) ->@@ -178,44 +178,44 @@                  return (a :- as :- t)  -- | construct/parse some 'Text' by repeatedly apply a 'Char' 0 or more times parser-rText :: Boomerang e [Text] r (Char :- r)-      -> Boomerang e [Text] r (Text :- r)+rText :: PrinterParser e [Text] r (Char :- r)+      -> PrinterParser e [Text] r (Text :- r) rText r = manyr (rTextCons . duck1 r) . rEmpty  -- | construct/parse some 'Text' by repeatedly apply a 'Char' 1 or more times parser-rText1 :: Boomerang e [Text] r (Char :- r)-      -> Boomerang e [Text] r (Text :- r)+rText1 :: PrinterParser e [Text] r (Char :- r)+      -> PrinterParser e [Text] r (Text :- r) rText1 r = somer (rTextCons . duck1 r) . rEmpty  --- | a sequence of one or more digits-digits :: Boomerang TextsError [Text] r (Text :- r)-digits = rText1 digit+-- | a sequence of digits+digits :: PrinterParser TextsError [Text] r (Text :- r)+digits = rText digit  -- | an optional - character -- -- Typically used with 'digits' to support signed numbers -- -- > signed digits-signed :: Boomerang TextsError [Text] a (Text :- r)-       -> Boomerang TextsError [Text] a (Text :- r)+signed :: PrinterParser TextsError [Text] a (Text :- r)+       -> PrinterParser TextsError [Text] a (Text :- r) signed r = opt (rTextCons . char '-') . r  -- | matches an 'Integral' value -- -- Note that the combinator @(rPair . integral . integral)@ is ill-defined because the parse canwell. not tell where it is supposed to split the sequence of digits to produced two ints.-integral :: (Integral a, Show a) => Boomerang TextsError [Text] r (a :- r)+integral :: (Integral a, Show a) => PrinterParser TextsError [Text] r (a :- r) integral = xmaph readIntegral (Just . Text.pack . show)  (signed digits)  -- | matches an 'Int' -- Note that the combinator @(rPair . int . int)@ is ill-defined because the parse canwell. not tell where it is supposed to split the sequence of digits to produced two ints.-int :: Boomerang TextsError [Text] r (Int :- r)+int :: PrinterParser TextsError [Text] r (Int :- r) int = integral  -- | matches an 'Integer' -- -- Note that the combinator @(rPair . integer . integer)@ is ill-defined because the parse can not tell where it is supposed to split the sequence of digits to produced two ints.-integer :: Boomerang TextsError [Text] r (Integer :- r)+integer :: PrinterParser TextsError [Text] r (Integer :- r) integer = integral  -- | matches any 'Text'@@ -235,7 +235,7 @@ -- > parseTexts (rPair . anyText . anyText)  ["foobar"] -- -- We will get @Right ("foobar","")@ instead of the original @Right ("foo","bar")@-anyText :: Boomerang TextsError [Text] r (Text :- r)+anyText :: PrinterParser TextsError [Text] r (Text :- r) anyText = val ps ss     where       ps = Parser $ \tok pos ->@@ -262,7 +262,7 @@ -- Returns the first complete parse or a parse error. -- -- > parseTexts (rUnit . lit "foo") ["foo"]-parseTexts :: Boomerang TextsError [Text] () (r :- ())+parseTexts :: PrinterParser TextsError [Text] () (r :- ())              -> [Text]              -> Either TextsError r parseTexts pp strs =@@ -271,5 +271,5 @@ -- | run the printer -- -- > unparseTexts (rUnit . lit "foo") ()-unparseTexts :: Boomerang e [Text] () (r :- ()) -> r -> Maybe [Text]+unparseTexts :: PrinterParser e [Text] () (r :- ()) -> r -> Maybe [Text] unparseTexts pp r = unparse1 [] pp r
boomerang.cabal view
@@ -1,5 +1,5 @@ Name:             boomerang-Version:          1.3.4+Version:          1.3.4.1 License:          BSD3 License-File:     LICENSE Author:           jeremy@seereason.com@@ -41,5 +41,5 @@  source-repository head     type:     darcs-    location: http://hub.darcs.net/stepcut/boomerang+    location: http://patch-tag.com/r/stepcut/boomerang