Welcome! Got a question? Do you have -Ypartial-unification turned on? Other FAQs: http://typelevel.org/cats/faq.html
Coyoneda
as well, so it's actually closer to Coyoneda
in haskell
a good way of looking at it is noting how Monad
can be expressed as either (forgetting Applicative
)
class Functor f => Monad f where
pure :: a -> f a
join :: f (f a) -> f a
or
class Monad f where
pure :: a -> f a
(>>=) :: f a -> (a -> f b) -> f b
.
The first definition gives rise to
data Free f a = Pure a | Roll (f (Free f a))
instance Functor f => Monad (Free f) where ...
and your algebra looks this way:
data Alg a = Put String a | Get String (String -> a)
instance Functor Alg where
The second definition, which is Operational
(and cats Free) gives rise to
data Free f a where
Pure :: a -> Free fa
FlatMap :: f a -> (a -> Free f b) -> Free f b
instance Monad (Free f a) -- note no Functor
and your algebra looks this way
data Alg a where
Put :: String -> Alg ()
Get :: String -> Alg String
and no Functor needed
Functor
for your algebra
class Functor f where
fmap :: (a -> b) -> f a -> f b
data Coyoneda f a where
Fmap :: (a -> b) -> f b -> Coyoneda f a
Free[Coyoneda[F, ?], A]
(with a FreeC
type synonym)
Operational
List
as the pattern functor
Free
(especially evident in the first version) is as a tree with a Functorful f
of children, and values at the leaves (the Pure
constructor is Leaf a
, and Roll
is the branch, with f
children). If you look at Cofree
, that's also a Tree with values at the branches instead, and again whose structure is determined by f
, and that's a Rose Tree
data Free f a = Leaf a | Node f (Free f a)
data Cofree f a = Node a (f (Cofree f a))
type Rose = Cofree []
-- replace and you get
data Rose a = Node a [Rose a]
F[T]
s later in the list
F[A] => F[Boolean]
instead of A => F[Boolean]
tho
List[A]
and would like to build a T[A]
where there's a Traversable[T]
CanBuildFrom
, semantically, yet I would rather avoid doing it procedurally
Traverse[T]
of course
No implicit view available from (Int, Int) => scala.collection.GenTraversableOnce[B]
. How can I create GenTraversableOnce? The only way is to create a new such instance? for instance new GenTraversableOnce { ... }