module Duckling.Duration.Rules
( rules
) where
import Prelude
import Data.String
import Duckling.Dimensions.Types
import Duckling.Duration.Helpers
import Duckling.Numeral.Types (NumeralData(..))
import qualified Duckling.Numeral.Types as TNumeral
import Duckling.Types
ruleIntegerUnitofduration :: Rule
ruleIntegerUnitofduration = Rule
{ name = "<integer> <unit-of-duration>"
, pattern =
[ Predicate isNatural
, dimension TimeGrain
]
, prod = \tokens -> case tokens of
(Token Numeral (NumeralData {TNumeral.value = v}):
Token TimeGrain grain:
_) -> Just . Token Duration . duration grain $ floor v
_ -> Nothing
}
rules :: [Rule]
rules =
[ ruleIntegerUnitofduration
]