[Haskell-cafe] Records in Haskell

Evan Laforge qdunkan at gmail.com
Mon Feb 27 23:10:06 CET 2012


[ ccing the list because the wiki page was flawed and I made a bunch
of changes, hope you don't mind ]

> Thanks Evan, but I think that wiki page isn't doing your
> proposal justice. There seem to be several typos in critical
> places that make it hard to follow (for me at least).

Sorry about the sloppy editing.  I updated it and added more detailed
examples.  I also realized that as stated it didn't quite work for
lens updates, so I extended it a little.

> I think it would really help to include a record decl. to
> show where `a` comes from, especially since you say that
> record syntax doesn't change.

Good point, added.

> Could you explain what the TH does. Perhaps give an example
> of what gets generated from a record decl?

Sure, I added an example of that too.

> And perhaps you could explain what you mean by a "type
> directed function"? Aren't all overloaded functions type
> directed? Can I have both a `#f` and a `f` in scope? What's
> the difference?

The idea is they're not overloaded functions.  #f is not a symbol that
can be in scope, it's special syntax to go *find* a `f` in some
module.  So `x = #f` is not in conflict with `x = f` provided #f is
desugared to SomeModule.f.  Unless of course the argument is defined
in the current module, in which case it will desugar to plain `f` and
then they will be the same.  Since it's syntax for resolving a name,
assigning it like `#f = xyz` doesn't make sense since you can't put a
qualified name on the left of an `=` sign.



More information about the Haskell-Cafe mailing list