I have the following value and its signature
type JsonResponse = Affjax.AffjaxResponse Json
getUser :: forall e m. (MonadAff (ajax :: Affjax.AJAX | e) m) => String -> m (Either Error JsonResponse)
getUser user = liftAff $ attempt $ Affjax.get $ "http://someservice.com?user=" ++ user
Now I want to use that in combination with a Maybe
. Easy enough just use map
(or the alias operator)
applyUser' = getUser <$> Just "Bob"
Only this gives me the following error
82 applyUser = getUser <$> Just "Bob"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No type class instance was found for
Control.Monad.Aff.Class.MonadAff ( ajax :: AJAX
| _0
)
_1
The instance head contains unknown type variables. Consider adding a type annotation.
in value declaration getUser'
where _1 is an unknown type
_0 is an unknown type
Only when I add the signature as
applyUser :: forall e m. (MonadAff (ajax :: Affjax.AJAX | e) m) => Maybe (m (Either Error JsonResponse))
it compiles. I am a bit stunned as really I dont see why the compiler is not able to fully infer all data here