Last active
January 27, 2018 00:11
-
-
Save echatav/362fac156c779a7fbac36eb2080fc047 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
{-# LANGUAGE ExistentialQuantification #-} | |
import Prelude hiding (id,(.)) | |
import Control.Category | |
data Learn a b | |
= forall p. Learn | |
{ impl :: p -> a -> b | |
, update :: p -> a -> b -> p | |
, request :: p -> a -> b -> a | |
} | |
instance Category Learn where | |
id = Learn | |
{ impl = \ _ a -> a | |
, update = \ _ _ _ -> () | |
, request = \ _ a _ -> a | |
} | |
Learn j v s . Learn i u r = Learn | |
{ impl = \ (p, q) a -> j q (i p a) | |
, update = \ (p, q) a c -> | |
( u p a (s q (i p a) c) | |
, v q (i p a) c | |
) | |
, request = \ (p, q) a c -> r p a (s q (i p a) c) | |
} | |
data Para a b = forall p. Para (p -> a -> b) | |
instance Category Para where | |
id = Para (\ _ a -> a) | |
Para j . Para i = Para (\ (p, q) a -> j q (i p a)) | |
learn :: Para a b -> Learn a b | |
learn (Para i) = Learn | |
{ impl = i | |
, update = undefined | |
, request = undefined | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment