{-# LANGUAGE GADTs #-}
module Duckling.Ordinal.Helpers
( ordinal
, oneOf
) where
import Prelude
import Duckling.Dimensions.Types
import Duckling.Ordinal.Types (OrdinalData (..))
import Duckling.Types
import qualified Duckling.Ordinal.Types as TOrdinal
oneOf :: [Int] -> PatternItem
oneOf :: [Int] -> PatternItem
oneOf [Int]
vs = Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ \Token
x ->
case Token
x of
(Token Dimension a
Ordinal OrdinalData {TOrdinal.value = v}) -> Int -> [Int] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem Int
v [Int]
vs
Token
_ -> Bool
False
ordinal :: Int -> Token
ordinal :: Int -> Token
ordinal Int
x = Dimension OrdinalData -> OrdinalData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension OrdinalData
Ordinal OrdinalData :: Int -> OrdinalData
OrdinalData {value :: Int
TOrdinal.value = Int
x}