
20 Mar
2019
20 Mar
'19
2:45 a.m.
Hi, I was wondering if this function exists somewhere (i'm not attached to the name): (<<$>>) :: (Functor f) => (a -> g b) -> f a -> Compose f g b (<<$>>) mkG = Compose . fmap mkG It's handy if you're working with an applicative (e.g Reflex.Dynamic) and want to layer on top a validation type function that returns a different applicative that need composing. So I figure that it must exist somewhere! :) E.g. data Person = Person Text Email nameTextDyn :: Dynamic t Text emailTextDyn :: Dynamic t Text validEmail :: Text -> Validation (NonEmpty Text) Email validPersonDyn :: Dynamic t (Validation (NonEmpty Text) Person = getCompose $ Person <$> (pure <<$>> name) <*> (validEmail <<$>> emailTextDyn) Cheers, Ben