Commit d5085da0 authored by Thorsten Wißmann's avatar Thorsten Wißmann 🐧
Browse files

Migrate remaining modules

parent 83b2ed8a
......@@ -7,6 +7,7 @@ import Html.Attributes as HA
import Html.Events exposing (onClick)
import Html.Events as HE
import RailTree as RT
import Browser
import RailTree exposing (RailTree)
import RailPuzzle
import RailPuzzle.Command as RPCmd
......@@ -23,13 +24,21 @@ import NuSmvInput
import Char
import Json.Decode as Json
import Regex
import Regex exposing (regex)
import Regex exposing (fromString)
import ListUtils
import Shunt
import RailPuzzle.History as RPHist
import MultiLang
import Overlay
{-| migration to elm 0.19 |-}
toString = String.fromInt
regex src =
Maybe.withDefault Regex.never <|
Regex.fromString src
parseInt : String -> Result String Int
parseInt s = Result.fromMaybe ("Invalid int '" ++ s ++ "'") (String.toInt s)
type alias Flags =
{ clickableHeader : Bool
, minimalInterface : Bool -- whether to show a more minimal 'mobile' version
......@@ -58,7 +67,7 @@ type Msg
| NextPuzzle
main =
Html.programWithFlags
Browser.element
{ init = init
, view = view
, update = update
......@@ -108,7 +117,7 @@ subscriptions model =
]
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
update msg_packed model =
let
validateIndex : Array a -> Int -> Result String (Int,a)
validateIndex arr idx =
......@@ -124,7 +133,7 @@ update msg model =
Nothing ->
array
in
case msg of
case msg_packed of
ForRails msg ->
({ model | rails = RailPuzzle.update msg model.rails }, Cmd.none)
......@@ -157,7 +166,7 @@ update msg model =
)
SwitchNet str_idx ->
case (String.toInt str_idx |> Result.andThen (validateIndex model.archive)) of
case (parseInt str_idx |> Result.andThen (validateIndex model.archive)) of
Err m ->
Debug.log "Selected index not valid" m
|> always (model, Cmd.none)
......@@ -193,7 +202,7 @@ update msg model =
, Cmd.none
)
SwitchQuery str_idx ->
case (String.toInt str_idx |> Result.andThen (validateIndex model.queries)) of
case (parseInt str_idx |> Result.andThen (validateIndex model.queries)) of
Err m ->
Debug.log "Selected index not valid" m
|> always (model, Cmd.none)
......@@ -323,11 +332,9 @@ viewNavigation model =
noclick <| [ a main_page_url
[ img
[ HA.src "logo_negated.png"
, HA.style
[Tuple.pair "height" "2.4em"
,Tuple.pair "margin" "-5px -5px"
--,Tuple.pair "border" "1px solid red"
]
, HA.style "height" "2.4em"
, HA.style "margin" "-5px -5px"
-- , HA.style "border" "1px solid red"
] []
]
]
......@@ -336,7 +343,7 @@ viewNavigation model =
( if model.flags.showRestart
then (::) <|
noclick <| [ Html.a
[ HA.style [Tuple.pair "font-weight" "bold" ]
[ HA.style "font-weight" "bold"
, HA.href "rails.html"
]
[ MultiLang.text "Restart" "Neu Starten"]
......@@ -346,7 +353,7 @@ viewNavigation model =
[ link (ForRails RailPuzzle.undo) "Undo" "Rückgängig"
, link resetCars "Reset All Cars" "Zurücksetzen"
, noclick <| [ Html.span
[ HA.style [Tuple.pair "margin-right" "1em"] ]
[ HA.style "margin-right" "1em" ]
[ Html.text "Puzzle:"]
, net_switcher
]
......
......@@ -9,7 +9,7 @@ import ListUtils
import RailPuzzle
import RailPuzzle.Command as RPCmd
import Regex
import Regex exposing (regex)
import Regex exposing (fromString)
import Ports
import Shunt
import String
......@@ -17,6 +17,14 @@ import Json.Decode as Json
import NuSmvOutput
import RailExample exposing (RailExample)
{-| migration to elm 0.19 |-}
flip f a b = f b a
uncurry f (a,b) = f a b
toString = String.fromInt
regex src =
Maybe.withDefault Regex.never <|
Regex.fromString src
type alias Model =
{ validated_trace : Result String (List P.TraceLine)
, showSmvOptions : Bool
......@@ -43,9 +51,6 @@ type Msg
| StickToBottom Bool
| Screenshot
{-| added for elm 0.19 migration -}
uncurry f (a,b) = f a b
init : (Model, RPCmd.Command)
init =
let
......@@ -243,9 +248,9 @@ compileTraceLine line =
parseQuery : String -> List Int
parseQuery =
-- extract all numbers, no matter how they are separated
Regex.find Regex.All (regex "[0-9]+")
Regex.find (regex "[0-9]+")
>> List.map (.match)
>> List.filterMap (Result.toMaybe << String.toInt)
>> List.filterMap String.toInt
>> List.map (\x -> x - 1) -- make them 0-indexed.
>> ListUtils.dropDuplicates
......@@ -296,7 +301,7 @@ viewTraceResult traceline_idx res =
]
in
case line of
P.Specification query res ->
P.Specification query _ ->
Html.div
[ html_id
, classes "traceSpecification"
......
......@@ -17,6 +17,11 @@ import NonEmptyList as NEL
import NonEmptyList exposing (NonEmptyList)
import ArrayTree exposing (ArrayTree)
{-| migration to elm 0.19 |-}
flip f a b = f b a
uncurry f (a,b) = f a b
toString = String.fromInt
docLines : List String -> String
docLines =
String.concat << List.intersperse "\n" << List.map ((++) "-- ")
......@@ -509,8 +514,8 @@ showCondition cond =
And conds ->
n_ary conds "TRUE" " & "
Not cond ->
"! " ++ showCondition cond
Not cond_ ->
"! " ++ showCondition cond_
indentString : String -> String
indentString =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment