{-# OPTIONS -w -O0 #-}
{-# LANGUAGE CPP, StandaloneDeriving, DeriveDataTypeable, DeriveGeneric #-}
{- |
Module      :  ATC/ProofTree.der.hs
Description :  generated ShATermConvertible, Json instances
Copyright   :  (c) DFKI GmbH 2012
License     :  GPLv2 or higher, see LICENSE.txt

Maintainer  :  Christian.Maeder@dfki.de
Stability   :  provisional
Portability :  non-portable(derive Typeable instances)

Automatic derivation of instances via DrIFT-rule ShATermConvertible, Json
  for the type(s):
'Common.ProofTree.ProofTree'
-}

{-
Generated by 'genRules' (automatic rule generation for DrIFT). Don't touch!!
  dependency files:
Common/ProofTree.hs
-}

module ATC.ProofTree () where

import ATerm.Lib
import Common.Json.Instances
import Common.ProofTree
import Data.Aeson(ToJSON, FromJSON)
import Data.Data
import Data.Graph.Inductive.Graph
import Data.Graph.Inductive.PatriciaTree (Gr)
import Data.List (intercalate)
import GHC.Generics(Generic)
import Text.Printf

{-! for Common.ProofTree.ProofTree derive : ShATermConvertible !-}

{-! for Common.ProofTree.ProofTree derive : Json !-}

-- Generated by DrIFT, look but don't touch!

deriving instance GHC.Generics.Generic Common.ProofTree.ProofTree
instance Data.Aeson.ToJSON Common.ProofTree.ProofTree where
instance Data.Aeson.FromJSON Common.ProofTree.ProofTree where

instance ShATermConvertible Common.ProofTree.ProofTree where
  toShATermAux :: ATermTable -> ProofTree -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: ProofTree
xv = case ProofTree
xv of
    ProofTree a :: String
a -> do
      (att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> String -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 String
a
      (ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "ProofTree" [Int
a'] []) ATermTable
att1
    ProofGraph a :: Gr ProofGraphNode Int
a -> do
      (att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> Gr ProofGraphNode Int -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 Gr ProofGraphNode Int
a
      (ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "ProofGraph" [Int
a'] []) ATermTable
att1
  fromShATermAux :: Int -> ATermTable -> (ATermTable, ProofTree)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
    ShAAppl "ProofTree" [a :: Int
a] _ ->
      case Int -> ATermTable -> (ATermTable, String)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
      { (att1 :: ATermTable
att1, a' :: String
a') ->
      (ATermTable
att1, String -> ProofTree
ProofTree String
a') }
    ShAAppl "ProofGraph" [a :: Int
a] _ ->
      case Int -> ATermTable -> (ATermTable, Gr ProofGraphNode Int)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
      { (att1 :: ATermTable
att1, a' :: Gr ProofGraphNode Int
a') ->
      (ATermTable
att1, Gr ProofGraphNode Int -> ProofTree
ProofGraph Gr ProofGraphNode Int
a') }
    u :: ShATerm
u -> String -> ShATerm -> (ATermTable, ProofTree)
forall a. String -> ShATerm -> a
fromShATermError "Common.ProofTree.ProofTree" ShATerm
u