[Haskell-cafe] Naming inner elements

amindfv at gmail.com amindfv at gmail.com
Thu Dec 31 02:38:43 UTC 2015

I've looked all around but haven't found a nice syntax for this -- anyone have suggestions?:

What I'd like to do is assign toplevel variable names to inner elements of a structure. Pseudocode for what I'd like to do is:

things = [
 , bar@"thing2"

The major difference from just `foo = "thing1" ; things = [foo, ...` is that it's much more visually clear which values are in `things` (imagine I create a `baz` but forget to add it to `things`).

The best I've found (which is not at all ideal) is to say e.g.:

  [  foo     , bar     , baz     ] =
    ["thing1", "thing2", "thing3"]

But of course, for starters, I run off the page very quickly.

I don't see anything in the usual places (e.g. the Haskell Report), but has anyone come across this and found an elegant solution?


More information about the Haskell-Cafe mailing list