{-# OPTIONS -w -O0 #-}
{- |
Module      :  ATC/Graph.der.hs
Description :  generated ShATermConvertible 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
  for the type(s):
'Common.Lib.Graph.Gr'
'Common.Lib.Graph.GrContext'
-}

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

module ATC.Graph () where

import ATerm.Lib
import Common.Lib.Graph
import Data.Data
import Data.Graph.Inductive.Graph as Graph
import Data.List
import qualified Data.IntMap as Map

{-! for Common.Lib.Graph.Gr derive : ShATermConvertible !-}
{-! for Common.Lib.Graph.GrContext derive : ShATermConvertible !-}

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

instance (ShATermConvertible a,
          ShATermConvertible b) => ShATermConvertible (Gr a b) where
  toShATermAux :: ATermTable -> Gr a b -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: Gr a b
xv = case Gr a b
xv of
    Gr a :: IntMap (GrContext a b)
a -> do
      (att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> IntMap (GrContext a b) -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 IntMap (GrContext a b)
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 "Gr" [Int
a'] []) ATermTable
att1
  fromShATermAux :: Int -> ATermTable -> (ATermTable, Gr a b)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
    ShAAppl "Gr" [a :: Int
a] _ ->
      case Int -> ATermTable -> (ATermTable, IntMap (GrContext a b))
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
      { (att1 :: ATermTable
att1, a' :: IntMap (GrContext a b)
a') ->
      (ATermTable
att1, IntMap (GrContext a b) -> Gr a b
forall a b. IntMap (GrContext a b) -> Gr a b
Gr IntMap (GrContext a b)
a') }
    u :: ShATerm
u -> String -> ShATerm -> (ATermTable, Gr a b)
forall a. String -> ShATerm -> a
fromShATermError "Gr" ShATerm
u

instance (ShATermConvertible a,
          ShATermConvertible b) => ShATermConvertible (GrContext a b) where
  toShATermAux :: ATermTable -> GrContext a b -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: GrContext a b
xv = case GrContext a b
xv of
    GrContext a :: a
a b :: IntMap [b]
b c :: [b]
c d :: IntMap [b]
d -> do
      (att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> a -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 a
a
      (att2 :: ATermTable
att2, b' :: Int
b') <- ATermTable -> IntMap [b] -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att1 IntMap [b]
b
      (att3 :: ATermTable
att3, c' :: Int
c') <- ATermTable -> [b] -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att2 [b]
c
      (att4 :: ATermTable
att4, d' :: Int
d') <- ATermTable -> IntMap [b] -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att3 IntMap [b]
d
      (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 "GrContext" [Int
a', Int
b', Int
c', Int
d'] []) ATermTable
att4
  fromShATermAux :: Int -> ATermTable -> (ATermTable, GrContext a b)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
    ShAAppl "GrContext" [a :: Int
a, b :: Int
b, c :: Int
c, d :: Int
d] _ ->
      case Int -> ATermTable -> (ATermTable, a)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
      { (att1 :: ATermTable
att1, a' :: a
a') ->
      case Int -> ATermTable -> (ATermTable, IntMap [b])
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
b ATermTable
att1 of
      { (att2 :: ATermTable
att2, b' :: IntMap [b]
b') ->
      case Int -> ATermTable -> (ATermTable, [b])
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
c ATermTable
att2 of
      { (att3 :: ATermTable
att3, c' :: [b]
c') ->
      case Int -> ATermTable -> (ATermTable, IntMap [b])
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
d ATermTable
att3 of
      { (att4 :: ATermTable
att4, d' :: IntMap [b]
d') ->
      (ATermTable
att4, a -> IntMap [b] -> [b] -> IntMap [b] -> GrContext a b
forall a b. a -> IntMap [b] -> [b] -> IntMap [b] -> GrContext a b
GrContext a
a' IntMap [b]
b' [b]
c' IntMap [b]
d') }}}}
    u :: ShATerm
u -> String -> ShATerm -> (ATermTable, GrContext a b)
forall a. String -> ShATerm -> a
fromShATermError "GrContext" ShATerm
u