{-# LANGUAGE TypeSynonymInstances
           , FlexibleInstances
           , FlexibleContexts
           , DeriveDataTypeable
           , CPP
           , GADTs
           , DataKinds
           , OverloadedStrings
           , ScopedTypeVariables
           , TypeOperators
           , RecordWildCards
           #-}

{-# OPTIONS_GHC -Wall -fwarn-tabs #-}
----------------------------------------------------------------
--                                                    2016.04.28
-- |
-- Module      :  Language.Hakaru.Simplify
-- Copyright   :  Copyright (c) 2016 the Hakaru team
-- License     :  BSD3
-- Maintainer  :  wren@community.haskell.org
-- Stability   :  experimental
-- Portability :  GHC-only
--
-- Take strings from Maple and interpret them in Haskell (Hakaru)
----------------------------------------------------------------
module Language.Hakaru.Simplify
    ( simplify, simplifyWithOpts
    , simplify'
    , simplifyDebug
    ) where

import Language.Hakaru.Syntax.ABT
import Language.Hakaru.Syntax.AST
import Language.Hakaru.Maple 
import Language.Hakaru.Syntax.TypeCheck

----------------------------------------------------------------

simplify
    :: forall abt a
    .  (ABT Term abt) 
    => abt '[] a -> IO (abt '[] a)
simplify :: abt '[] a -> IO (abt '[] a)
simplify = MapleOptions () -> abt '[] a -> IO (abt '[] a)
forall (abt :: [Hakaru] -> Hakaru -> *) (a :: Hakaru).
ABT Term abt =>
MapleOptions () -> abt '[] a -> IO (abt '[] a)
simplifyWithOpts MapleOptions ()
defaultMapleOptions

simplifyWithOpts
    :: forall abt a
    .  (ABT Term abt) 
    => MapleOptions () -> abt '[] a -> IO (abt '[] a)
simplifyWithOpts :: MapleOptions () -> abt '[] a -> IO (abt '[] a)
simplifyWithOpts MapleOptions ()
o = MapleOptions (MapleCommand a a) -> abt '[] a -> IO (abt '[] a)
forall (abt :: [Hakaru] -> Hakaru -> *) (i :: Hakaru)
       (o :: Hakaru).
ABT Term abt =>
MapleOptions (MapleCommand i o) -> abt '[] i -> IO (abt '[] o)
sendToMaple MapleOptions ()
o{command :: MapleCommand a a
command=Transform '[ '( '[], a)] a -> MapleCommand a a
forall (i :: Hakaru) (o :: Hakaru).
Transform '[ '( '[], i)] o -> MapleCommand i o
MapleCommand Transform '[ '( '[], a)] a
forall (a :: Hakaru). Transform '[LC a] a
Simplify}

simplify'
    :: forall abt
    .  (ABT Term (abt Term)) 
    => TypedAST (abt Term)  -> IO (TypedAST (abt Term))
simplify' :: TypedAST (abt Term) -> IO (TypedAST (abt Term))
simplify' = MapleOptions String
-> TypedAST (abt Term) -> IO (TypedAST (abt Term))
forall (abt :: (([Hakaru] -> Hakaru -> *) -> Hakaru -> *)
               -> [Hakaru] -> Hakaru -> *).
ABT Term (abt Term) =>
MapleOptions String
-> TypedAST (abt Term) -> IO (TypedAST (abt Term))
sendToMaple' MapleOptions ()
defaultMapleOptions{command :: String
command=String
"Simplify"}

simplifyDebug
    :: forall abt a
    .  (ABT Term abt) 
    => Bool
    -> Int
    -> abt '[] a
    -> IO (abt '[] a)
simplifyDebug :: Bool -> Int -> abt '[] a -> IO (abt '[] a)
simplifyDebug Bool
d Int
t = MapleOptions (MapleCommand a a) -> abt '[] a -> IO (abt '[] a)
forall (abt :: [Hakaru] -> Hakaru -> *) (i :: Hakaru)
       (o :: Hakaru).
ABT Term abt =>
MapleOptions (MapleCommand i o) -> abt '[] i -> IO (abt '[] o)
sendToMaple
  MapleOptions ()
defaultMapleOptions{command :: MapleCommand a a
command=Transform '[ '( '[], a)] a -> MapleCommand a a
forall (i :: Hakaru) (o :: Hakaru).
Transform '[ '( '[], i)] o -> MapleCommand i o
MapleCommand Transform '[ '( '[], a)] a
forall (a :: Hakaru). Transform '[LC a] a
Simplify,
                      debug :: Bool
debug=Bool
d,timelimit :: Int
timelimit=Int
t}

----------------------------------------------------------------
----------------------------------------------------------- fin.