{-# LINE 1 "src/Clingo/Raw/AST.hsc" #-}
{-# OPTIONS_GHC -Wno-missing-pattern-synonym-signatures #-}
{-# LINE 2 "src/Clingo/Raw/AST.hsc" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Clingo.Raw.AST
(
    -- * Enumerations
    AstComparisonOperator,

    pattern AstComparisonOperatorGreaterThan,
    pattern AstComparisonOperatorLessThan,
    pattern AstComparisonOperatorLessEqual,
    pattern AstComparisonOperatorGreaterEqual,
    pattern AstComparisonOperatorNotEqual,
    pattern AstComparisonOperatorEqual,

    AstSign,

    pattern AstSignNone,
    pattern AstSignNegation,
    pattern AstSignDoubleNegation,

    AstTermType,

    pattern AstTermTypeSymbol,
    pattern AstTermTypeVariable,
    pattern AstTermTypeUnaryOperation,
    pattern AstTermTypeBinaryOperation,
    pattern AstTermTypeInterval,
    pattern AstTermTypeFunction,
    pattern AstTermTypeExternalFunction,
    pattern AstTermTypePool,

    AstUnaryOperator,

    pattern AstUnaryOperatorMinus,
    pattern AstUnaryOperatorNegation,
    pattern AstUnaryOperatorAbsolute,

    AstBinaryOperator,

    pattern AstBinaryOperatorXor,
    pattern AstBinaryOperatorOr,
    pattern AstBinaryOperatorAnd,
    pattern AstBinaryOperatorPlus,
    pattern AstBinaryOperatorMinus,
    pattern AstBinaryOperatorMultiplication,
    pattern AstBinaryOperatorDivision,
    pattern AstBinaryOperatorModulo,

    AstLiteralType,

    pattern AstLiteralTypeBoolean,
    pattern AstLiteralTypeSymbolic,
    pattern AstLiteralTypeComparison,
    pattern AstLiteralTypeCsp,

    AstAggregateFunction,

    pattern AstAggregateFunctionCount,
    pattern AstAggregateFunctionSum,
    pattern AstAggregateFunctionSump,
    pattern AstAggregateFunctionMin,
    pattern AstAggregateFunctionMax,

    AstTheoryTermType,

    pattern AstTheoryTermTypeSymbol,
    pattern AstTheoryTermTypeVariable,
    pattern AstTheoryTermTypeTuple,
    pattern AstTheoryTermTypeList,
    pattern AstTheoryTermTypeSet,
    pattern AstTheoryTermTypeFunction,
    pattern AstTheoryTermTypeUnparsedTerm,

    AstHeadLiteralType,

    pattern AstHeadLiteralTypeLiteral,
    pattern AstHeadLiteralTypeDisjunction,
    pattern AstHeadLiteralTypeAggregate,
    pattern AstHeadLiteralTypeHeadAggregate,
    pattern AstHeadLiteralTypeTheoryAtom,

    AstBodyLiteralType,

    pattern AstBodyLiteralTypeLiteral,
    pattern AstBodyLiteralTypeConditional,
    pattern AstBodyLiteralTypeAggregate,
    pattern AstBodyLiteralTypeBodyAggregate,
    pattern AstBodyLiteralTypeTheoryAtom,
    pattern AstBodyLiteralTypeDisjoint,

    AstTheoryOperatorType,

    pattern AstTheoryOperatorTypeUnary,
    pattern AstTheoryOperatorTypeBinaryLeft,
    pattern AstTheoryOperatorTypeBinaryRight,

    AstTheoryAtomDefType,

    pattern AstTheoryAtomDefinitionTypeHead,
    pattern AstTheoryAtomDefinitionTypeBody,
    pattern AstTheoryAtomDefinitionTypeAny,
    pattern AstTheoryAtomDefinitionTypeDirective,

    AstScriptType,

    pattern AstScriptTypeLua,
    pattern AstScriptTypePython,

    AstStatementType,

    pattern AstStatementTypeRule,
    pattern AstStatementTypeConst,
    pattern AstStatementTypeShowSignature,
    pattern AstStatementTypeShowTerm,
    pattern AstStatementTypeMinimize,
    pattern AstStatementTypeScript,
    pattern AstStatementTypeProgram,
    pattern AstStatementTypeExternal,
    pattern AstStatementTypeEdge,
    pattern AstStatementTypeHeuristic,
    pattern AstStatementTypeProjectAtom,
    pattern AstStatementTypeProjectAtomSignature,
    pattern AstStatementTypeTheoryDefinition,

    -- * Syntax Tree Definitions
    AstUnaryOperation (..),
    AstBinaryOperation (..),
    AstInterval (..),
    AstFunction (..),
    AstPool (..),
    AstTerm (..),
    AstCspProductTerm (..),
    AstCspSumTerm (..),
    AstCspGuard (..),
    AstCspLiteral (..),
    AstId (..),
    AstComparison (..),
    AstLiteral (..),
    AstAggregateGuard (..),
    AstConditionalLiteral (..),
    AstAggregate (..),
    AstBodyAggregateElement (..),
    AstBodyAggregate (..),
    AstHeadAggregateElement (..),
    AstHeadAggregate (..),
    AstDisjunction (..),
    AstDisjointElement (..),
    AstDisjoint (..),
    AstTheoryTermArray (..),
    AstTheoryFunction (..),
    AstTheoryUnparsedTermElement (..),
    AstTheoryUnparsedTerm (..),
    AstTheoryTerm (..),
    AstTheoryAtomElement (..),
    AstTheoryGuard (..),
    AstTheoryAtom (..),
    AstHeadLiteral (..),
    AstBodyLiteral (..),
    AstTheoryOperatorDefinition (..),
    AstTheoryTermDefinition (..),
    AstTheoryGuardDefinition (..),
    AstTheoryAtomDefinition (..),
    AstTheoryDefinition (..),
    AstRule (..),
    AstDefinition (..),
    AstShowSignature (..),
    AstShowTerm (..),
    AstMinimize (..),
    AstScript (..),
    AstProgram (..),
    AstExternal (..),
    AstEdge (..),
    AstHeuristic (..),
    AstProject (..),
    AstStatement (..),

    -- * Functions
    CallbackAST,
    mkCallbackAst,
    parseProgram,
)
where

import Control.Monad.IO.Class

import Foreign
import Foreign.C

import Clingo.Raw.Types


{-# LINE 194 "src/Clingo/Raw/AST.hsc" #-}

type AstComparisonOperator = Int32
{-# LINE 196 "src/Clingo/Raw/AST.hsc" #-}

pattern AstComparisonOperatorGreaterThan = 0
{-# LINE 198 "src/Clingo/Raw/AST.hsc" #-}
pattern AstComparisonOperatorLessThan = 1
{-# LINE 199 "src/Clingo/Raw/AST.hsc" #-}
pattern AstComparisonOperatorLessEqual = 2
{-# LINE 200 "src/Clingo/Raw/AST.hsc" #-}
pattern AstComparisonOperatorGreaterEqual = 3
{-# LINE 201 "src/Clingo/Raw/AST.hsc" #-}
pattern AstComparisonOperatorNotEqual = 4
{-# LINE 202 "src/Clingo/Raw/AST.hsc" #-}
pattern AstComparisonOperatorEqual = 5
{-# LINE 203 "src/Clingo/Raw/AST.hsc" #-}

type AstSign = Int32
{-# LINE 205 "src/Clingo/Raw/AST.hsc" #-}

pattern AstSignNone = 0
{-# LINE 207 "src/Clingo/Raw/AST.hsc" #-}
pattern AstSignNegation = 1
{-# LINE 208 "src/Clingo/Raw/AST.hsc" #-}
pattern AstSignDoubleNegation = 2
{-# LINE 209 "src/Clingo/Raw/AST.hsc" #-}

type AstTermType = Int32
{-# LINE 211 "src/Clingo/Raw/AST.hsc" #-}

pattern AstTermTypeSymbol = 0
{-# LINE 213 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTermTypeVariable = 1
{-# LINE 214 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTermTypeUnaryOperation = 2
{-# LINE 215 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTermTypeBinaryOperation = 3
{-# LINE 216 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTermTypeInterval = 4
{-# LINE 217 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTermTypeFunction = 5
{-# LINE 218 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTermTypeExternalFunction = 6
{-# LINE 219 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTermTypePool = 7
{-# LINE 220 "src/Clingo/Raw/AST.hsc" #-}

type AstUnaryOperator = Int32
{-# LINE 222 "src/Clingo/Raw/AST.hsc" #-}

pattern AstUnaryOperatorMinus = 0
{-# LINE 224 "src/Clingo/Raw/AST.hsc" #-}
pattern AstUnaryOperatorNegation = 1
{-# LINE 225 "src/Clingo/Raw/AST.hsc" #-}
pattern AstUnaryOperatorAbsolute = 2
{-# LINE 226 "src/Clingo/Raw/AST.hsc" #-}

type AstBinaryOperator = Int32
{-# LINE 228 "src/Clingo/Raw/AST.hsc" #-}

pattern AstBinaryOperatorXor = 0
{-# LINE 230 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBinaryOperatorOr = 1
{-# LINE 231 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBinaryOperatorAnd = 2
{-# LINE 232 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBinaryOperatorPlus = 3
{-# LINE 233 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBinaryOperatorMinus = 4
{-# LINE 234 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBinaryOperatorMultiplication = 5
{-# LINE 235 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBinaryOperatorDivision = 6
{-# LINE 236 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBinaryOperatorModulo = 7
{-# LINE 237 "src/Clingo/Raw/AST.hsc" #-}

type AstLiteralType = Int32
{-# LINE 239 "src/Clingo/Raw/AST.hsc" #-}

pattern AstLiteralTypeBoolean = 0
{-# LINE 241 "src/Clingo/Raw/AST.hsc" #-}
pattern AstLiteralTypeSymbolic = 1
{-# LINE 242 "src/Clingo/Raw/AST.hsc" #-}
pattern AstLiteralTypeComparison = 2
{-# LINE 243 "src/Clingo/Raw/AST.hsc" #-}
pattern AstLiteralTypeCsp = 3
{-# LINE 244 "src/Clingo/Raw/AST.hsc" #-}

type AstAggregateFunction = Int32
{-# LINE 246 "src/Clingo/Raw/AST.hsc" #-}

pattern AstAggregateFunctionCount = 0
{-# LINE 248 "src/Clingo/Raw/AST.hsc" #-}
pattern AstAggregateFunctionSum = 1
{-# LINE 249 "src/Clingo/Raw/AST.hsc" #-}
pattern AstAggregateFunctionSump = 2
{-# LINE 250 "src/Clingo/Raw/AST.hsc" #-}
pattern AstAggregateFunctionMin = 3
{-# LINE 251 "src/Clingo/Raw/AST.hsc" #-}
pattern AstAggregateFunctionMax = 4
{-# LINE 252 "src/Clingo/Raw/AST.hsc" #-}

type AstTheoryTermType = Int32
{-# LINE 254 "src/Clingo/Raw/AST.hsc" #-}

pattern AstTheoryTermTypeSymbol = 0
{-# LINE 256 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryTermTypeVariable = 1
{-# LINE 257 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryTermTypeTuple = 2
{-# LINE 258 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryTermTypeList = 3
{-# LINE 259 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryTermTypeSet = 4
{-# LINE 260 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryTermTypeFunction = 5
{-# LINE 261 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryTermTypeUnparsedTerm = 6
{-# LINE 262 "src/Clingo/Raw/AST.hsc" #-}

type AstHeadLiteralType = Int32
{-# LINE 264 "src/Clingo/Raw/AST.hsc" #-}

pattern AstHeadLiteralTypeLiteral = 0
{-# LINE 266 "src/Clingo/Raw/AST.hsc" #-}
pattern AstHeadLiteralTypeDisjunction = 1
{-# LINE 267 "src/Clingo/Raw/AST.hsc" #-}
pattern AstHeadLiteralTypeAggregate = 2
{-# LINE 268 "src/Clingo/Raw/AST.hsc" #-}
pattern AstHeadLiteralTypeHeadAggregate = 3
{-# LINE 269 "src/Clingo/Raw/AST.hsc" #-}
pattern AstHeadLiteralTypeTheoryAtom = 4
{-# LINE 270 "src/Clingo/Raw/AST.hsc" #-}

type AstBodyLiteralType = Int32
{-# LINE 272 "src/Clingo/Raw/AST.hsc" #-}

pattern AstBodyLiteralTypeLiteral = 0
{-# LINE 274 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBodyLiteralTypeConditional = 1
{-# LINE 275 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBodyLiteralTypeAggregate = 2
{-# LINE 276 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBodyLiteralTypeBodyAggregate = 3
{-# LINE 277 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBodyLiteralTypeTheoryAtom = 4
{-# LINE 278 "src/Clingo/Raw/AST.hsc" #-}
pattern AstBodyLiteralTypeDisjoint = 5
{-# LINE 279 "src/Clingo/Raw/AST.hsc" #-}

type AstTheoryOperatorType = Int32
{-# LINE 281 "src/Clingo/Raw/AST.hsc" #-}

pattern AstTheoryOperatorTypeUnary = 0
{-# LINE 283 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryOperatorTypeBinaryLeft = 1
{-# LINE 284 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryOperatorTypeBinaryRight = 2
{-# LINE 285 "src/Clingo/Raw/AST.hsc" #-}

type AstTheoryAtomDefType = Int32
{-# LINE 287 "src/Clingo/Raw/AST.hsc" #-}

pattern AstTheoryAtomDefinitionTypeHead = 0
{-# LINE 289 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryAtomDefinitionTypeBody = 1
{-# LINE 290 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryAtomDefinitionTypeAny = 2
{-# LINE 291 "src/Clingo/Raw/AST.hsc" #-}
pattern AstTheoryAtomDefinitionTypeDirective = 3
{-# LINE 292 "src/Clingo/Raw/AST.hsc" #-}

type AstScriptType = Int32
{-# LINE 294 "src/Clingo/Raw/AST.hsc" #-}

pattern AstScriptTypeLua = 0
{-# LINE 296 "src/Clingo/Raw/AST.hsc" #-}
pattern AstScriptTypePython = 1
{-# LINE 297 "src/Clingo/Raw/AST.hsc" #-}

type AstStatementType = Int32
{-# LINE 299 "src/Clingo/Raw/AST.hsc" #-}

pattern AstStatementTypeRule = 0
{-# LINE 301 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeConst = 1
{-# LINE 302 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeShowSignature = 2
{-# LINE 303 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeShowTerm = 3
{-# LINE 304 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeMinimize = 4
{-# LINE 305 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeScript = 5
{-# LINE 306 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeProgram = 6
{-# LINE 307 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeExternal = 7
{-# LINE 308 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeEdge = 8
{-# LINE 309 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeHeuristic = 9
{-# LINE 310 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeProjectAtom = 10
{-# LINE 311 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeProjectAtomSignature = 11
{-# LINE 312 "src/Clingo/Raw/AST.hsc" #-}
pattern AstStatementTypeTheoryDefinition = 12
{-# LINE 313 "src/Clingo/Raw/AST.hsc" #-}

type CallbackAST a = Ptr AstStatement -> Ptr a -> IO CBool 

foreign import ccall "wrapper" mkCallbackAst ::
    CallbackAST a -> IO (FunPtr (CallbackAST a))

data AstUnaryOperation = AstUnaryOperation AstUnaryOperator AstTerm
    deriving (Eq, Show)

instance Storable AstUnaryOperation where
    sizeOf _ = (72)
{-# LINE 324 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstUnaryOperation 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 327 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 328 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstUnaryOperation a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 330 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 331 "src/Clingo/Raw/AST.hsc" #-}
   
data AstBinaryOperation = AstBinaryOperation AstBinaryOperator AstTerm AstTerm
    deriving (Eq, Show)

instance Storable AstBinaryOperation where
    sizeOf _ = (136)
{-# LINE 337 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstBinaryOperation 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 340 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 341 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 342 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstBinaryOperation a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 344 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 345 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 346 "src/Clingo/Raw/AST.hsc" #-}

data AstInterval = AstInterval AstTerm AstTerm
    deriving (Eq, Show)

instance Storable AstInterval where
    sizeOf _ = (128)
{-# LINE 352 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstInterval 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 355 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 356 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstInterval a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 358 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 359 "src/Clingo/Raw/AST.hsc" #-}

data AstFunction = AstFunction CString (Ptr AstTerm) CSize
    deriving (Eq, Show)

instance Storable AstFunction where
    sizeOf _ = (24)
{-# LINE 365 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstFunction 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 368 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 369 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 370 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstFunction a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 372 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 373 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 374 "src/Clingo/Raw/AST.hsc" #-}

data AstPool = AstPool (Ptr AstTerm) CSize
    deriving (Eq, Show)

instance Storable AstPool where
    sizeOf _ = (16)
{-# LINE 380 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstPool 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 383 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 384 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstPool a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 386 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 387 "src/Clingo/Raw/AST.hsc" #-}

data AstTerm = AstTermSymbol Location Symbol
             | AstTermVariable Location CString
             | AstTermUOp Location (Ptr AstUnaryOperation)
             | AstTermBOp Location (Ptr AstBinaryOperation)
             | AstTermInterval Location (Ptr AstInterval)
             | AstTermFunction Location (Ptr AstFunction)
             | AstTermExtFunction Location (Ptr AstFunction)
             | AstTermPool Location (Ptr AstPool)
    deriving (Eq, Show)

instance Storable AstTerm where
    sizeOf _ = (64)
{-# LINE 400 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = do
        loc <- ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 403 "src/Clingo/Raw/AST.hsc" #-}
        typ :: AstTermType <- ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 404 "src/Clingo/Raw/AST.hsc" #-}
        case typ of
            AstTermTypeSymbol -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 407 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermSymbol loc payload
            AstTermTypeVariable -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 410 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermVariable loc payload
            AstTermTypeUnaryOperation -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 413 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermUOp loc payload
            AstTermTypeBinaryOperation -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 416 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermBOp loc payload
            AstTermTypeInterval -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 419 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermInterval loc payload
            AstTermTypeFunction -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 422 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermFunction loc payload
            AstTermTypeExternalFunction -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 425 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermExtFunction loc payload
            AstTermTypePool -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 428 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTermPool loc payload
            _ -> error "Malformed struct clingo_ast_term_t"
    poke p d = case d of
        AstTermSymbol l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 433 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypeSymbol :: AstTermType)
{-# LINE 434 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 435 "src/Clingo/Raw/AST.hsc" #-}
        AstTermVariable l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 437 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypeVariable :: AstTermType)
{-# LINE 438 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 439 "src/Clingo/Raw/AST.hsc" #-}
        AstTermUOp l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 441 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypeUnaryOperation :: AstTermType)
{-# LINE 442 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 443 "src/Clingo/Raw/AST.hsc" #-}
        AstTermBOp l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 445 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypeBinaryOperation :: AstTermType)
{-# LINE 446 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 447 "src/Clingo/Raw/AST.hsc" #-}
        AstTermInterval l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 449 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypeInterval :: AstTermType)
{-# LINE 450 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 451 "src/Clingo/Raw/AST.hsc" #-}
        AstTermFunction l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 453 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypeFunction :: AstTermType)
{-# LINE 454 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 455 "src/Clingo/Raw/AST.hsc" #-}
        AstTermExtFunction l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 457 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypeExternalFunction :: AstTermType)
{-# LINE 458 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 459 "src/Clingo/Raw/AST.hsc" #-}
        AstTermPool l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 461 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTermTypePool :: AstTermType)
{-# LINE 462 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 463 "src/Clingo/Raw/AST.hsc" #-}

data AstCspProductTerm = AstCspProductTerm Location AstTerm (Ptr AstTerm)
    deriving (Eq, Show)

instance Storable AstCspProductTerm where
    sizeOf _ = (120)
{-# LINE 469 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstCspProductTerm 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 472 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 473 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 112) p)
{-# LINE 474 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstCspProductTerm a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 476 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p b
{-# LINE 477 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 112)) p c
{-# LINE 478 "src/Clingo/Raw/AST.hsc" #-}

data AstCspSumTerm = AstCspSumTerm Location (Ptr AstCspProductTerm) CSize
    deriving (Eq, Show)

instance Storable AstCspSumTerm where
    sizeOf _ = (64)
{-# LINE 484 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstCspSumTerm 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 487 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 488 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 489 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstCspSumTerm a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 491 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p b
{-# LINE 492 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p c
{-# LINE 493 "src/Clingo/Raw/AST.hsc" #-}
    
data AstCspGuard = AstCspGuard AstComparisonOperator AstCspSumTerm
    deriving (Eq, Show)

instance Storable AstCspGuard where
    sizeOf _ = (72)
{-# LINE 499 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstCspGuard 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 502 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 503 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstCspGuard a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 505 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 506 "src/Clingo/Raw/AST.hsc" #-}

data AstCspLiteral = AstCspLiteral AstCspSumTerm (Ptr AstCspGuard) CSize
    deriving (Eq, Show)

instance Storable AstCspLiteral where
    sizeOf _ = (80)
{-# LINE 512 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstCspLiteral 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 515 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 516 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 517 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstCspLiteral a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 519 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 520 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 521 "src/Clingo/Raw/AST.hsc" #-}
    
data AstId = AstId Location CString
    deriving (Eq, Show)

instance Storable AstId where
    sizeOf _ = (56)
{-# LINE 527 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstId 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 530 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 531 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstId a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 533 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p b
{-# LINE 534 "src/Clingo/Raw/AST.hsc" #-}

data AstComparison = AstComparison AstComparisonOperator AstTerm AstTerm
    deriving (Eq, Show)

instance Storable AstComparison where
    sizeOf _ = (136)
{-# LINE 540 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstComparison 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 543 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 544 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 545 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstComparison a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 547 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 548 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 549 "src/Clingo/Raw/AST.hsc" #-}

data AstLiteral = AstLiteralBool Location AstSign CBool
                | AstLiteralTerm Location AstSign (Ptr AstTerm)
                | AstLiteralComp Location AstSign (Ptr AstComparison)
                | AstLiteralCSPL Location AstSign (Ptr AstCspLiteral)
    deriving (Eq, Show)

instance Storable AstLiteral where
    sizeOf _ = (64)
{-# LINE 558 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = do
        loc <- ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 561 "src/Clingo/Raw/AST.hsc" #-}
        sign <- ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 562 "src/Clingo/Raw/AST.hsc" #-}
        typ :: AstLiteralType <- ((\hsc_ptr -> peekByteOff hsc_ptr 52) p)
{-# LINE 563 "src/Clingo/Raw/AST.hsc" #-}
        case typ of
            AstLiteralTypeBoolean -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 566 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstLiteralBool loc sign payload
            AstLiteralTypeSymbolic -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 569 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstLiteralTerm loc sign payload
            AstLiteralTypeComparison -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 572 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstLiteralComp loc sign payload
            AstLiteralTypeCsp -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 575 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstLiteralCSPL loc sign payload
            _ -> error "Malformed struct clingo_ast_literal_t"
    poke p d = case d of
        AstLiteralBool l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 580 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 581 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstLiteralTypeBoolean :: AstLiteralType)
{-# LINE 582 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 583 "src/Clingo/Raw/AST.hsc" #-}
        AstLiteralTerm l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 585 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 586 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstLiteralTypeSymbolic :: AstLiteralType)
{-# LINE 587 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 588 "src/Clingo/Raw/AST.hsc" #-}
        AstLiteralComp l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 590 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 591 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstLiteralTypeComparison:: AstLiteralType)
{-# LINE 592 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 593 "src/Clingo/Raw/AST.hsc" #-}
        AstLiteralCSPL l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 595 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 596 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstLiteralTypeCsp :: AstLiteralType)
{-# LINE 597 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 598 "src/Clingo/Raw/AST.hsc" #-}

data AstAggregateGuard = AstAggregateGuard AstComparisonOperator AstTerm
    deriving (Eq, Show)

instance Storable AstAggregateGuard where
    sizeOf _ = (72)
{-# LINE 604 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstAggregateGuard 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 607 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 608 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstAggregateGuard a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 610 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 611 "src/Clingo/Raw/AST.hsc" #-}

data AstConditionalLiteral = AstConditionalLiteral AstLiteral 
                             (Ptr AstLiteral) CSize
    deriving (Eq, Show)

instance Storable AstConditionalLiteral where
    sizeOf _ = (80)
{-# LINE 618 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstConditionalLiteral 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 621 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 622 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 623 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstConditionalLiteral a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 625 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 626 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 627 "src/Clingo/Raw/AST.hsc" #-}

data AstAggregate = AstAggregate (Ptr AstConditionalLiteral) CSize
                    (Ptr AstAggregateGuard) (Ptr AstAggregateGuard)
    deriving (Eq, Show)

instance Storable AstAggregate where
    sizeOf _ = (32)
{-# LINE 634 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstAggregate 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 637 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 638 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 639 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 24) p)
{-# LINE 640 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstAggregate a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 642 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 643 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 644 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p d
{-# LINE 645 "src/Clingo/Raw/AST.hsc" #-}
    
data AstBodyAggregateElement = AstBodyAggregateElement (Ptr AstTerm) CSize 
                               (Ptr AstLiteral) CSize
    deriving (Eq, Show)

instance Storable AstBodyAggregateElement where
    sizeOf _ = (32)
{-# LINE 652 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstBodyAggregateElement 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 655 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 656 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 657 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 24) p)
{-# LINE 658 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstBodyAggregateElement a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 660 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 661 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 662 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p d
{-# LINE 663 "src/Clingo/Raw/AST.hsc" #-}
    
data AstBodyAggregate = AstBodyAggregate AstAggregateFunction
                        (Ptr AstBodyAggregateElement) CSize
                        (Ptr AstAggregateGuard) (Ptr AstAggregateGuard)
    deriving (Eq, Show)

instance Storable AstBodyAggregate where
    sizeOf _ = (40)
{-# LINE 671 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstBodyAggregate 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 674 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 675 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 676 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 24) p)
{-# LINE 677 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 32) p)
{-# LINE 678 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstBodyAggregate a b c d e) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 680 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 681 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 682 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p d
{-# LINE 683 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 32)) p e
{-# LINE 684 "src/Clingo/Raw/AST.hsc" #-}

data AstHeadAggregateElement = AstHeadAggregateElement (Ptr AstTerm) CSize
                               AstConditionalLiteral
    deriving (Eq, Show)

instance Storable AstHeadAggregateElement where
    sizeOf _ = (96)
{-# LINE 691 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstHeadAggregateElement 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 694 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 695 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 696 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstHeadAggregateElement a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 698 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 699 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 700 "src/Clingo/Raw/AST.hsc" #-}
    
data AstHeadAggregate = AstHeadAggregate AstAggregateFunction
                        (Ptr AstHeadAggregateElement) CSize
                        (Ptr AstAggregateGuard) (Ptr AstAggregateGuard)
    deriving (Eq, Show)

instance Storable AstHeadAggregate where
    sizeOf _ = (32)
{-# LINE 708 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstHeadAggregate 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 711 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 712 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 713 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 24) p)
{-# LINE 714 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 32) p)
{-# LINE 715 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstHeadAggregate a b c d e) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 717 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 718 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 719 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p d
{-# LINE 720 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 32)) p e
{-# LINE 721 "src/Clingo/Raw/AST.hsc" #-}
    
data AstDisjunction = AstDisjunction (Ptr AstConditionalLiteral) CSize
    deriving (Eq, Show)

instance Storable AstDisjunction where
    sizeOf _ = (16)
{-# LINE 727 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstDisjunction 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 730 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 731 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstDisjunction a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 733 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 734 "src/Clingo/Raw/AST.hsc" #-}
    
data AstDisjointElement = AstDisjointElement Location (Ptr AstTerm) CSize
                          AstCspSumTerm (Ptr AstLiteral) CSize
    deriving (Eq, Show)

instance Storable AstDisjointElement where
    sizeOf _ = (144)
{-# LINE 741 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstDisjointElement 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 744 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 745 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 746 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 747 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 128) p)
{-# LINE 748 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 136) p)
{-# LINE 749 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstDisjointElement a b c d e f) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 751 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p b
{-# LINE 752 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p c
{-# LINE 753 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p d
{-# LINE 754 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 128)) p e
{-# LINE 755 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 136)) p f
{-# LINE 756 "src/Clingo/Raw/AST.hsc" #-}
    
data AstDisjoint = AstDisjoint (Ptr AstDisjointElement) CSize
    deriving (Eq, Show)

instance Storable AstDisjoint where
    sizeOf _ = (16)
{-# LINE 762 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstDisjoint 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 765 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 766 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstDisjoint a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 768 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 769 "src/Clingo/Raw/AST.hsc" #-}
    
data AstTheoryTermArray = AstTheoryTermArray (Ptr AstTheoryTerm) CSize
    deriving (Eq, Show)

instance Storable AstTheoryTermArray where
    sizeOf _ = (16)
{-# LINE 775 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryTermArray 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 778 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 779 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryTermArray a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 781 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 782 "src/Clingo/Raw/AST.hsc" #-}

data AstTheoryFunction = AstTheoryFunction CString (Ptr AstTheoryTerm) CSize
    deriving (Eq, Show)

instance Storable AstTheoryFunction where
    sizeOf _ = (24)
{-# LINE 788 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryFunction 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 791 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 792 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 793 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryFunction a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 795 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 796 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 797 "src/Clingo/Raw/AST.hsc" #-}
    
data AstTheoryUnparsedTermElement = AstTheoryUnparsedTermElement 
                                    (Ptr CString) CSize AstTheoryTerm
    deriving (Eq, Show)

instance Storable AstTheoryUnparsedTermElement where
    sizeOf _ = (80)
{-# LINE 804 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryUnparsedTermElement 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 807 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 808 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 809 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryUnparsedTermElement a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 811 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 812 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 813 "src/Clingo/Raw/AST.hsc" #-}

data AstTheoryUnparsedTerm = AstTheoryUnparsedTerm 
                             (Ptr AstTheoryUnparsedTermElement) CSize
    deriving (Eq, Show)

instance Storable AstTheoryUnparsedTerm where
    sizeOf _ = (16)
{-# LINE 820 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryUnparsedTerm 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 823 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 824 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryUnparsedTerm a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 826 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 827 "src/Clingo/Raw/AST.hsc" #-}
    
data AstTheoryTerm = AstTheoryTermSymbol Location Symbol
                   | AstTheoryTermVariable Location CString
                   | AstTheoryTermTuple Location (Ptr AstTheoryTermArray)
                   | AstTheoryTermList Location (Ptr AstTheoryTermArray)
                   | AstTheoryTermSet Location (Ptr AstTheoryTermArray)
                   | AstTheoryTermFunction Location (Ptr AstTheoryFunction)
                   | AstTheoryTermUnparsed Location (Ptr AstTheoryUnparsedTerm)
    deriving (Eq, Show)

instance Storable AstTheoryTerm where
    sizeOf _ = (64)
{-# LINE 839 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = do
        loc <- ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 842 "src/Clingo/Raw/AST.hsc" #-}
        typ :: AstTheoryTermType <- ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 843 "src/Clingo/Raw/AST.hsc" #-}
        case typ of
            AstTheoryTermTypeSymbol -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 846 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTheoryTermSymbol loc payload
            AstTheoryTermTypeVariable -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 849 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTheoryTermVariable loc payload
            AstTheoryTermTypeTuple -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 852 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTheoryTermTuple loc payload
            AstTheoryTermTypeList -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 855 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTheoryTermList loc payload
            AstTheoryTermTypeSet -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 858 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTheoryTermSet loc payload
            AstTheoryTermTypeFunction -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 861 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTheoryTermFunction loc payload
            AstTheoryTermTypeUnparsedTerm -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 864 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstTheoryTermUnparsed loc payload
            _ -> error "Malformed struct clingo_ast_theory_term_t"
    poke p d = case d of
        AstTheoryTermSymbol l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 869 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTheoryTermTypeSymbol :: AstTheoryTermType)
{-# LINE 870 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 871 "src/Clingo/Raw/AST.hsc" #-}
        AstTheoryTermVariable l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 873 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTheoryTermTypeVariable :: AstTheoryTermType)
{-# LINE 874 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 875 "src/Clingo/Raw/AST.hsc" #-}
        AstTheoryTermTuple l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 877 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTheoryTermTypeTuple :: AstTheoryTermType)
{-# LINE 878 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 879 "src/Clingo/Raw/AST.hsc" #-}
        AstTheoryTermList l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 881 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTheoryTermTypeList :: AstTheoryTermType)
{-# LINE 882 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 883 "src/Clingo/Raw/AST.hsc" #-}
        AstTheoryTermSet l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 885 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTheoryTermTypeSet :: AstTheoryTermType)
{-# LINE 886 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 887 "src/Clingo/Raw/AST.hsc" #-}
        AstTheoryTermFunction l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 889 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTheoryTermTypeFunction :: AstTheoryTermType)
{-# LINE 890 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 891 "src/Clingo/Raw/AST.hsc" #-}
        AstTheoryTermUnparsed l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 893 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstTheoryTermTypeUnparsedTerm :: AstTheoryTermType)
{-# LINE 894 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 895 "src/Clingo/Raw/AST.hsc" #-}

data AstTheoryAtomElement = AstTheoryAtomElement (Ptr AstTheoryTerm) CSize
                            (Ptr AstLiteral) CSize
    deriving (Eq, Show)

instance Storable AstTheoryAtomElement where
    sizeOf _ = (32)
{-# LINE 902 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryAtomElement 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 905 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 906 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 907 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 24) p)
{-# LINE 908 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryAtomElement a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 910 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 911 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 912 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p d
{-# LINE 913 "src/Clingo/Raw/AST.hsc" #-}
    
data AstTheoryGuard = AstTheoryGuard CString AstTheoryTerm
    deriving (Eq, Show)

instance Storable AstTheoryGuard where
    sizeOf _ = (72)
{-# LINE 919 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryGuard 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 922 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 923 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryGuard a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 925 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 926 "src/Clingo/Raw/AST.hsc" #-}

data AstTheoryAtom = AstTheoryAtom AstTerm (Ptr AstTheoryAtomElement) CSize
                     AstTheoryGuard
    deriving (Eq, Show)

instance Storable AstTheoryAtom where
    sizeOf _ = (88)
{-# LINE 933 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryAtom 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 936 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 937 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 938 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 80) p)
{-# LINE 939 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryAtom a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 941 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 942 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 943 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 80)) p d
{-# LINE 944 "src/Clingo/Raw/AST.hsc" #-}

data AstHeadLiteral = AstHeadLiteral Location (Ptr AstLiteral)
                    | AstHeadDisjunction Location (Ptr AstDisjunction)
                    | AstHeadLitAggregate Location (Ptr AstAggregate)
                    | AstHeadHeadAggregate Location (Ptr AstHeadAggregate)
                    | AstHeadTheoryAtom Location (Ptr AstTheoryAtom)
    deriving (Eq, Show)

instance Storable AstHeadLiteral where
    sizeOf _ = (64)
{-# LINE 954 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = do
        loc <- ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 957 "src/Clingo/Raw/AST.hsc" #-}
        typ :: AstHeadLiteralType <- ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 958 "src/Clingo/Raw/AST.hsc" #-}
        case typ of
            AstHeadLiteralTypeLiteral -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 961 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstHeadLiteral loc payload
            AstHeadLiteralTypeDisjunction -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 964 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstHeadDisjunction loc payload
            AstHeadLiteralTypeAggregate -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 967 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstHeadLitAggregate loc payload
            AstHeadLiteralTypeHeadAggregate -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 970 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstHeadHeadAggregate loc payload
            AstHeadLiteralTypeTheoryAtom -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 973 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstHeadTheoryAtom loc payload
            _ -> error "Malformed struct clingo_ast_head_literal_t"
    poke p d = case d of
        AstHeadLiteral l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 978 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstHeadLiteralTypeLiteral :: AstHeadLiteralType)
{-# LINE 979 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 980 "src/Clingo/Raw/AST.hsc" #-}
        AstHeadDisjunction l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 982 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstHeadLiteralTypeDisjunction :: AstHeadLiteralType)
{-# LINE 983 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 984 "src/Clingo/Raw/AST.hsc" #-}
        AstHeadLitAggregate l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 986 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstHeadLiteralTypeAggregate :: AstHeadLiteralType)
{-# LINE 987 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 988 "src/Clingo/Raw/AST.hsc" #-}
        AstHeadHeadAggregate l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 990 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstHeadLiteralTypeHeadAggregate :: AstHeadLiteralType)
{-# LINE 991 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 992 "src/Clingo/Raw/AST.hsc" #-}
        AstHeadTheoryAtom l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 994 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstHeadLiteralTypeTheoryAtom :: AstHeadLiteralType)
{-# LINE 995 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 996 "src/Clingo/Raw/AST.hsc" #-}

data AstBodyLiteral 
    = AstBodyLiteral Location AstSign (Ptr AstLiteral)
    | AstBodyConditional Location (Ptr AstConditionalLiteral)
    | AstBodyLitAggregate Location AstSign (Ptr AstAggregate)
    | AstBodyBodyAggregate Location AstSign (Ptr AstBodyAggregate)
    | AstBodyTheoryAtom Location AstSign (Ptr AstTheoryAtom)
    | AstBodyDisjoint Location AstSign (Ptr AstDisjoint)
    deriving (Eq, Show)

instance Storable AstBodyLiteral where
    sizeOf _ = (64)
{-# LINE 1008 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = do
        loc <- ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1011 "src/Clingo/Raw/AST.hsc" #-}
        sign <- ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 1012 "src/Clingo/Raw/AST.hsc" #-}
        typ :: AstBodyLiteralType <- ((\hsc_ptr -> peekByteOff hsc_ptr 52) p)
{-# LINE 1013 "src/Clingo/Raw/AST.hsc" #-}
        case typ of
            AstBodyLiteralTypeLiteral -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1016 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstBodyLiteral loc sign payload
            AstBodyLiteralTypeConditional -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1019 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstBodyConditional loc payload
            AstBodyLiteralTypeAggregate -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1022 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstBodyLitAggregate loc sign payload
            AstBodyLiteralTypeBodyAggregate -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1025 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstBodyBodyAggregate loc sign payload
            AstBodyLiteralTypeTheoryAtom -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1028 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstBodyTheoryAtom loc sign payload
            AstBodyLiteralTypeDisjoint -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1031 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstBodyDisjoint loc sign payload
            _ -> error "Malformed struct clingo_ast_body_literal_t"
    poke p d = case d of
        AstBodyLiteral l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1036 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 1037 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstBodyLiteralTypeLiteral :: AstBodyLiteralType)
{-# LINE 1038 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1039 "src/Clingo/Raw/AST.hsc" #-}
        AstBodyConditional l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1041 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstBodyLiteralTypeConditional :: AstBodyLiteralType)
{-# LINE 1042 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1043 "src/Clingo/Raw/AST.hsc" #-}
        AstBodyLitAggregate l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1045 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 1046 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstBodyLiteralTypeAggregate :: AstBodyLiteralType)
{-# LINE 1047 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1048 "src/Clingo/Raw/AST.hsc" #-}
        AstBodyBodyAggregate l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1050 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 1051 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstBodyLiteralTypeBodyAggregate :: AstBodyLiteralType)
{-# LINE 1052 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1053 "src/Clingo/Raw/AST.hsc" #-}
        AstBodyTheoryAtom l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1055 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 1056 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstBodyLiteralTypeTheoryAtom :: AstBodyLiteralType)
{-# LINE 1057 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1058 "src/Clingo/Raw/AST.hsc" #-}
        AstBodyDisjoint l s x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1060 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p s
{-# LINE 1061 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 52)) p (AstBodyLiteralTypeDisjoint :: AstBodyLiteralType)
{-# LINE 1062 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1063 "src/Clingo/Raw/AST.hsc" #-}

data AstTheoryOperatorDefinition = AstTheoryOperatorDefinition Location 
                                   CString CUInt AstTheoryOperatorType
    deriving (Eq, Show)

instance Storable AstTheoryOperatorDefinition where
    sizeOf _ = (64)
{-# LINE 1070 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryOperatorDefinition 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1073 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 1074 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1075 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 60) p)
{-# LINE 1076 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryOperatorDefinition a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1078 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p b
{-# LINE 1079 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p c
{-# LINE 1080 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 60)) p d
{-# LINE 1081 "src/Clingo/Raw/AST.hsc" #-}
    
data AstTheoryTermDefinition = AstTheoryTermDefinition Location CString
                               (Ptr AstTheoryOperatorDefinition) CSize
    deriving (Eq, Show)

instance Storable AstTheoryTermDefinition where
    sizeOf _ = (72)
{-# LINE 1088 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryTermDefinition 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1091 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 1092 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1093 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1094 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryTermDefinition a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1096 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p b
{-# LINE 1097 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p c
{-# LINE 1098 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p d
{-# LINE 1099 "src/Clingo/Raw/AST.hsc" #-}
    
data AstTheoryGuardDefinition = AstTheoryGuardDefinition CString (Ptr CString) 
                                CSize
    deriving (Eq, Show)

instance Storable AstTheoryGuardDefinition where
    sizeOf _ = (24)
{-# LINE 1106 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryGuardDefinition 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1109 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 1110 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 1111 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryGuardDefinition a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1113 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 1114 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 1115 "src/Clingo/Raw/AST.hsc" #-}

data AstTheoryAtomDefinition = AstTheoryAtomDefinition Location 
                               AstTheoryAtomDefType CString CUInt CString
                               (Ptr AstTheoryGuardDefinition)
    deriving (Eq, Show)

instance Storable AstTheoryAtomDefinition where
    sizeOf _ = (88)
{-# LINE 1123 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryAtomDefinition 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1126 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 1127 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1128 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1129 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 1130 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 80) p)
{-# LINE 1131 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryAtomDefinition a b c d e f) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1133 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p b
{-# LINE 1134 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p c
{-# LINE 1135 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p d
{-# LINE 1136 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p e
{-# LINE 1137 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 80)) p f
{-# LINE 1138 "src/Clingo/Raw/AST.hsc" #-}

data AstTheoryDefinition = AstTheoryDefinition CString 
                           (Ptr AstTheoryTermDefinition) CSize
                           (Ptr AstTheoryAtomDefinition) CSize
    deriving (Eq, Show)

instance Storable AstTheoryDefinition where
    sizeOf _ = (40)
{-# LINE 1146 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstTheoryDefinition 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1149 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 1150 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 1151 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 24) p)
{-# LINE 1152 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 32) p)
{-# LINE 1153 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstTheoryDefinition a b c d e) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1155 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 1156 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 1157 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p d
{-# LINE 1158 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 32)) p e
{-# LINE 1159 "src/Clingo/Raw/AST.hsc" #-}
    
data AstRule = AstRule AstHeadLiteral (Ptr AstBodyLiteral) CSize
    deriving (Eq, Show)

instance Storable AstRule where
    sizeOf _ = (80)
{-# LINE 1165 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstRule 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1168 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1169 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 1170 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstRule a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1172 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 1173 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 1174 "src/Clingo/Raw/AST.hsc" #-}
    
data AstDefinition = AstDefinition CString AstTerm CBool
    deriving (Eq, Show)

instance Storable AstDefinition where
    sizeOf _ = (80)
{-# LINE 1180 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstDefinition 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1183 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 1184 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 1185 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstDefinition a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1187 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 1188 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 1189 "src/Clingo/Raw/AST.hsc" #-}
    
data AstShowSignature = AstShowSignature Signature CBool
    deriving (Eq, Show)

instance Storable AstShowSignature where
    sizeOf _ = (16)
{-# LINE 1195 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstShowSignature 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1198 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 1199 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstShowSignature a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1201 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 1202 "src/Clingo/Raw/AST.hsc" #-}

data AstShowTerm = AstShowTerm AstTerm (Ptr AstBodyLiteral) CSize CBool
    deriving (Eq, Show)

instance Storable AstShowTerm where
    sizeOf _ = (88)
{-# LINE 1208 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstShowTerm 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1211 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1212 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 1213 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 80) p)
{-# LINE 1214 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstShowTerm a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1216 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 1217 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 1218 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 80)) p d
{-# LINE 1219 "src/Clingo/Raw/AST.hsc" #-}
    
data AstMinimize = AstMinimize AstTerm AstTerm (Ptr AstTerm) CSize 
                   (Ptr AstBodyLiteral) CSize
    deriving (Eq, Show)

instance Storable AstMinimize where
    sizeOf _ = (160)
{-# LINE 1226 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstMinimize 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1229 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1230 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 128) p)
{-# LINE 1231 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 136) p)
{-# LINE 1232 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 144) p)
{-# LINE 1233 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 152) p)
{-# LINE 1234 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstMinimize a b c d e f) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1236 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 1237 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 128)) p c
{-# LINE 1238 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 136)) p d
{-# LINE 1239 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 144)) p e
{-# LINE 1240 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 152)) p f
{-# LINE 1241 "src/Clingo/Raw/AST.hsc" #-}

data AstScript = AstScript AstScriptType CString
    deriving (Eq, Show)

instance Storable AstScript where
    sizeOf _ = (16)
{-# LINE 1247 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstScript 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1250 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 1251 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstScript a b) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1253 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 1254 "src/Clingo/Raw/AST.hsc" #-}

data AstProgram = AstProgram CString (Ptr AstId) CSize
    deriving (Eq, Show)

instance Storable AstProgram where
    sizeOf _ = (24)
{-# LINE 1260 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstProgram 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1263 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 8) p)
{-# LINE 1264 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 16) p)
{-# LINE 1265 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstProgram a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1267 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p b
{-# LINE 1268 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p c
{-# LINE 1269 "src/Clingo/Raw/AST.hsc" #-}
    
data AstExternal = AstExternal AstTerm (Ptr AstBodyLiteral) CSize
    deriving (Eq, Show)

instance Storable AstExternal where
    sizeOf _ = (80)
{-# LINE 1275 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstExternal 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1278 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1279 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 1280 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstExternal a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1282 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 1283 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 1284 "src/Clingo/Raw/AST.hsc" #-}

data AstEdge = AstEdge AstTerm AstTerm (Ptr AstBodyLiteral) CSize
    deriving (Eq, Show)

instance Storable AstEdge where
    sizeOf _ = (144)
{-# LINE 1290 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstEdge 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1293 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1294 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 128) p)
{-# LINE 1295 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 136) p)
{-# LINE 1296 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstEdge a b c d) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1298 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 1299 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 128)) p c
{-# LINE 1300 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 136)) p d
{-# LINE 1301 "src/Clingo/Raw/AST.hsc" #-}
    
data AstHeuristic = AstHeuristic AstTerm (Ptr AstBodyLiteral) CSize 
                    AstTerm AstTerm AstTerm
    deriving (Eq, Show)

instance Storable AstHeuristic where
    sizeOf _ = (272)
{-# LINE 1308 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstHeuristic 
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1311 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1312 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 1313 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 80) p)
{-# LINE 1314 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 144) p)
{-# LINE 1315 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 208) p)
{-# LINE 1316 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstHeuristic a b c d e f) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1318 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 1319 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 1320 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 80)) p d
{-# LINE 1321 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 144)) p e
{-# LINE 1322 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 208)) p f
{-# LINE 1323 "src/Clingo/Raw/AST.hsc" #-}

data AstProject = AstProject AstTerm (Ptr AstBodyLiteral) CSize
    deriving (Eq, Show)

instance Storable AstProject where
    sizeOf _ = (80)
{-# LINE 1329 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = AstProject
        <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1332 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 64) p)
{-# LINE 1333 "src/Clingo/Raw/AST.hsc" #-}
        <*> ((\hsc_ptr -> peekByteOff hsc_ptr 72) p)
{-# LINE 1334 "src/Clingo/Raw/AST.hsc" #-}
    poke p (AstProject a b c) = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p a
{-# LINE 1336 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 64)) p b
{-# LINE 1337 "src/Clingo/Raw/AST.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 72)) p c
{-# LINE 1338 "src/Clingo/Raw/AST.hsc" #-}
    
data AstStatement = AstStmtRule Location (Ptr AstRule)
                  | AstStmtDefinition Location (Ptr AstDefinition)
                  | AstStmtShowSignature Location (Ptr AstShowSignature)
                  | AstStmtShowTerm Location (Ptr AstShowTerm)
                  | AstStmtMinimize Location (Ptr AstMinimize)
                  | AstStmtScript Location (Ptr AstScript)
                  | AstStmtProgram Location (Ptr AstProgram)
                  | AstStmtExternal Location (Ptr AstExternal)
                  | AstStmtEdge Location (Ptr AstEdge)
                  | AstStmtHeuristic Location (Ptr AstHeuristic)
                  | AstStmtProject Location (Ptr AstProject)
                  | AstStmtSignature Location Signature
                  | AstStmtTheoryDefn Location (Ptr AstTheoryDefinition)
    deriving (Eq, Show)

instance Storable AstStatement where
    sizeOf _ = (72)
{-# LINE 1356 "src/Clingo/Raw/AST.hsc" #-}
    alignment = sizeOf
    peek p = do
        loc <- ((\hsc_ptr -> peekByteOff hsc_ptr 0) p)
{-# LINE 1359 "src/Clingo/Raw/AST.hsc" #-}
        typ :: AstStatementType <- ((\hsc_ptr -> peekByteOff hsc_ptr 48) p)
{-# LINE 1360 "src/Clingo/Raw/AST.hsc" #-}
        case typ of
            AstStatementTypeRule -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1363 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtRule loc payload
            AstStatementTypeConst -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1366 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtDefinition loc payload
            AstStatementTypeShowSignature -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1369 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtShowSignature loc payload
            AstStatementTypeShowTerm -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1372 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtShowTerm loc payload
            AstStatementTypeMinimize -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1375 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtMinimize loc payload
            AstStatementTypeScript -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1378 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtScript loc payload
            AstStatementTypeProgram -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1381 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtProgram loc payload
            AstStatementTypeExternal -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1384 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtExternal loc payload
            AstStatementTypeEdge -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1387 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtEdge loc payload
            AstStatementTypeHeuristic -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1390 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtHeuristic loc payload
            AstStatementTypeProjectAtom -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1393 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtProject loc payload
            AstStatementTypeProjectAtomSignature -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1396 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtSignature loc payload
            AstStatementTypeTheoryDefinition -> do
                payload <- ((\hsc_ptr -> peekByteOff hsc_ptr 56) p)
{-# LINE 1399 "src/Clingo/Raw/AST.hsc" #-}
                pure $! AstStmtTheoryDefn loc payload
            _ -> error "Malformed struct clingo_ast_statement_t"
    poke p d = case d of
        AstStmtRule l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1404 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeRule :: AstStatementType)
{-# LINE 1405 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1406 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtDefinition l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1408 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeConst :: AstStatementType)
{-# LINE 1409 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1410 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtShowSignature l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1412 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeShowSignature :: AstStatementType)
{-# LINE 1413 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1414 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtShowTerm l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1416 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeShowTerm :: AstStatementType)
{-# LINE 1417 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1418 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtMinimize l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1420 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeMinimize :: AstStatementType)
{-# LINE 1421 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1422 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtScript l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1424 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeScript :: AstStatementType)
{-# LINE 1425 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1426 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtProgram l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1428 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeProgram :: AstStatementType)
{-# LINE 1429 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1430 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtExternal l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1432 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeExternal :: AstStatementType)
{-# LINE 1433 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1434 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtEdge l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1436 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeEdge :: AstStatementType)
{-# LINE 1437 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1438 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtHeuristic l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1440 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeHeuristic :: AstStatementType)
{-# LINE 1441 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1442 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtProject l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1444 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeProjectAtom :: AstStatementType)
{-# LINE 1445 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1446 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtSignature l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1448 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeProjectAtomSignature :: AstStatementType)
{-# LINE 1449 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1450 "src/Clingo/Raw/AST.hsc" #-}
        AstStmtTheoryDefn l x -> do
            ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p l
{-# LINE 1452 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 48)) p (AstStatementTypeTheoryDefinition :: AstStatementType)
{-# LINE 1453 "src/Clingo/Raw/AST.hsc" #-}
            ((\hsc_ptr -> pokeByteOff hsc_ptr 56)) p x
{-# LINE 1454 "src/Clingo/Raw/AST.hsc" #-}

foreign import ccall "clingo.h clingo_parse_program" parseProgramFFI ::
    CString -> FunPtr (CallbackAST a) -> Ptr a -> FunPtr (Logger b) -> Ptr b 
            -> CUInt -> IO CBool

parseProgram :: MonadIO m
             => CString -> FunPtr (CallbackAST a) -> Ptr a -> FunPtr (Logger b) 
             -> Ptr b -> CUInt -> m CBool
parseProgram a b c d e f = liftIO $ parseProgramFFI a b c d e f