[Haskell-cafe] Some thoughts on Type-Directed Name Resolution

Jonathan Geddes geddes.jonathan at gmail.com
Thu Feb 9 22:24:01 CET 2012

>   modifyConfig :: (Config -> a) -> (a -> a) -> Config -> Config
>   modifyConfig fr fv a = a { fr = fv (fr a)

I like this Idea. The only problem I see is this: if I'm trying to write
code that is very generic and abstract, how does the compiler know if the

> a { fr = 5 }

is targeting a field fr of the record a, or a variable fr, which is in
scope and "points to" a first-class field. The difference depends on the
record in question, so the code would work differently depending on the
context. I would think it would have to be something like

> a { :fr = 5 }

or something else syntactically distinct from current record update syntax.

With this and a few more conveniences on record syntax, lenses could go
away. For example, I'd love to see a "lambda update" syntax. For example
instead of:

> setName n r = r {name = n}

we'd write

> setName n = \{name = n}

I'd also like to see an "Update field by" syntax. Instead of

> addMr r = r { name = "Mr. " ++ (name r) }

we'd write

> addMr r = r { name => ("Mr. "++) }

or combining the previous 2:

> addMr = \{name=>("Mr. "++)}

feels very terse and "Haskelly" to me.


--J Arthur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120209/6ff00c89/attachment.htm>

More information about the Haskell-Cafe mailing list