Proposal: Data.Bool.implies
Andrew Butterfield
Andrew.Butterfield at scss.tcd.ie
Mon Jan 18 08:50:42 UTC 2016
HI Niklas,
> On 18 Jan 2016, at 02:17, Niklas Hambüchen <mail at nh2.me> wrote:
>
> I propose to add to Data.Bool:
>
> -- | Boolean implication.
> implies :: Bool -> Bool -> Bool
> implies True x = x
> implies False _ = True
Fine by me (+1)
>
> infix 4 `implies` -- same as (==)
>
> The request for this is quite old (see e.g.
> http://neilmitchell.blogspot.de/2007/02/logical-implication-in-haskell.html).
>
> I believe that by not trying to use an operator for it, and keeping it
> in Data.Bool, we can avoid doing anything wrong.
>
> A quick superficial search on Stackage Hoogle suggests that adding this
> function should create no breakage (4 packages define their own function
> called `implies`, none of them import Data.Bool).
>
> `infix` instead of `infixl` or `infixr` to force you to bracket it; for
> the same reason it has the same precedence as `==`.
In equational logic, it makes more sense for implication to bind tighter than equivalence,
and it would usually be considered as infixr
a `implies` b `implies` c same as a `implies` (b `implies` c)
But if this breaks something else then plain infix is fine....
That this is the same associativity rule as for function arrows is not a coincidence, by the way.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Andrew Butterfield
School of Computer Science & Statistics
Trinity College
Dublin 2, Ireland
More information about the Libraries
mailing list