summaryrefslogtreecommitdiff
path: root/app/Main.hs
blob: 5b9ed076322fe2d005bf19ca0650154f81e40235 (plain)
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
40
41
42
43
module Main where

import qualified Data.Map as M
import Interpreter
import Text.Pretty.Simple

ppr :: Show a => a -> IO ()
ppr =
  pPrintOpt
    CheckColorTty
    defaultOutputOptionsDarkBg
      { outputOptionsCompactParens = True
      , outputOptionsIndentAmount = 2
      , outputOptionsPageWidth = 80
      }

main :: IO ()
main = do
  let (res, interp) =
        prove [Goal, U (Struct $ Id 1 2), U (Atom 1), U (Atom 2), LastCall] $
        M.fromList
          [ ( Id 1 2
            , [ [U (Atom 333), U (Atom 444), NoGoal]
              , [ U (Atom 1)
                , U (Atom 2)
                , Goal
                , U (Struct $ Id 2 0)
                , Call
                , Goal
                , U (Struct $ Id 1 2)
                , U (Atom 333)
                , U (Atom 444)
                , LastCall
                ]
              ])
          , (Id 2 0, [[NoGoal]])
          ]
  ppr interp
  ppr res

{-
ppr $ let { Right l = parse lexPrlg "stdin" "c(cc(X)) :- a, b. " ; Right p = parse parsePrlg "stdin" l; clause:_ = map (ast2prlg defaultOps) p; ((StrTable _ strfwd strback),codei) = strtablizePrlg emptystrtable clause } in compileRule (Id (strfwd M.! ":-") 2) (Id (strfwd M.! ",") 2) codei
 -}