bergamot-elm/src/Main.elm
Danila Fedorin e123f24af0 Add support for reifying proof trees
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2023-11-26 13:14:44 -08:00

57 lines
1.4 KiB
Elm

module Main exposing (main)
import Browser
import Html exposing (Html)
import Html.Events exposing (onInput)
import Html.Attributes exposing (type_)
import Bergamot.Syntax exposing (..)
import Bergamot.Search exposing (..)
import Bergamot.Rules exposing (..)
import Bergamot.Parser exposing (..)
import Maybe
import Tuple
import Debug
type alias Model =
{ program : String
, query : String
}
type alias Flags = ()
type Msg
= SetProgram String
| SetQuery String
init : Flags -> (Model, Cmd Msg)
init () = ({ program = "", query = "" }, Cmd.none)
proveQuery : String -> String -> Maybe ProofTree
proveQuery progs querys =
case (run program progs, run term querys) of
(Just prog, Just query) -> single prog (prove query |> Bergamot.Rules.andThen reifyProofTree)
_ -> Nothing
view : Model -> Html Msg
view m = Html.div []
[ Html.textarea [ onInput SetProgram ] []
, Html.br [] []
, Html.input [ type_ "text", onInput SetQuery ] []
, Html.p [] [ Html.text (Debug.toString (proveQuery m.program m.query)) ]
]
update : Msg -> Model -> (Model, Cmd Msg)
update msg m =
case msg of
SetProgram prog -> ({ m | program = prog }, Cmd.none)
SetQuery query -> ({ m | query = query }, Cmd.none)
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}