[MLton-user] new warn unused anomoly

Vesa Karvonen vesa.a.j.k at gmail.com
Tue Oct 21 08:09:24 PDT 2008


On Tue, Oct 21, 2008 at 5:10 PM, Sean McLaughlin <seanmcl at gmail.com> wrote:
>  I just wanted to contribute a warn-unused anomaly that doesn't occur
> on http://mlton.org/WarnUnusedAnomalies.  It regards pattern matching
> in records:
>
> structure Tmp =
> struct
>
> datatype record = R of {x : int * int}
>
> fun doit () =
>    let
>       val record = R {x = (1, 2)}
>       val R {x as (y, z)} = record
>    in
>       print (Int.toString (y + z) ^ "\n")
>    end

Actually, this isn't a warn-unused anomaly.  When you write

  label as pattern

the label is bound, but when you write

  label = pattern

the label isn't bound.  So, if you write

       val R {x = (y, z)} = record

you shouldn't get the unused warning.

BTW, I hadn't personally noticed that SML's grammar has the "label as
pattern" pattern --- I had to check this from the Definition.  So,
thanks for reporting this! :-)

-Vesa Karvonen



More information about the MLton-user mailing list