{-# OPTIONS -w -O0 #-}
{- |
Module      :  TopHybrid/ATC_TopHybrid.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):
'TopHybrid.AS_TopHybrid.TH_BSPEC'
'TopHybrid.AS_TopHybrid.TH_BASIC_ITEM'
'TopHybrid.AS_TopHybrid.TH_FORMULA'
'TopHybrid.AS_TopHybrid.Mor'
'TopHybrid.TopHybridSign.THybridSign'
-}

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

module TopHybrid.ATC_TopHybrid () where

import ATC.AS_Annotation
import ATerm.Lib
import Common.AS_Annotation
import Common.Id
import Common.Json
import Common.Result
import Common.ToXml
import Control.Monad (liftM)
import Data.Data
import Data.Monoid ()
import Data.Set
import Logic.Logic
import Text.XML.Light
import TopHybrid.AS_TopHybrid
import TopHybrid.TopHybridSign
import Unsafe.Coerce

{-! for TopHybrid.AS_TopHybrid.TH_BSPEC derive : ShATermConvertible !-}
{-! for TopHybrid.AS_TopHybrid.TH_BASIC_ITEM derive : ShATermConvertible !-}
{-! for TopHybrid.AS_TopHybrid.TH_FORMULA derive : ShATermConvertible !-}
{-! for TopHybrid.AS_TopHybrid.Mor derive : ShATermConvertible !-}
{-! for TopHybrid.TopHybridSign.THybridSign derive : ShATermConvertible !-}

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

instance ShATermConvertible Mor where
  toShATermAux att0 xv = case xv of
    Mor -> return $ addATerm (ShAAppl "Mor" [] []) att0
  fromShATermAux ix att0 = case getShATerm ix att0 of
    ShAAppl "Mor" [] _ -> (att0, Mor)
    u -> fromShATermError "Mor" u

instance ShATermConvertible f => ShATermConvertible (TH_FORMULA f) where
  toShATermAux att0 xv = case xv of
    At a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "At" [a', b'] []) att2
    Uni a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Uni" [a', b'] []) att2
    Exist a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Exist" [a', b'] []) att2
    Box a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Box" [a', b'] []) att2
    Dia a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Dia" [a', b'] []) att2
    UnderLogic a -> do
      (att1, a') <- toShATerm' att0 a
      return $ addATerm (ShAAppl "UnderLogic" [a'] []) att1
    Conjunction a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Conjunction" [a', b'] []) att2
    Disjunction a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Disjunction" [a', b'] []) att2
    Implication a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Implication" [a', b'] []) att2
    BiImplication a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "BiImplication" [a', b'] []) att2
    Here a -> do
      (att1, a') <- toShATerm' att0 a
      return $ addATerm (ShAAppl "Here" [a'] []) att1
    Neg a -> do
      (att1, a') <- toShATerm' att0 a
      return $ addATerm (ShAAppl "Neg" [a'] []) att1
    Par a -> do
      (att1, a') <- toShATerm' att0 a
      return $ addATerm (ShAAppl "Par" [a'] []) att1
    TrueA -> return $ addATerm (ShAAppl "TrueA" [] []) att0
    FalseA -> return $ addATerm (ShAAppl "FalseA" [] []) att0
  fromShATermAux ix att0 = case getShATerm ix att0 of
    ShAAppl "At" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, At a' b') }}
    ShAAppl "Uni" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Uni a' b') }}
    ShAAppl "Exist" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Exist a' b') }}
    ShAAppl "Box" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Box a' b') }}
    ShAAppl "Dia" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Dia a' b') }}
    ShAAppl "UnderLogic" [a] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      (att1, UnderLogic a') }
    ShAAppl "Conjunction" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Conjunction a' b') }}
    ShAAppl "Disjunction" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Disjunction a' b') }}
    ShAAppl "Implication" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Implication a' b') }}
    ShAAppl "BiImplication" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, BiImplication a' b') }}
    ShAAppl "Here" [a] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      (att1, Here a') }
    ShAAppl "Neg" [a] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      (att1, Neg a') }
    ShAAppl "Par" [a] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      (att1, Par a') }
    ShAAppl "TrueA" [] _ -> (att0, TrueA)
    ShAAppl "FalseA" [] _ -> (att0, FalseA)
    u -> fromShATermError "TH_FORMULA" u

instance ShATermConvertible TH_BASIC_ITEM where
  toShATermAux att0 xv = case xv of
    Simple_mod_decl a -> do
      (att1, a') <- toShATerm' att0 a
      return $ addATerm (ShAAppl "Simple_mod_decl" [a'] []) att1
    Simple_nom_decl a -> do
      (att1, a') <- toShATerm' att0 a
      return $ addATerm (ShAAppl "Simple_nom_decl" [a'] []) att1
  fromShATermAux ix att0 = case getShATerm ix att0 of
    ShAAppl "Simple_mod_decl" [a] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      (att1, Simple_mod_decl a') }
    ShAAppl "Simple_nom_decl" [a] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      (att1, Simple_nom_decl a') }
    u -> fromShATermError "TH_BASIC_ITEM" u

instance ShATermConvertible s => ShATermConvertible (TH_BSPEC s) where
  toShATermAux att0 xv = case xv of
    Bspec a b -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      return $ addATerm (ShAAppl "Bspec" [a', b'] []) att2
  fromShATermAux ix att0 = case getShATerm ix att0 of
    ShAAppl "Bspec" [a, b] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      (att2, Bspec a' b') }}
    u -> fromShATermError "TH_BSPEC" u

instance ShATermConvertible s => ShATermConvertible (THybridSign s) where
  toShATermAux att0 xv = case xv of
    THybridSign a b c -> do
      (att1, a') <- toShATerm' att0 a
      (att2, b') <- toShATerm' att1 b
      (att3, c') <- toShATerm' att2 c
      return $ addATerm (ShAAppl "THybridSign" [a', b', c'] []) att3
  fromShATermAux ix att0 = case getShATerm ix att0 of
    ShAAppl "THybridSign" [a, b, c] _ ->
      case fromShATerm' a att0 of
      { (att1, a') ->
      case fromShATerm' b att1 of
      { (att2, b') ->
      case fromShATerm' c att2 of
      { (att3, c') ->
      (att3, THybridSign a' b' c') }}}
    u -> fromShATermError "THybridSign" u