6 ms·
From https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0282-record-dot-syntax.rst#lexer https://github.com/ghc-proposals/ghc-proposals/blob/m
by duijf 6y ago
From https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0282-record-dot-syntax.rst#lexer https://github.com/ghc-proposals/ghc-proposals/blob/master/p...
.g is a field selector.
f.g is field selection of a record.
f . g is function composition.
f. g is function composition.
- moomin 6y agoWhilst I'm not going to argue the proposal is a bad thing, I think you've just summarized why some are giving it the side eye pretty well.
- ben509 6y agoTo me it's just, "the dot hugs a field, dot by itself is composition, and module names are capitalized." While I wouldn't write f. g, if I see it, it's not hugging the field name so it's composition. I don't think I'd have trouble reading it. But... it will probably trip up newbies and people with odd spacing styles. Hopefully GHC can give a useful error like "In the field selection expression f.g, g is a function defined on XX. Did you mean f . g?"
- thomasahle 6y ago(.g) us a field selector, is (. g) then a function :: (a -> b) -> c -> b?
- giraj 6y agoYep! You could check this in GHCi (the repl), for example: > :t (. id) > (. id) :: (b -> c) -> b -> c (:t prints the type of an expression, and id is the "identity function" that's b -> b here.) (EDIT: Maybe you know the above and you're asking if it's being changed in the proposal. It doesn't seem so to me.)
- thomasahle 6y agoI'm just pointing out that the difference between (.g) and (. g) is potentially easy to miss.