2023-11-26 11:43:38 -08:00
|
|
|
module Main exposing (main)
|
|
|
|
|
|
|
|
import Browser
|
|
|
|
import Html exposing (Html)
|
2023-11-26 11:58:20 -08:00
|
|
|
import Html.Events exposing (onInput)
|
2023-11-26 12:47:05 -08:00
|
|
|
import Html.Attributes exposing (type_)
|
2023-11-26 11:43:38 -08:00
|
|
|
import Bergamot.Syntax exposing (..)
|
|
|
|
import Bergamot.Search exposing (..)
|
|
|
|
import Bergamot.Rules exposing (..)
|
|
|
|
import Bergamot.Parser exposing (..)
|
|
|
|
import Maybe
|
|
|
|
import Tuple
|
|
|
|
import Debug
|
|
|
|
|
2023-11-26 12:47:05 -08:00
|
|
|
type alias Model =
|
|
|
|
{ program : String
|
|
|
|
, query : String
|
|
|
|
}
|
2023-11-26 11:43:38 -08:00
|
|
|
type alias Flags = ()
|
2023-11-26 11:58:20 -08:00
|
|
|
type Msg
|
|
|
|
= SetProgram String
|
2023-11-26 12:47:05 -08:00
|
|
|
| SetQuery String
|
2023-11-26 11:43:38 -08:00
|
|
|
|
|
|
|
init : Flags -> (Model, Cmd Msg)
|
2023-11-26 12:47:05 -08:00
|
|
|
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)
|
|
|
|
_ -> Nothing
|
2023-11-26 11:43:38 -08:00
|
|
|
|
|
|
|
view : Model -> Html Msg
|
2023-11-26 11:58:20 -08:00
|
|
|
view m = Html.div []
|
|
|
|
[ Html.textarea [ onInput SetProgram ] []
|
2023-11-26 12:47:05 -08:00
|
|
|
, Html.br [] []
|
|
|
|
, Html.input [ type_ "text", onInput SetQuery ] []
|
|
|
|
, Html.p [] [ Html.text (Debug.toString (proveQuery m.program m.query)) ]
|
2023-11-26 11:58:20 -08:00
|
|
|
]
|
2023-11-26 11:43:38 -08:00
|
|
|
|
|
|
|
update : Msg -> Model -> (Model, Cmd Msg)
|
|
|
|
update msg m =
|
|
|
|
case msg of
|
2023-11-26 11:58:20 -08:00
|
|
|
SetProgram prog -> ({ m | program = prog }, Cmd.none)
|
2023-11-26 12:47:05 -08:00
|
|
|
SetQuery query -> ({ m | query = query }, Cmd.none)
|
2023-11-26 11:43:38 -08:00
|
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
|
|
subscriptions _ = Sub.none
|
|
|
|
|
|
|
|
main =
|
|
|
|
Browser.element
|
|
|
|
{ init = init
|
|
|
|
, view = view
|
|
|
|
, update = update
|
|
|
|
, subscriptions = subscriptions
|
|
|
|
}
|