{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Text.Haiji.Syntax.Filter
       ( Filter(..)
       , filter
       ) where

#if MIN_VERSION_base(4,8,0)
#else
import Control.Applicative
#endif
import Data.Attoparsec.Text
import Prelude hiding (filter)

-- http://jinja.pocoo.org/docs/dev/templates/#builtin-filters
data Filter = FilterAbs
            | FilterLength
            deriving Filter -> Filter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Filter -> Filter -> Bool
$c/= :: Filter -> Filter -> Bool
== :: Filter -> Filter -> Bool
$c== :: Filter -> Filter -> Bool
Eq
{-
            -- | FilterAttr Identifier
            -- | FilterBatch
            -- | FilterCapitalize
            -- | FilterCenter Int
            -- | FilterDefault
            -- | FilterDictSort
            -- | FilterEscape
            -- | FilterFileSizeFormat
            -- | FilterFirst
            -- | FilterFloat
            -- | FilterForceEscape
            -- | FilterFormat
            -- | FilterGroupBy Variable
            -- | FilterIndent Int Bool
            -- | FilterInt Int Int
            -- | FilterJoin String (Maybe Identifier)
            -- | FilterLast
            -- | FilterList
            -- | FilterLower
            -- | FilterMap
            -- | FilterPprint
            -- | FilterRandom
            -- | FilterReject
            -- | FilterRejectAttr
            -- | FilterReplace
            -- | FilterReverse
            -- | FilterRound
            -- | FilterSafe
            -- | FilterSelect
            -- | FilterSelectAttr
            -- | FilterSlice
            -- | FilterSort
            -- | FilterString
            -- | FilterStripTags
            -- | FilterSum
            -- | FilterTitle
            -- | FilterTrim
            -- | FilterTruncate
            -- | FilterUpper
            -- | FilterURLEncode
            -- | FilterURLize
            -- | FilterWordCount
            -- | FilterWordWrap
            -- | FilterXMLAttr
-}
instance Show Filter where
  show :: Filter -> String
show (Filter
FilterAbs) = String
"|abs"
  show (Filter
FilterLength) = String
"|length"

filter :: Parser Filter
filter :: Parser Filter
filter = Char -> Parser Char
char Char
'|' forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
         Parser Text ()
skipSpace forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
         forall (f :: * -> *) a. Alternative f => [f a] -> f a
choice
         [ Parser Filter
filterAbs
         , Parser Filter
filterLength
         ]

filterAbs :: Parser Filter
filterAbs :: Parser Filter
filterAbs = Text -> Parser Text
string Text
"abs" forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a. Monad m => a -> m a
return Filter
FilterAbs

filterLength :: Parser Filter
filterLength :: Parser Filter
filterLength = Text -> Parser Text
string Text
"length" forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a. Monad m => a -> m a
return Filter
FilterLength