Skip to content

Commit

Permalink
Removed unnecessary imports. Fixing imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Oct 2, 2015
1 parent 5a7c8b0 commit 0bac8ba
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion mustache.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 1 addition & 5 deletions src/lib/Text/Mustache/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ module Text.Mustache.Compile
) where


import Control.Applicative
import Control.Arrow ((&&&))
import Control.Monad
import Control.Monad.Except
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
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Text/Mustache/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 8 additions & 10 deletions src/lib/Text/Mustache/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -249,25 +247,25 @@ 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
<$> (try (char partialBegin) spaces (noneOf (nub end) `manyTill` try (spaces string end)))
, 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
Expand All @@ -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) }
Expand All @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions src/lib/Text/Mustache/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/lib/Text/Mustache/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/unit/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,6 +68,10 @@ instance FromJSON LangSpecTest where
parseJSON _ = mzero


(&) a (a b) b
(&) = flip ($)


parserSpec :: Spec
parserSpec =
describe "mustacheParser" $ do
Expand Down

0 comments on commit 0bac8ba

Please sign in to comment.