bergamot-elm/src/Main.elm

43 lines
980 B
Elm
Raw Normal View History

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 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 11:58:20 -08:00
type alias Model = { program : 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 11:43:38 -08:00
init : Flags -> (Model, Cmd Msg)
2023-11-26 11:58:20 -08:00
init () = ({ program = "" }, Cmd.none)
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 ] []
, Html.p [] [ Html.text (Debug.toString (run program m.program)) ]
]
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 11:43:38 -08:00
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}