arliss_obsidian/fp/Language/Infix Operators/Common Operators/Boolean Logic.md

29 lines
1.5 KiB
Markdown
Raw Normal View History

2024-09-23 23:56:55 +00:00
[[Infix Operators]] used for [[Boolean|boolean]] algebra.
> [!info]
> `&&` and `||` become short-circuiting when used on functions, e.g. `Unit -> Boolean`:
>
> ```haskell
> a :: Unit -> Boolean
> a _ = false
>
> b :: Unit -> Boolean
> b _ = unsafeCrashWith "uh-oh!"
>
> c :: Unit -> Boolean
> c = a && b
>
> d :: Unit -> Boolean
> d = c unit
> ```
|Operator|Description|Associativity|Precedence|Defined As|
|--|--|--|--|--|
|<code>&vert;&vert;</code>|boolean OR|right|2|[`Data.HeytingAlgrebra.disj`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.HeytingAlgebra#v:(||))
|`&&`|boolean AND|right|3|[`Data.HeytingAlgrebra.conj`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.HeytingAlgebra#v:(&&))|
|`==`|equals|not|4|[`Data.Eq.eq`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.Eq#v:(==))|
|`/=`|not equals|||[`Data.Eq.notEq`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.Eq#v:(/=))|
|`>`|greater than|||[`Data.Ord.greaterThan`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.Ord#v:(>))|
|`<`|less than|||[`Data.Ord.lessThan`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.Ord#v:(<))|
|`>=`|greater than or equal|||[`Data.Ord.greaterThanOrEq`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.Ord#v:(>=))|
|`<=`|less than or equal|||[`Data.Ord.lessThanOrEq`](https://pursuit.purescript.org/packages/purescript-prelude/docs/Data.Ord#v:(<=))|