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