News for hackers. Stuff that matters.
Re:Idioms of Dynamic Languages by doomrobo on Tuesday July 03, 2018 @04:11PM (#17453288)

    // By contrast, Rust (and I believe Haskell?) require  exhaustive matching:
    let MyValue::String(ref s) = map[&200]; // Invalid!
This is called irrefutable pattern matching in Rust terminology. Haskell actually doesn't enforce this at compile time. Consider the program

    data Foo = A Int | B Int

    x :: Foo
    x = A 10

    -- Do an invalid pattern match
    y :: Int
    y = let (B i) = x in i

    main :: IO ()
    main = do
      print y
This compiles without warning and gives the error at runtime:

    foo: foo.hs:8:9-17: Irrefutable pattern failed for pattern B i

There are no comments on this comment yet.