{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Duckling.AmountOfMoney.EN.NZ.Rules
( rules
) where
import Data.String
import Prelude
import Duckling.AmountOfMoney.Helpers
import Duckling.AmountOfMoney.Types (Currency(..))
import Duckling.Numeral.Helpers (isPositive)
import Duckling.Types
import qualified Duckling.Numeral.Types as TNumeral
ruleAGrand :: Rule
ruleAGrand = Rule
{ name = "a grand"
, pattern =
[ regex "a grand"
]
, prod = \_ -> Just . Token AmountOfMoney . withValue 1000
$ currencyOnly NZD
}
ruleGrand :: Rule
ruleGrand = Rule
{ name = "<amount> grand"
, pattern =
[ Predicate isPositive
, regex "grand"
]
, prod = \case
(Token Numeral TNumeral.NumeralData{TNumeral.value = v}:_)
-> Just . Token AmountOfMoney . withValue (1000 * v)
$ currencyOnly NZD
_ -> Nothing
}
rules :: [Rule]
rules =
[ ruleAGrand
, ruleGrand
]