cifl-math-library-1.1.1.0: Math libraries
Safe HaskellSafe
LanguageHaskell2010

Math.Tools.CoMonad

Synopsis

Documentation

class Functor w => Coapplicative w where Source #

Methods

coeval :: w a -> a Source #

colambda :: (w a -> w b) -> w (a -> b) Source #

Instances

Instances details
Coapplicative Vector3 Source # 
Instance details

Defined in Math.Matrix.Vector3

Methods

coeval :: Vector3 a -> a Source #

colambda :: (Vector3 a -> Vector3 b) -> Vector3 (a -> b) Source #

class Functor w => Comonad w where Source #

From youtube video "Category theory II 7.2: Comonads categorically and examples" by Bartosz Milewski, comonad has a "focal point" defined by extract operation, and a mechanism for applying a cokleisli arrow to the whole environment [e.g. if you give average to extend, you'd smooth the whole data structure].

Minimal complete definition

extract

Methods

extract :: w a -> a Source #

duplicate :: w a -> w (w a) Source #

extend :: (w a -> b) -> w a -> w b Source #

(=>>) :: w a -> (w a -> b) -> w b Source #

(.>>) :: w a -> b -> w b Source #

Instances

Instances details
Comonad Vector2 Source # 
Instance details

Defined in Math.Matrix.Vector2

Methods

extract :: Vector2 a -> a Source #

duplicate :: Vector2 a -> Vector2 (Vector2 a) Source #

extend :: (Vector2 a -> b) -> Vector2 a -> Vector2 b Source #

(=>>) :: Vector2 a -> (Vector2 a -> b) -> Vector2 b Source #

(.>>) :: Vector2 a -> b -> Vector2 b Source #

Comonad Vector3 Source # 
Instance details

Defined in Math.Matrix.Vector3

Methods

extract :: Vector3 a -> a Source #

duplicate :: Vector3 a -> Vector3 (Vector3 a) Source #

extend :: (Vector3 a -> b) -> Vector3 a -> Vector3 b Source #

(=>>) :: Vector3 a -> (Vector3 a -> b) -> Vector3 b Source #

(.>>) :: Vector3 a -> b -> Vector3 b Source #

Comonad Vector4 Source # 
Instance details

Defined in Math.Matrix.Vector4

Methods

extract :: Vector4 a -> a Source #

duplicate :: Vector4 a -> Vector4 (Vector4 a) Source #

extend :: (Vector4 a -> b) -> Vector4 a -> Vector4 b Source #

(=>>) :: Vector4 a -> (Vector4 a -> b) -> Vector4 b Source #

(.>>) :: Vector4 a -> b -> Vector4 b Source #

Comonad StreamIndex Source # 
Instance details

Defined in Math.Number.Stream

Comonad Stream Source # 
Instance details

Defined in Math.Number.Stream

Methods

extract :: Stream a -> a Source #

duplicate :: Stream a -> Stream (Stream a) Source #

extend :: (Stream a -> b) -> Stream a -> Stream b Source #

(=>>) :: Stream a -> (Stream a -> b) -> Stream b Source #

(.>>) :: Stream a -> b -> Stream b Source #

Comonad (CoState s) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

extract :: CoState s a -> a Source #

duplicate :: CoState s a -> CoState s (CoState s a) Source #

extend :: (CoState s a -> b) -> CoState s a -> CoState s b Source #

(=>>) :: CoState s a -> (CoState s a -> b) -> CoState s b Source #

(.>>) :: CoState s a -> b -> CoState s b Source #

Comonad ((,) a) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

extract :: (a, a0) -> a0 Source #

duplicate :: (a, a0) -> (a, (a, a0)) Source #

extend :: ((a, a0) -> b) -> (a, a0) -> (a, b) Source #

(=>>) :: (a, a0) -> ((a, a0) -> b) -> (a, b) Source #

(.>>) :: (a, a0) -> b -> (a, b) Source #

Adjunction g f => Comonad (AdjM f g) Source # 
Instance details

Defined in Math.Tools.Monad

Methods

extract :: AdjM f g a -> a Source #

duplicate :: AdjM f g a -> AdjM f g (AdjM f g a) Source #

extend :: (AdjM f g a -> b) -> AdjM f g a -> AdjM f g b Source #

(=>>) :: AdjM f g a -> (AdjM f g a -> b) -> AdjM f g b Source #

(.>>) :: AdjM f g a -> b -> AdjM f g b Source #

Comonad ((->) FiveD) Source # 
Instance details

Defined in Math.Matrix.Simple

Methods

extract :: (FiveD -> a) -> a Source #

duplicate :: (FiveD -> a) -> FiveD -> (FiveD -> a) Source #

extend :: ((FiveD -> a) -> b) -> (FiveD -> a) -> FiveD -> b Source #

(=>>) :: (FiveD -> a) -> ((FiveD -> a) -> b) -> FiveD -> b Source #

(.>>) :: (FiveD -> a) -> b -> FiveD -> b Source #

Comonad ((->) FourD) Source # 
Instance details

Defined in Math.Matrix.Simple

Methods

extract :: (FourD -> a) -> a Source #

duplicate :: (FourD -> a) -> FourD -> (FourD -> a) Source #

extend :: ((FourD -> a) -> b) -> (FourD -> a) -> FourD -> b Source #

(=>>) :: (FourD -> a) -> ((FourD -> a) -> b) -> FourD -> b Source #

(.>>) :: (FourD -> a) -> b -> FourD -> b Source #

Comonad ((->) SixD) Source # 
Instance details

Defined in Math.Matrix.Simple

Methods

extract :: (SixD -> a) -> a Source #

duplicate :: (SixD -> a) -> SixD -> (SixD -> a) Source #

extend :: ((SixD -> a) -> b) -> (SixD -> a) -> SixD -> b Source #

(=>>) :: (SixD -> a) -> ((SixD -> a) -> b) -> SixD -> b Source #

(.>>) :: (SixD -> a) -> b -> SixD -> b Source #

Comonad ((->) ThreeD) Source # 
Instance details

Defined in Math.Matrix.Simple

Methods

extract :: (ThreeD -> a) -> a Source #

duplicate :: (ThreeD -> a) -> ThreeD -> (ThreeD -> a) Source #

extend :: ((ThreeD -> a) -> b) -> (ThreeD -> a) -> ThreeD -> b Source #

(=>>) :: (ThreeD -> a) -> ((ThreeD -> a) -> b) -> ThreeD -> b Source #

(.>>) :: (ThreeD -> a) -> b -> ThreeD -> b Source #

Comonad ((->) TwoD) Source # 
Instance details

Defined in Math.Matrix.Simple

Methods

extract :: (TwoD -> a) -> a Source #

duplicate :: (TwoD -> a) -> TwoD -> (TwoD -> a) Source #

extend :: ((TwoD -> a) -> b) -> (TwoD -> a) -> TwoD -> b Source #

(=>>) :: (TwoD -> a) -> ((TwoD -> a) -> b) -> TwoD -> b Source #

(.>>) :: (TwoD -> a) -> b -> TwoD -> b Source #

(Comonad f, Comonad g, forall a. Transposable g f a, forall b. Transposable f g b, forall a. Diagonalizable f (f (g a)), forall a. LinearTransform g f (f (g a)), forall a. Diagonalizable g (g a), forall a. LinearTransform f g (g a)) => Comonad (f :*: g) Source #

See video by Bartosz Milewski ("Category theory II 7.2: Comonads categorically and examples")

Instance details

Defined in Math.Matrix.Matrix

Methods

extract :: (f :*: g) a -> a Source #

duplicate :: (f :*: g) a -> (f :*: g) ((f :*: g) a) Source #

extend :: ((f :*: g) a -> b) -> (f :*: g) a -> (f :*: g) b Source #

(=>>) :: (f :*: g) a -> ((f :*: g) a -> b) -> (f :*: g) b Source #

(.>>) :: (f :*: g) a -> b -> (f :*: g) b Source #

class Comonad w => CircularComonad w where Source #

Methods

rotate :: w a -> w a Source #

Instances

Instances details
CircularComonad Vector2 Source # 
Instance details

Defined in Math.Matrix.Vector2

Methods

rotate :: Vector2 a -> Vector2 a Source #

CircularComonad Vector3 Source # 
Instance details

Defined in Math.Matrix.Vector3

Methods

rotate :: Vector3 a -> Vector3 a Source #

CircularComonad Stream Source # 
Instance details

Defined in Math.Number.Stream

Methods

rotate :: Stream a -> Stream a Source #

class CircularComonad w => FiniteComonad w where Source #

Methods

inverseRotate :: w a -> w a Source #

Instances

Instances details
FiniteComonad Vector3 Source # 
Instance details

Defined in Math.Matrix.Vector3

class Comonad w => BinaryTreeComonad w where Source #

Methods

nextLevel :: w a -> (w a, w a) Source #

class Comonad w => TernaryTreeComonad w where Source #

Methods

nextLevel3 :: w a -> (w a, w a, w a) Source #

class Comonad w => ChainComonad w where Source #

Methods

coMonadChain :: w a -> Maybe (w a) Source #

class Comonad w => TreeComonad w where Source #

Methods

children :: w a -> [w a] Source #

class Comonad w => DenseComonad w where Source #

Methods

dense_comonad_split :: w a -> w (a, a) Source #

class Comonad w => NonemptyComonad w where Source #

Methods

nonzero :: w a -> Either a (w a) Source #

class CircularComonad w => InfiniteComonad w where Source #

Methods

comonad_pre :: a -> w a -> w a Source #

Instances

Instances details
InfiniteComonad Stream Source # 
Instance details

Defined in Math.Number.Stream

Methods

comonad_pre :: a -> Stream a -> Stream a Source #

class UncertainComonad w where Source #

Methods

perhaps :: w a -> w (Maybe a) Source #

preList :: (InfiniteComonad w, Foldable t) => t a -> w a -> w a Source #

permute :: Comonad w => w a -> w a Source #

wmap :: Comonad w => (a -> b) -> w a -> w b Source #

class Reference w where Source #

Methods

dereference :: w a -> a Source #

invoke :: w a -> (w a -> b) -> w b Source #

new_reference :: w a -> b -> w b Source #

class Unique w where Source #

Methods

copy :: a -> (w a, a) Source #

class Continuation m where Source #

Methods

escape :: ((a -> m b) -> m a) -> m a Source #

Instances

Instances details
Continuation (Neg o) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

escape :: ((a -> Neg o b) -> Neg o a) -> Neg o a Source #

data CoState s a Source #

Constructors

CoState (s -> a) s 

Instances

Instances details
Functor (CoState s) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

fmap :: (a -> b) -> CoState s a -> CoState s b #

(<$) :: a -> CoState s b -> CoState s a #

Comonad (CoState s) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

extract :: CoState s a -> a Source #

duplicate :: CoState s a -> CoState s (CoState s a) Source #

extend :: (CoState s a -> b) -> CoState s a -> CoState s b Source #

(=>>) :: CoState s a -> (CoState s a -> b) -> CoState s b Source #

(.>>) :: CoState s a -> b -> CoState s b Source #

newtype CoKleisli w a b Source #

Constructors

CoKleisli 

Fields

Instances

Instances details
Comonad w => Category (CoKleisli w :: Type -> Type -> Type) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

id :: forall (a :: k). CoKleisli w a a #

(.) :: forall (b :: k) (c :: k) (a :: k). CoKleisli w b c -> CoKleisli w a b -> CoKleisli w a c #

Comonad w => Arrow (CoKleisli w) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

arr :: (b -> c) -> CoKleisli w b c #

first :: CoKleisli w b c -> CoKleisli w (b, d) (c, d) #

second :: CoKleisli w b c -> CoKleisli w (d, b) (d, c) #

(***) :: CoKleisli w b c -> CoKleisli w b' c' -> CoKleisli w (b, b') (c, c') #

(&&&) :: CoKleisli w b c -> CoKleisli w b c' -> CoKleisli w b (c, c') #

