-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
logic: make S.and and S.or monomorphic, and remove S.xor
The first of the three functions to be added was S.or, to allow: > S.or(S.Nothing, S.Just(42)) Just(42) This is possible in Haskell too: > Nothing <|> Just 42 Just 42 The <|> operator, though, does not accept Boolean operands, as the Bool type does not satisfy the requirements of the Alternative type class. The Bool type has two monoids: - All - mempty = True - mappend = (&&) - Any - mempty = False - mappend = (||) Overloading S.or for Boolean arguments requires implicitly selecting All as the Boolean monoid. This necessitates the definition and use of a Sanctuary-specific Monoid-like type class (the standard Monoid type class defined in sanctuary-type-classes rejects Boolean values because fantasy-land/empty is not defined for the Boolean type). This commit updates the type of S.or to match that of Haskell's (||): S.or :: Boolean -> Boolean -> Boolean The <|> behaviour currently provided by S.or is undoubtedly useful, but will be provided by S.alt once Sanctuary wrappers are added for the functions defined in sanctuary-type-classes: S.alt :: Alt f => f a -> f a -> f a S.and is currently polymorphic for consistency with S.or rather than to address any particular need. This commit updates the type of S.and to match that of Haskell's (&&): S.and :: Boolean -> Boolean -> Boolean Boolean XOR does not warrant inclusion, so this commit removes S.xor. This commit also removes the "toBoolean" methods which existed solely to allow S.and, S.or, and S.xor to operate on Maybe and Either values.
- Loading branch information
1 parent
3d080fe
commit 1958895
Showing
8 changed files
with
42 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.