
Pretty sure I'm getting bogged down on something simple, but how does the traverse function actually embed the Constant type in the f context passed to it? Or is it the pure defined in the f context that's being called? Thank you, Andrea newtype Constant a b = Constant { getConstant :: a } deriving (Eq, Show) instance Functor (Constant a) where fmap f (Constant a) = Constant a instance Monoid a => Applicative (Constant a) where pure a = Constant { getConstant = mempty } Constant a <*> Constant b = Constant { getConstant = a `mappend` b } instance Foldable (Constant a) where foldMap f (Constant a) = mempty instance Traversable (Constant a) where traverse f (Constant a) = pure $ Constant a λ> traverse (\x -> Just x) (Constant 1) Just (Constant {getConstant = 1}) Sent with [ProtonMail](https://protonmail.com) Secure Email.
participants (1)
-
Atrudyjane