g :: b -> c
f :: r -> a -> b
(g .) . f :: r -> a -> c
[x+1..] -- [x+1, x+2, ..]
The thread that runs main
in a Haskell program is a bound thread (slow). The best way around this problem is just to create a new thread from the main and work in that instead. [Parallelism and Concurrency in Haskell, chapter 15, page 248].
-- fromIntegral is broken
>>> fromIntegral (2^1280 ::Integer) :: Word64
0
Yoneda Lemma:
newtype Yoneda f a = Yoneda { runYoneda :: forall b. (a -> b) -> f b }
liftYoneda :: Functor f => f a -> Yoneda f a
liftYoneda a = Yoneda (\f -> fmap f a)
lowerYoneda :: Yoneda f a -> f a
lowerYoneda (Yoneda f) = f id
co-Yoneda Lemma (contravariant functor):
data Coyoneda f a where
Coyoneda :: (b -> a) -> f b -> Coyoneda f a
liftCoyoneda :: f a -> Coyoneda f a
liftCoyoneda = Coyoneda id
lowerCoyoneda :: Functor f => Coyoneda f a -> f a
lowerCoyoneda (Coyoneda f m) = fmap f m