r/purescript • u/ExplanationDear8334 • Nov 21 '23
Please show me some PureMagic...
Hello all, I would like to implore the gurus around here, could you show me some magic to make this declaration shorter?
I have this code:
getSearchV2 a = withRequestEncrypted a proc
where
proc :: ProcEncrypted {} (Array Int)
proc c b zgCode cred = do
pure $ Just [12] It would be nice if I can make it like this:
getSearchV2 a = withRequestEncrypted a $ \c b zgCode cred -> do
pure $ Just [12] but I got the error:
The inferred type
forall t274. ReadForeign t274 => Config -> Context -> Effect Unit
has type variables which are not determined by those mentioned in the body of the type:
t274 could not be determined
Consider adding a type annotation. I suppose ReadForeign comes from the definition of ProcEncrypted. So the question is:
- How should I annotate the type
ProcEncrypted {} (Array Int)? - Is this can be used for
forall a b. ProcEncrypted a b?
Thank you very much for your kind responses dear Gurus, may your light shone brighter and clearer everyday...
4
Upvotes
1
u/fellow_nerd Nov 21 '23
What is the type of withRequestEncrypted?
1
u/sammthomson Nov 21 '23
Without knowing exactly what
ProcEncryptedis a type alias for, I can't say for sure which of its parameters needs to get annotated, but you should be able to do something like this:where you type-hint the appropriate lambda parameter (I did
chere, but it might have to beb,zgCodeorcred?).