{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
module Language.REST.MetaTerm where
import Data.String
import Data.Hashable
import GHC.Generics (Generic)
import Language.REST.Op
import Language.REST.RuntimeTerm
data MetaTerm =
Var String
| RWApp Op [MetaTerm] deriving (MetaTerm -> MetaTerm -> Bool
(MetaTerm -> MetaTerm -> Bool)
-> (MetaTerm -> MetaTerm -> Bool) -> Eq MetaTerm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MetaTerm -> MetaTerm -> Bool
== :: MetaTerm -> MetaTerm -> Bool
$c/= :: MetaTerm -> MetaTerm -> Bool
/= :: MetaTerm -> MetaTerm -> Bool
Eq, Eq MetaTerm
Eq MetaTerm =>
(MetaTerm -> MetaTerm -> Ordering)
-> (MetaTerm -> MetaTerm -> Bool)
-> (MetaTerm -> MetaTerm -> Bool)
-> (MetaTerm -> MetaTerm -> Bool)
-> (MetaTerm -> MetaTerm -> Bool)
-> (MetaTerm -> MetaTerm -> MetaTerm)
-> (MetaTerm -> MetaTerm -> MetaTerm)
-> Ord MetaTerm
MetaTerm -> MetaTerm -> Bool
MetaTerm -> MetaTerm -> Ordering
MetaTerm -> MetaTerm -> MetaTerm
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: MetaTerm -> MetaTerm -> Ordering
compare :: MetaTerm -> MetaTerm -> Ordering
$c< :: MetaTerm -> MetaTerm -> Bool
< :: MetaTerm -> MetaTerm -> Bool
$c<= :: MetaTerm -> MetaTerm -> Bool
<= :: MetaTerm -> MetaTerm -> Bool
$c> :: MetaTerm -> MetaTerm -> Bool
> :: MetaTerm -> MetaTerm -> Bool
$c>= :: MetaTerm -> MetaTerm -> Bool
>= :: MetaTerm -> MetaTerm -> Bool
$cmax :: MetaTerm -> MetaTerm -> MetaTerm
max :: MetaTerm -> MetaTerm -> MetaTerm
$cmin :: MetaTerm -> MetaTerm -> MetaTerm
min :: MetaTerm -> MetaTerm -> MetaTerm
Ord, Int -> MetaTerm -> ShowS
[MetaTerm] -> ShowS
MetaTerm -> String
(Int -> MetaTerm -> ShowS)
-> (MetaTerm -> String) -> ([MetaTerm] -> ShowS) -> Show MetaTerm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MetaTerm -> ShowS
showsPrec :: Int -> MetaTerm -> ShowS
$cshow :: MetaTerm -> String
show :: MetaTerm -> String
$cshowList :: [MetaTerm] -> ShowS
showList :: [MetaTerm] -> ShowS
Show, (forall x. MetaTerm -> Rep MetaTerm x)
-> (forall x. Rep MetaTerm x -> MetaTerm) -> Generic MetaTerm
forall x. Rep MetaTerm x -> MetaTerm
forall x. MetaTerm -> Rep MetaTerm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MetaTerm -> Rep MetaTerm x
from :: forall x. MetaTerm -> Rep MetaTerm x
$cto :: forall x. Rep MetaTerm x -> MetaTerm
to :: forall x. Rep MetaTerm x -> MetaTerm
Generic, Eq MetaTerm
Eq MetaTerm =>
(Int -> MetaTerm -> Int) -> (MetaTerm -> Int) -> Hashable MetaTerm
Int -> MetaTerm -> Int
MetaTerm -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> MetaTerm -> Int
hashWithSalt :: Int -> MetaTerm -> Int
$chash :: MetaTerm -> Int
hash :: MetaTerm -> Int
Hashable)
instance IsString MetaTerm where
fromString :: String -> MetaTerm
fromString = String -> MetaTerm
Var
class ToMetaTerm a where
toMetaTerm :: a -> MetaTerm
instance ToMetaTerm MetaTerm where
toMetaTerm :: MetaTerm -> MetaTerm
toMetaTerm = MetaTerm -> MetaTerm
forall a. a -> a
id
instance ToMetaTerm RuntimeTerm where
toMetaTerm :: RuntimeTerm -> MetaTerm
toMetaTerm (App Op
f [RuntimeTerm]
xs) = Op -> [MetaTerm] -> MetaTerm
RWApp Op
f ((RuntimeTerm -> MetaTerm) -> [RuntimeTerm] -> [MetaTerm]
forall a b. (a -> b) -> [a] -> [b]
map RuntimeTerm -> MetaTerm
forall a. ToMetaTerm a => a -> MetaTerm
toMetaTerm [RuntimeTerm]
xs)