This module provides infix versions of Elm's Bitwise module functions. This greatly eases conversion of existing JavaScript code. Intead of changing infix to prefix, just prepend a twiddle (~) to the operators.
Bitwise.not has no infix operator, since Elm doesn't provide
single argument "infix" operators. So I named it
BitwiseInfix.lognot, in honor of its Common Lisp name.
It is intended to be imported exposing (..), so that the operators can appear unadorned in your code.
All the operators are left associative.
I mirrored the JavaScript precedences, putting the shift operators at lower precedence than arithmetic, but higher than comparison, and the others lower than comparison.
(~<<), (~>>), and (~>>>) have a precedence of 5.
(~&) has a precedence of 3.
(~^) has a precedence of 2.
(~|) has a precedence of 1.
Examples:
import BitwiseInfix exposing (..)
3 ~& 1 ~| 4 ~& 12 -- 5
3 ~& (1 ~| 4) ~& 12 -- 0
2 ~<< 1 ~| 2 -- 6
2 ~<< (1 ~| 2) -- 16
1 ~| 2 ~^ 2 ~| 1 -- 1
(1 ~| 2) ~^ (2 ~| 1) -- 0
3 ~& 1 ~^ 4 ~& 12 -- 5
3 ~& (1 ~^ 4) ~& 12 -- 0
9 ~>> 1 ~<< 1 -- 8
9 ~>> (1 ~<< 1) -- 2Infix for Bitwise.or
Infix for Bitwise.xor
Alias for Bitwise.not. Elm does not provide "infix" operators with only a single argument. This name let's you import BitwiseInfix exposing (..), without worrying about name collisions.
Infix for Bitwise.shiftLeft
Infix for Bitwise.shiftRight
Infix for Bitwise.shiftRightLogical
Infix for Bitwise.and