[ghc-steering-committee] Record syntax

Joachim Breitner mail at joachim-breitner.de
Fri Jan 10 16:34:39 UTC 2020


Hi,

Am Freitag, den 10.01.2020, 10:08 -0500 schrieb Eric Seidel:
> The important thing for this discussion is that by invoking the
> method chaining example, we're implicitly endorsing either virtual
> fields or some other yet-to-be-designed way of treating functions as
> fields[1]. I think we should be more explicit about that.

Well, or simply records that store functions, some of which return such
records. Think common idioms like explicit dictionaries. Or something
like


   data Automaton a b =
     { val :: a
     , next :: b -> Automaton a b
     }


   print $ a.next "hello"
            .next "word"
            .val

And I am sure our users would find other great use of that features.


But to me, function chaining a nice side-effect of (2).

What I really like about 2 is that that "r .x" can be explained using
function application (it evaluates the record, seen as a function with
a finite set of field names as its domain, by passing it the argument
.f), and by using the same syntax as function application, many
questions about parsing are already answered, in a nicely consistent
way.

Cheers,
Joachim

-- 
Joachim Breitner
  mail at joachim-breitner.de
  http://www.joachim-breitner.de/




More information about the ghc-steering-committee mailing list