{-# OPTIONS -w -O0 #-}
{-# LANGUAGE CPP, StandaloneDeriving, DeriveDataTypeable, DeriveGeneric #-}
{- |
Module      :  COL/ATC_COL.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):
'COL.AS_COL.COL_SIG_ITEM'
'COL.COLSign.COLSign'
-}

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

module COL.ATC_COL () where

import ATerm.Lib
import CASL.AS_Basic_CASL
import CASL.ATC_CASL
import COL.AS_COL
import COL.COLSign
import Common.AS_Annotation
import Common.Id
import Common.Json.Instances
import Data.Aeson(ToJSON, FromJSON)
import Data.Data
import GHC.Generics(Generic)
import qualified Data.Map as Map
import qualified Data.Set as Set

{-! for COL.AS_COL.COL_SIG_ITEM derive : ShATermConvertible !-}
{-! for COL.COLSign.COLSign derive : ShATermConvertible !-}

{-! for COL.AS_COL.COL_SIG_ITEM derive : Json !-}
{-! for COL.COLSign.COLSign derive : Json !-}

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

instance ShATermConvertible COL.AS_COL.COL_SIG_ITEM where
  toShATermAux :: ATermTable -> COL_SIG_ITEM -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: COL_SIG_ITEM
xv = case COL_SIG_ITEM
xv of
    Constructor_items a :: [Annoted Id]
a b :: Range
b -> do
      (att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> [Annoted Id] -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 [Annoted Id]
a
      (att2 :: ATermTable
att2, b' :: Int
b') <- ATermTable -> Range -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att1 Range
b
      (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 "Constructor_items" [Int
a', Int
b'] []) ATermTable
att2
    Observer_items a :: [Annoted (Id, Maybe Int)]
a b :: Range
b -> do
      (att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> [Annoted (Id, Maybe Int)] -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 [Annoted (Id, Maybe Int)]
a
      (att2 :: ATermTable
att2, b' :: Int
b') <- ATermTable -> Range -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att1 Range
b
      (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 "Observer_items" [Int
a', Int
b'] []) ATermTable
att2
  fromShATermAux :: Int -> ATermTable -> (ATermTable, COL_SIG_ITEM)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
    ShAAppl "Constructor_items" [a :: Int
a, b :: Int
b] _ ->
      case Int -> ATermTable -> (ATermTable, [Annoted Id])
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
      { (att1 :: ATermTable
att1, a' :: [Annoted Id]
a') ->
      case Int -> ATermTable -> (ATermTable, Range)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
b ATermTable
att1 of
      { (att2 :: ATermTable
att2, b' :: Range
b') ->
      (ATermTable
att2, [Annoted Id] -> Range -> COL_SIG_ITEM
Constructor_items [Annoted Id]
a' Range
b') }}
    ShAAppl "Observer_items" [a :: Int
a, b :: Int
b] _ ->
      case Int -> ATermTable -> (ATermTable, [Annoted (Id, Maybe Int)])
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
      { (att1 :: ATermTable
att1, a' :: [Annoted (Id, Maybe Int)]
a') ->
      case Int -> ATermTable -> (ATermTable, Range)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
b ATermTable
att1 of
      { (att2 :: ATermTable
att2, b' :: Range
b') ->
      (ATermTable
att2, [Annoted (Id, Maybe Int)] -> Range -> COL_SIG_ITEM
Observer_items [Annoted (Id, Maybe Int)]
a' Range
b') }}
    u :: ShATerm
u -> String -> ShATerm -> (ATermTable, COL_SIG_ITEM)
forall a. String -> ShATerm -> a
fromShATermError "COL.AS_COL.COL_SIG_ITEM" ShATerm
u

deriving instance GHC.Generics.Generic COL.AS_COL.COL_SIG_ITEM
instance Data.Aeson.ToJSON COL.AS_COL.COL_SIG_ITEM where
instance Data.Aeson.FromJSON COL.AS_COL.COL_SIG_ITEM where

deriving instance GHC.Generics.Generic COL.COLSign.COLSign
instance Data.Aeson.ToJSON COL.COLSign.COLSign where
instance Data.Aeson.FromJSON COL.COLSign.COLSign where

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