packages feed

chuchu 0.0.0.1 → 0.1.0.0

raw patch · 3 files changed

+35/−29 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Test.Chuchu.Parser: instance IsString (Parser a)
+ Test.Chuchu.Types: ChuchuParser :: (Parser a) -> ChuchuParser a
+ Test.Chuchu.Types: instance Applicative ChuchuParser
+ Test.Chuchu.Types: instance Functor ChuchuParser
+ Test.Chuchu.Types: instance IsString (ChuchuParser a)
+ Test.Chuchu.Types: instance Monad ChuchuParser
+ Test.Chuchu.Types: newtype ChuchuParser a
- Test.Chuchu.Parser: email :: Parser String
+ Test.Chuchu.Parser: email :: ChuchuParser String
- Test.Chuchu.Parser: int :: Parser Integer
+ Test.Chuchu.Parser: int :: ChuchuParser Integer
- Test.Chuchu.Parser: number :: Parser Double
+ Test.Chuchu.Parser: number :: ChuchuParser Double
- Test.Chuchu.Parser: text :: Parser String
+ Test.Chuchu.Parser: text :: ChuchuParser String
- Test.Chuchu.Parser: wildcard :: String -> Parser ()
+ Test.Chuchu.Parser: wildcard :: String -> ChuchuParser ()
- Test.Chuchu.Types: And :: Parser a -> (a -> m ()) -> ChuchuM m ()
+ Test.Chuchu.Types: And :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()
- Test.Chuchu.Types: But :: Parser a -> (a -> m ()) -> ChuchuM m ()
+ Test.Chuchu.Types: But :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()
- Test.Chuchu.Types: Given :: Parser a -> (a -> m ()) -> ChuchuM m ()
+ Test.Chuchu.Types: Given :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()
- Test.Chuchu.Types: Then :: Parser a -> (a -> m ()) -> ChuchuM m ()
+ Test.Chuchu.Types: Then :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()
- Test.Chuchu.Types: When :: Parser a -> (a -> m ()) -> ChuchuM m ()
+ Test.Chuchu.Types: When :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()

Files

Test/Chuchu/Parser.hs view
@@ -14,46 +14,39 @@ -- base import Control.Applicative hiding ((<|>)) import Control.Monad-import GHC.Exts  -- parsec import Text.Parsec-import Text.Parsec.Text  -- chuchu+import Test.Chuchu.Types (ChuchuParser(..)) import qualified Test.Chuchu.Parsec as P import Test.Chuchu.Email -instance IsString (Parser a) where-  fromString s-    = void (string s)-      >> return-        (error $ "The return value of string parsers should not be used")- -- | Parses a floating point number, with the same syntax as accepted by -- Haskell.-number :: Parser Double-number = nofToDouble <$> P.natFloat+number :: ChuchuParser Double+number = ChuchuParser $ nofToDouble <$> P.natFloat  nofToDouble :: Either Integer Double -> Double nofToDouble (Left i) = fromInteger i nofToDouble (Right d) = d  -- | Parses an integer.-int :: Parser Integer-int = P.int+int :: ChuchuParser Integer+int = ChuchuParser P.int  -- | Parses a quoted string, with the same syntax as accepted by Haskell.-text :: Parser String-text = P.stringLiteral+text :: ChuchuParser String+text = ChuchuParser P.stringLiteral  -- | Parses anything until the string passed as parameter, and also the string.-wildcard :: String -> Parser ()-wildcard = void . manyTill anyChar . string+wildcard :: String -> ChuchuParser ()+wildcard = ChuchuParser . void . manyTill anyChar . string  -- | Parses a simplified e-mail address and return everything that was parsed as -- a simple 'String'.  This is a very simplified parser for e-mail, which does -- not follow RFC5322. Basically, it parses @TEXT\@TEXT@, where TEXT is -- @alphaNum \<|> oneOf \"!#$%&\'*+-\/=?^_\`{|}~.\"@.-email :: Parser String-email = addrSpecSimple+email :: ChuchuParser String+email = ChuchuParser addrSpecSimple
Test/Chuchu/Types.hs view
@@ -5,19 +5,32 @@ -- -- Maintainer  :  Marco Túlio Pimenta Gontijo <marcotmarcot@gmail.com> -- Stability   :  unstable--- Portability :  non-portable (GADTs)+-- Portability :  non-portable (GADTs, GeneralizedNewtypeDeriving) module   Test.Chuchu.Types-  (Chuchu, ChuchuM (Given, When, Then, And, But), runChuchu)+  (ChuchuParser (..), Chuchu, ChuchuM (Given, When, Then, And, But), runChuchu)   where  -- base import Control.Applicative hiding ((<|>))+import GHC.Exts  -- parsec import Text.Parsec import Text.Parsec.Text ++-- | @newtype@ for Parsec's 'Parser' used on this library.  The+-- main reason for not using 'Parser' directly is to be able to+-- define the 'IsString' instance.+newtype ChuchuParser a+  = ChuchuParser (Parser a) deriving (Functor, Applicative, Monad)++instance IsString (ChuchuParser a) where+  fromString s = ChuchuParser (string s >> return err)+    where err = error "fromString: ChuchuParser strings do not return any useful value."++ -- | The most command use case where the return value of the Monad is ignored. type Chuchu m  = ChuchuM m () @@ -26,11 +39,11 @@ -- of them receive a parser and an action to run if the parser finishes -- correctly. data ChuchuM m a where-  Given :: Parser a -> (a -> m ()) -> ChuchuM m ()-  When :: Parser a -> (a -> m ()) -> ChuchuM m ()-  Then :: Parser a -> (a -> m ()) -> ChuchuM m ()-  And :: Parser a -> (a -> m ()) -> ChuchuM m ()-  But :: Parser a -> (a -> m ()) -> ChuchuM m ()+  Given :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()+  When :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()+  Then :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()+  And :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()+  But :: ChuchuParser a -> (a -> m ()) -> ChuchuM m ()   Nil :: ChuchuM m a   Cons :: ChuchuM m b -> ChuchuM m a -> ChuchuM m a @@ -50,5 +63,5 @@ runChuchu (And p f) = apply p f runChuchu (But p f) = apply p f -apply :: Parser a -> (a -> m ()) -> Parser (m ())-apply p f = try $ f <$> p <* eof+apply :: ChuchuParser a -> (a -> m ()) -> Parser (m ())+apply (ChuchuParser p) f = try $ f <$> p <* eof
chuchu.cabal view
@@ -1,5 +1,5 @@ name: chuchu-version: 0.0.0.1+version: 0.1.0.0 cabal-version: >= 1.8 build-type: Simple license: OtherLicense@@ -37,7 +37,7 @@     parsec >= 3.1 && < 3.2,     cmdargs >= 0.9 && < 0.10,     abacate >= 0.0 && < 0.1-  extensions: DeriveDataTypeable, TypeSynonymInstances, FlexibleInstances, GADTs+  extensions: DeriveDataTypeable, GADTs, GeneralizedNewtypeDeriving   ghc-options: -Wall  Test-Suite environment