According to the Haskell wikibook, a Monad
called m
is a Functor
with two additional operations:
unit :: a -> m a
join :: m (m a) -> m a
That's nice, but I have something slightly different. Glossing over the gory details, I have a type that has good unit
and join
functions, but its fmap
is not well behaved (fmap g . fmap f
is not necessarily fmap (g.f)
). Because of this, it cannot be made an instance of Monad
. Nonetheless, I'd like to give it as much generic functionality as possible.
So my question is, what category theoretic structures are similar to monads in that they have a unit
and join
?
I realize that on some level, the above question is ill-defined. For monads the unit
and join
definitions only make sense in terms of the fmap
definition. Without fmap
, you can't define any of the monad laws, so any definitions of unit
/join
would be equally "valid." So I'm looking for functions other than fmap
that it might make sense to define some "not-monad" laws on these unit
and join
functions.
fmap
? – luquifmap
in a way so thatjoin
fulfills the 2nd monad law? Normally, you almost always getfmap g . fmap f ≡ fmap $ f.g
just automatically. – leftaroundaboutfmap
as applying a function to every point in a distribution, thenfmap
only obeys theFunctor
laws for addition and multiplication.unit
is training on a single data point, andjoin
is merging a "normal distribution of normal distributions" into a single normal distribution. Obviously, this requires some constraints on the parameters, so it can't be done at all using theBase
type classes and I'be been usingConstraintKinds
to play around with it. – Mike Izbickimonoid
, just in a different category. I'm not sure what category would correspond to normal distributions, but I'm a bit suspicious. My intuition (which is frequently wrong FWIW) is that the only structure imposed by a normal distribution is isomorphic to a List. – John L