So what will this mean now? Will function composition require a space between the dot, or how will a “record dot” be disambiguated?
.g is a field selector.
f.g is field selection of a record.
f . g is function composition.
f. g is function composition.
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?"
> :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.)
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.It looks like the "record dot" follows the same parsing rules as the "module dot": the presence of whitespace turns the . into function composition.