Functor (CoKleisli w a) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

fmap :: (a0 -> b) -> CoKleisli w a a0 -> CoKleisli w a b #

(<$) :: a0 -> CoKleisli w a b -> CoKleisli w a a0 #

data Neg o a Source #

Constructors

Neg ((a -> o) -> o) 

Instances

Instances details
Applicative (Neg o) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

pure :: a -> Neg o a #

(<*>) :: Neg o (a -> b) -> Neg o a -> Neg o b #

liftA2 :: (a -> b -> c) -> Neg o a -> Neg o b -> Neg o c #

(*>) :: Neg o a -> Neg o b -> Neg o b #

(<*) :: Neg o a -> Neg o b -> Neg o a #

Functor (Neg o) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

fmap :: (a -> b) -> Neg o a -> Neg o b #

(<$) :: a -> Neg o b -> Neg o a #

Monad (Neg o) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

(>>=) :: Neg o a -> (a -> Neg o b) -> Neg o b #

(>>) :: Neg o a -> Neg o b -> Neg o b #

return :: a -> Neg o a #

Continuation (Neg o) Source # 
Instance details

Defined in Math.Tools.CoMonad

Methods

escape :: ((a -> Neg o b) -> Neg o a) -> Neg o a Source #

evalC :: Neg o o -> o Source #

shiftC :: ((a -> Neg o o) -> Neg o o) -> Neg o a Source #

shift and reset are from Wadler: Monads and composable continuations http://citeseer.nj.nec.com/wadler93monads.html

liftC :: (a -> o) -> Neg o a -> Neg o o Source #