Created
June 13, 2018 20:13
-
-
Save eric-corumdigital/bd007b9b8abe5bf270a6df5c84009b3f to your computer and use it in GitHub Desktop.
Incremental functions category draft (PS)
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
type Jet a = { position :: a, velocity :: Change a } | |
destination :: forall a da. Patch a da => Jet a -> a | |
destination {position, velocity} = patch position (fromChange velocity) | |
newtype Incremental a b = Incremental (Jet a -> Jet b) | |
-- | Construct an incremental function from a function on Jets. The user must | |
-- | verify that these laws hold: | |
-- | | |
-- | - `∀fxy. destination x = destination y ⇒ destination (f x) = destination (f y)` | |
-- | - `∀fxy. x.position = y.position ⇒ (f x).position = (f y).position` | |
incremental :: forall a b. (Jet a -> Jet b) -> Incremental a b | |
incremental = Incremental | |
instance semigroupoidIncremental :: Semigroupoid Incremental where | |
compose (Incremental f) (Incremental g) = Incremental (compose f g) | |
instance categoryIncremental :: Category Incremental where | |
identity = Incremental identity | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment