-- Copyright (c) 2016-present, Facebook, Inc.
-- All rights reserved.
--
-- This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree.


{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}

module Duckling.Temperature.Rules
  ( rules
  ) where

import Data.String
import Prelude

import Duckling.Dimensions.Types
import Duckling.Temperature.Helpers
import Duckling.Temperature.Types (TemperatureData (..))
import Duckling.Types
import qualified Duckling.Numeral.Types as TNumeral
import qualified Duckling.Temperature.Types as TTemperature

ruleNumeralAsTemp :: Rule
ruleNumeralAsTemp :: Rule
ruleNumeralAsTemp = Rule :: Text -> Pattern -> Production -> Rule
Rule
  { name :: Text
name = Text
"number as temp"
  , pattern :: Pattern
pattern =
    [ Dimension NumeralData -> PatternItem
forall a. Typeable a => Dimension a -> PatternItem
dimension Dimension NumeralData
Numeral
    ]
  , prod :: Production
prod = \case
      (Token Dimension a
Numeral a
nd:[Token]
_) ->
        Token -> Maybe Token
forall a. a -> Maybe a
Just (Token -> Maybe Token)
-> (TemperatureData -> Token) -> TemperatureData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dimension TemperatureData -> TemperatureData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TemperatureData
Temperature (TemperatureData -> Maybe Token) -> TemperatureData -> Maybe Token
forall a b. (a -> b) -> a -> b
$ Double -> TemperatureData
valueOnly (Double -> TemperatureData) -> Double -> TemperatureData
forall a b. (a -> b) -> a -> b
$ NumeralData -> Double
TNumeral.value a
NumeralData
nd
      [Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
  }

rules :: [Rule]
rules :: [Rule]
rules =
  [ Rule
ruleNumeralAsTemp
  ]