diff --git a/mustache.cabal b/mustache.cabal index 2ec97f5..e79c71c 100644 --- a/mustache.cabal +++ b/mustache.cabal @@ -1,5 +1,5 @@ name: mustache -version: 0.1.0.0 +version: 0.2.0.0 synopsis: A mustache template parser library. description: Allows parsing and rendering template files with mustache markup. See the diff --git a/src/lib/Text/Mustache/Compile.hs b/src/lib/Text/Mustache/Compile.hs index 5207d0a..0788745 100644 --- a/src/lib/Text/Mustache/Compile.hs +++ b/src/lib/Text/Mustache/Compile.hs @@ -5,7 +5,6 @@ module Text.Mustache.Compile ) where -import Control.Applicative import Control.Arrow ((&&&)) import Control.Monad import Control.Monad.Except @@ -13,12 +12,9 @@ import Control.Monad.State import Control.Monad.Trans.Either import Control.Monad.Unicode import Data.Bool -import Data.Foldable (fold) import Data.Function.JAExtra import Data.HashMap.Strict as HM -import Data.List -import Data.Monoid -import Data.Monoid.Unicode +import Data.Monoid.Unicode ((⊕), (∅)) import Data.Text hiding (concat, find, map, uncons) import qualified Data.Text.IO as TIO import Prelude.Unicode diff --git a/src/lib/Text/Mustache/Internal.hs b/src/lib/Text/Mustache/Internal.hs index 663ced8..bbd0906 100644 --- a/src/lib/Text/Mustache/Internal.hs +++ b/src/lib/Text/Mustache/Internal.hs @@ -4,9 +4,9 @@ module Text.Mustache.Internal (uncons) where #if MIN_VERSION_base(4,8,0) - import Data.List (uncons) +import Data.List (uncons) #else - uncons ∷ [a] → Maybe (a, [a]) - uncons [] = Nothing - uncons (x:xs) = return (x, xs) +uncons ∷ [a] → Maybe (a, [a]) +uncons [] = Nothing +uncons (x:xs) = return (x, xs) #endif diff --git a/src/lib/Text/Mustache/Parser.hs b/src/lib/Text/Mustache/Parser.hs index a03f702..a532508 100644 --- a/src/lib/Text/Mustache/Parser.hs +++ b/src/lib/Text/Mustache/Parser.hs @@ -36,11 +36,9 @@ import Control.Monad.Unicode import Conversion (Conversion, convert) import Conversion.Text () import Data.Char (isAlphaNum, isSpace) -import Data.Foldable (fold) import Data.Functor ((<$>)) import Data.List (nub) -import Data.Monoid (mempty, (<>)) -import Data.Monoid.Unicode +import Data.Monoid.Unicode ((∅), (⊕)) import Data.Text as T (Text, null, pack) import Prelude as Prel import Prelude.Unicode @@ -249,11 +247,11 @@ switchOnTag = do (MustacheState { sDelimiters = ( _, end )}) ← getState choice - [ SectionBegin False <$> (try (char sectionBegin) ≫ genParseTagEnd mempty) + [ SectionBegin False <$> (try (char sectionBegin) ≫ genParseTagEnd (∅)) , SectionEnd - <$> (try (char sectionEnd) ≫ genParseTagEnd mempty) + <$> (try (char sectionEnd) ≫ genParseTagEnd (∅)) , Tag ∘ Variable False - <$> (try (char unescape1) ≫ genParseTagEnd mempty) + <$> (try (char unescape1) ≫ genParseTagEnd (∅)) , Tag ∘ Variable False <$> (try (char (fst unescape2)) ≫ genParseTagEnd (return $ snd unescape2)) , Tag ∘ Partial Nothing @@ -261,13 +259,13 @@ switchOnTag = do , return HandledTag << (try (char delimiterChange) ≫ parseDelimChange) , SectionBegin True - <$> (try (char invertedSectionBegin) ≫ genParseTagEnd mempty ≫= \case + <$> (try (char invertedSectionBegin) ≫ genParseTagEnd (∅) ≫= \case n@(NamedData _) → return n _ → parserFail "Inverted Sections can not be implicit." ) , return HandledTag << (try (char comment) ≫ manyTill anyChar (try $ string end)) , Tag . Variable True - <$> genParseTagEnd mempty + <$> genParseTagEnd (∅) ] where parseDelimChange = do @@ -276,7 +274,7 @@ switchOnTag = do delim1 ← allowedDelimiterCharacter `manyTill` space spaces delim2 ← allowedDelimiterCharacter `manyTill` try (spaces ≫ string (delimiterChange : end)) - when (delim1 ≡ mempty ∨ delim2 ≡ (∅)) + when (delim1 ≡ (∅) ∨ delim2 ≡ (∅)) $ parserFail "Tags must contain more than 0 characters" oldState ← getState putState $ oldState { sDelimiters = (delim1, delim2) } @@ -298,7 +296,7 @@ genParseTagEnd emod = do <|> try (void $ char nestingSeparator)) others ← (char nestingSeparator ≫ parseOne) - <|> (const mempty <$> (spaces ≫ string nEnd)) + <|> (const (∅) <$> (spaces ≫ string nEnd)) return $ pack one : others spaces (try (char implicitIterator) ≫ spaces ≫ string nEnd ≫ return Implicit) diff --git a/src/lib/Text/Mustache/Render.hs b/src/lib/Text/Mustache/Render.hs index b7d44c2..81c20ce 100644 --- a/src/lib/Text/Mustache/Render.hs +++ b/src/lib/Text/Mustache/Render.hs @@ -24,14 +24,13 @@ import Control.Applicative ((<$>), (<|>)) import Control.Arrow (first) import Control.Monad import Control.Monad.Unicode -import Data.Foldable (find, fold) +import Data.Foldable (fold) import Data.HashMap.Strict as HM hiding (map) import Data.Maybe (fromMaybe) import Data.Monoid.Unicode import Data.Scientific (floatingOrInteger) -import Data.Text as T (Text, dropEnd, isSuffixOf, length, - null, pack, replace, stripSuffix) -import Data.Traversable (traverse) +import Data.Text as T (Text, isSuffixOf, null, pack, + replace, stripSuffix) import qualified Data.Vector as V import Prelude hiding (length, lines, unlines) import Prelude.Unicode diff --git a/src/lib/Text/Mustache/Types.hs b/src/lib/Text/Mustache/Types.hs index 20334e4..a494b73 100644 --- a/src/lib/Text/Mustache/Types.hs +++ b/src/lib/Text/Mustache/Types.hs @@ -34,7 +34,6 @@ module Text.Mustache.Types import Conversion import Conversion.Text () import qualified Data.Aeson as Aeson -import Data.Functor ((<$>)) import Data.HashMap.Strict as HM import Data.Scientific import Data.Text diff --git a/test/unit/Spec.hs b/test/unit/Spec.hs index 8e4b4b6..7ccd29b 100644 --- a/test/unit/Spec.hs +++ b/test/unit/Spec.hs @@ -10,7 +10,6 @@ import Control.Applicative ((<$>), (<*>)) import Control.Monad import Data.Either import Data.Foldable (for_) -import Data.Function ((&)) import qualified Data.HashMap.Strict as HM (HashMap, elems, empty, lookup, traverseWithKey) import Data.List @@ -69,6 +68,10 @@ instance FromJSON LangSpecTest where parseJSON _ = mzero +(&) ∷ a → (a → b) → b +(&) = flip ($) + + parserSpec :: Spec parserSpec = describe "mustacheParser" $ do