Last active
August 29, 2015 14:04
-
-
Save Ezku/6e01a03f2e36c5edbf46 to your computer and use it in GitHub Desktop.
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
# See: https://github.com/fantasyland/fantasy-land#comonad | |
# data Store b a = Store b (b -> a) | |
# instance Comonad (Store b) | |
class Store | |
# { value: b, set: (b -> a) } -> Store b a | |
constructor: ({@value, @set}) -> | |
# () -> b | |
from: -> @value | |
# () -> a | |
extract: -> @set @value | |
# (a -> c) -> Store b c | |
map: (f) -> new Store @value, (b) -> f @set b | |
# (Store b a -> b) -> Store b a | |
extend: (f) -> new Store (f this), @inject |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment