1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
------------------------------------------------------------------------------
--- This library defines a representation for Prolog programs.
--- It does not cover all aspects of Prolog but might be useful
--- for applications generating Prolog programs.
---
--- @author Michael Hanus
--- @version January 2022
------------------------------------------------------------------------------

module Language.Prolog.Types
  ( PlClause(..), PlGoal(..), PlTerm(..) )
 where

----------------------------------------------------------------------------
-- Representation of Prolog programs:

--- A Prolog clause is either a program clause consisting of a head
--- and a body, or a directive or a query without a head.
data PlClause = PlClause String [PlTerm] [PlGoal]
              | PlDirective [PlGoal]
              | PlQuery [PlGoal]
 deriving Eq

--- A Prolog goal is a literal, a negated goal, or a conditional.
data PlGoal = PlLit String [PlTerm]
            | PlNeg [PlGoal]
            | PlCond [PlGoal] [PlGoal] [PlGoal]
 deriving Eq

--- A Prolog term is a variable, an atom, a number, or a structure.
data PlTerm = PlVar String
            | PlAtom String
            | PlInt Int
            | PlFloat Float
            | PlStruct String [PlTerm]
 deriving Eq

----------------------------------------------------------------------------