[Haskell-cafe] Nested (=>) (Was: On finding the right exposition...)
Ben Franksen
ben.franksen at online.de
Tue Oct 5 05:31:56 UTC 2021
Am 04.10.21 um 18:12 schrieb Henning Thielemann:
> On Mon, 4 Oct 2021, Ben Franksen wrote:
>> Talking of inconsistencies, Haskell is not without some of those. For
>> instance, I never understood why (->) is right associative in types,
>> but (=>) is not and you are instead supposed to pack constraints in a
>> tuple. (It works in some simple cases but not consistently.)
>
> I use nested (=>) frequently. GHC allows it in type signatures but not
> in super-class constraints. Would be cool to be allowed everywhere, as
> it supports the "terminator syntax style".
I am having second thoughts. The analogy of => with -> breaks down when
you consider that the order of constraints never matters. Despite the
tuple-like notation, I guess the better intuition is that constraints
are always sets, "," is union, and simple constraints are singleton
sets. This also works better when using constraint synonyms such as
type OrderedNum a = (Num a, Ordered a)
I can write
f :: (OrderedNum a, Floating a) => a -> a
which would otherwise be a nested tuple?
Cheers
Ben
--
I would rather have questions that cannot be answered, than answers that
cannot be questioned. -- Richard Feynman
More information about the Haskell-Cafe
mailing list