This file contains hidden or 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
module Profunctorial where | |
import Control.Applicative | |
import Data.Function | |
import Data.Functor | |
import Data.Functor.Contravariant | |
import Data.Profunctor | |
import Witherable | |
class Foldable f where |
This file contains hidden or 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
module Constraint.Trans where | |
class (forall a. c a => d (f a)) | |
=> CFunctor c d f | f -> c, f -> d where | |
-- prop> cmap id = id | |
-- prop> cmap (g . f) = cmap g . cmap f | |
cmap :: (c a, c b) => (a -> b) -> f a -> f b | |
class CFunctor c d f | |
=> CTrans c d f where |
This file contains hidden or 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
Given distributive categories | |
* -C>, >C<, 1C, +C+, 0C | |
* -D>, >D<, 1D, +D+, 0D | |
An alternative functor consists of | |
* A functor | |
- F : C -> D | |
* morphisms | |
- eps : 1D -D> F(1C) | |
- mu : F(a) >D< F(b) -D> F(a >C< b) |
This file contains hidden or 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
newtype Grammar a b = Grammar | |
(Loop (String := Production) () (Production a b)) | |
type Production = DistAlt (ChooseMon (Token Char Char)) | |
newtype Loop p a b = Loop | |
{ runLoop | |
:: forall q. ArrowLoop q | |
=> (forall x y. p x y -> q x y) | |
-> q a b |
This file contains hidden or 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
module Data.Distributor | |
( -- * lax monoidal profunctors | |
Monoidal (unit, (>*<)) , dimap2, (>*), (*<) | |
, replicateP, replicateP_, foreverP | |
, Mon (Mon), liftMon | |
-- * lax distributors | |
, Distributor (zero, (>+<), several, several1, possibly) | |
, dialt, (>|<) | |
, Dist (DistEmpty, DistEither) | |
, DistAlt (DistAlts), liftDistAlt |
This file contains hidden or 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 | |
DeriveAnyClass | |
, DeriveGeneric | |
, DerivingStrategies | |
, GADTs | |
, LambdaCase | |
, OverloadedStrings | |
#-} | |
module Migratory where |
This file contains hidden or 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 |
This file contains hidden or 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 FlexibleContexts , ScopedTypeVariables , TypeFamilies #-} | |
import Data.Proxy | |
class Problem p where | |
type State p :: * | |
data Action p :: * | |
actions :: State p -> [Action p] | |
result :: State p -> Action p -> State p |