News for hackers. Stuff that matters.
Re:Haskell RecordDotSyntax language extension proposal (Acce... by ed25519FUUU on Sunday September 20, 2020 @11:49PM (#24539609)
Not a Haskell programmer so I didn’t know about this issue, but to me this change is night and day better.
Re:Haskell RecordDotSyntax language extension proposal (Acce... by dmkolobov on Monday September 21, 2020 @12:24AM (#24539785)
It's a nuanced issue, because Haskell extensively uses the dot (.) infix operator to mean function composition. Currently, the expression `f.g` will attempt to compose the function bound to `f` with the function bound to `g`.
Re:Haskell RecordDotSyntax language extension proposal (Acce... by willtim on Monday September 21, 2020 @02:13AM (#24540350)
It's worth pointing out that Haskell has always overloaded the dot. It is used for module namespace disambiguation, e.g Set.fromList
Re:Haskell RecordDotSyntax language extension proposal (Acce... by runeks on Monday September 21, 2020 @12:15PM (#24545118)
Great point! I hadn't thought of this.

It looks like the "record dot" follows the same parsing rules as the "module dot": the presence of whitespace turns the . into function composition.

Re:Haskell RecordDotSyntax language extension proposal (Acce... by srtjstjsj on Monday September 21, 2020 @09:28AM (#24543111)
But you've got the module there to disambiguate the ., which you don't have in records.
Re:Haskell RecordDotSyntax language extension proposal (Acce... by runeks on Monday September 21, 2020 @12:12PM (#24545086)
I don't think this is true. The presence of a qualified import of "Data.Set as Set" does not change how the following is parsed.

    import Data.Set (fromList)
    import qualified Data.Set as Set


    data Set a = Set (Set.Set a)

    f :: Ord a => [a] -> Set a
    f = Set . fromList

    g :: Ord a => [a] -> Set a
    g = Set .fromList

    h :: Ord a => [a] -> Set a
    h = Set. fromList

    i :: Ord a => [a] -> Set.Set a
    i = Set.fromList
In other words, the . is interpreted as a "module dot" if and only if there is no whitespace either preceding or following the dot.
Re:Haskell RecordDotSyntax language extension proposal (Acce... by runeks on Monday September 21, 2020 @01:58AM (#24540265)
> Currently, the expression `f.g` will attempt to compose the function bound to `f` with the function bound to `g`.

So what will this mean now? Will function composition require a space between the dot, or how will a “record dot” be disambiguated?

Re:Haskell RecordDotSyntax language extension proposal (Acce... by duijf on Monday September 21, 2020 @02:37AM (#24540481)
From 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.

Re:Haskell RecordDotSyntax language extension proposal (Acce... by moomin on Monday September 21, 2020 @04:19AM (#24540996)
Whilst 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.
Re:Haskell RecordDotSyntax language extension proposal (Acce... by ben509 on Wednesday September 23, 2020 @11:01AM (#24567922)
To 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?"

Re:Haskell RecordDotSyntax language extension proposal (Acce... by thomasahle on Monday September 21, 2020 @04:20AM (#24540999)
(.g) us a field selector, is (. g) then a function :: (a -> b) -> c -> b?
Re:Haskell RecordDotSyntax language extension proposal (Acce... by giraj on Monday September 21, 2020 @07:57AM (#24542264)
Yep! 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.)

Re:Haskell RecordDotSyntax language extension proposal (Acce... by thomasahle on Monday September 21, 2020 @11:09AM (#24544331)
I'm just pointing out that the difference between (.g) and (. g) is potentially easy to miss.