<div>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?<br></div><div><br></div><div>Thank you,<br></div><div>Andrea<br></div><div><br></div><div>newtype Constant a b = Constant { getConstant :: a } deriving (Eq, Show)<br></div><div><br></div><div>instance Functor (Constant a) where<br></div><div>    fmap f (Constant a) = Constant a<br></div><div><br></div><div>instance Monoid a => Applicative (Constant a) where<br></div><div>    pure a = Constant { getConstant = mempty }<br></div><div>    Constant a <*> Constant b = Constant { getConstant = a `mappend` b }<br></div><div><br></div><div>instance Foldable (Constant a) where<br></div><div>    foldMap f (Constant a) = mempty<br></div><div><br></div><div>instance Traversable (Constant a) where<br></div><div>  traverse f (Constant a) = pure $ Constant a<br></div><div><br></div><div>λ> traverse (\x -> Just x) (Constant 1)<br></div><div>Just (Constant {getConstant = 1})<br></div><div><br></div><div><br></div><div><br></div><div class="protonmail_signature_block "><div class="protonmail_signature_block-user protonmail_signature_block-empty"><br></div><div class="protonmail_signature_block-proton ">Sent with <a href="https://protonmail.com">ProtonMail</a> Secure Email.<br></div></div><div><br></div>