-----------------------------------------------------------------------------
-- Copyright 2019, Advise-Me project team. This file is distributed under 
-- the terms of the Apache License 2.0. For more information, see the files
-- "LICENSE.txt" and "NOTICE.txt", which are included in the distribution.
-----------------------------------------------------------------------------
-- |
-- Maintainer  :  bastiaan.heeren@ou.nl
-- Stability   :  provisional
-- Portability :  portable (depends on ghc)
--
-- This is an important module that "Recognize.Strategy.Derivation" relies on.
-- Here we define the translation from Ideas rule identifiers to our own `RuleId` type.
-- If you want to add new rules in "Recognize.Strategy.Derivation" make sure to also add
-- a new translation here.
--
-----------------------------------------------------------------------------

module Recognize.Data.RuleId where

data RuleId = Collect_Num
  | Collect_Var
  | Times
  | Power
  | Division
  | Distr_Times
  | Distr_Division
  | Coverup_OneVar_Plus
  | Coverup_Times_Positive
  deriving (Eq, Ord)

instance Show RuleId where
  show Collect_Num            = "Collect"
  show Collect_Var            = "Collect"
  show Times                  = "Times"
  show Power                  = "Power"
  show Division               = "Divide"
  show Coverup_OneVar_Plus    = "Coverup.OneVar.Plus"
  show Coverup_Times_Positive = "Coverup.OneVar.Times-Positive"
  show Distr_Times            = "Distribute"
  show Distr_Division         = "Distribute"
  show _ = "Recognize.Data.RuleId: Show not implemented"

matchRuleId :: String -> Maybe RuleId
matchRuleId "algebra.equations.linear.distr-times"     = Just Distr_Times
matchRuleId "linear.merge.num"                         = Just Collect_Num
matchRuleId "linear.merge.var"                         = Just Collect_Var
matchRuleId "algebra.equations.rational.cancel-div"    = Just Division
matchRuleId "algebra.equations.coverup.onevar.plus"    = Just Coverup_OneVar_Plus
matchRuleId "algebra.equations.coverup.times-positive" = Just Coverup_Times_Positive
matchRuleId "algebra.manipulation.simpler-fraction"    = Just Division
matchRuleId "arithmetic.operation.rational.times"      = Just Times
matchRuleId "arithmetic.operation.rational.power"      = Just Power
matchRuleId "distr-division"                           = Just Distr_Division
matchRuleId _ = Nothing