I was writing code in Elm for one page screen routing and rendering. What I accidentally discovered is that either Elm is not immutable, or it has a bug in pattern matching :-(, or, may be, it’s some scoping thing, but the former code works strange.

url : Screen -> String

url screen =

let

isCurrent ( s, l ) =

case s of

screen -> -- This ALWAYS match

Just l

_ ->

Nothing urls =

List.filterMap isCurrent screens

in

case urls of

[ u ] ->

"#" ++ u _ ->

""

I know that isCurrent can be easily rewritten with if..then..else, but from the point of my Erlang and Haskel background it shouldn’t anways match! Where am I wrong?