Created
November 26, 2022 12:40
-
-
Save Lysxia/ebe3bef85e11bd13928c94beb56aa7ab to your computer and use it in GitHub Desktop.
What is this called?
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
-- | Ordered affine spaces are made of points and vectors. | |
-- | |
-- - Vectors can be added, that's the 'Semigroup' superclass. | |
-- - Points can be translated along vectors using @('.+')@. | |
-- - Given two ordered points @i <= j@, @j '.-.?' i@ finds a vector @n@ | |
-- such that @i + n = j@. | |
-- | |
-- In other words, we only require the existence of "positive" vectors. | |
-- | |
-- __Laws:__ | |
-- | |
-- @ | |
-- (x '.+' v) '.+' w = x '.+' (v '<>' w) | |
-- x '<=' y ==> x '.+' (y '.-.' x) = y | |
-- (x '.+' v) '.-.' x = x | |
-- @ | |
class (Ord (Point v), Semigroup v) => Affine v where | |
type Point v | |
infixr 6 .+ | |
-- | Translation. | |
(.+) :: Point v -> v -> Point v | |
-- | Vector between two points. | |
-- @j .-.? i@ must be defined ('Just') if @i <= j@, | |
(.-.?) :: Point v -> Point v -> Maybe v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment