-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type mismatch when using JavaMailEmil #216
Comments
Hi @gabriellemadden , yeah, this is a bit tricky, because the type for the connection must match the one inside the concrete instance of The recommended way is to create the val access: Access[Task, emil.C] = emil.access
def searchInbox: MailOp[Task, emil.C, SearchResult[Mail[Task]]] =
for {
inbox <- access.getInbox
emails <- access.searchAndLoad(inbox, 1)(
(Subject contains "MySubject")
)
} yield emails
emil(imapConf).run(searchInbox) But this also ties your def searchInbox[C](access: Access[Task, C]): MailOp[Task, C, SearchResult[Mail[Task]]] =
for {
inbox <- access.getInbox
emails <- access.searchAndLoad(inbox, 1)(
(Subject contains "MySubject")
)
} yield emails
emil(imapConf).run(searchInbox(emil.access)) This frees you a bit from worring about this The return type is on purpose. It could return the more specific type, too. I did not choose this, so the user needs to code against the abstract type Hope this helps and hope I was not too confusing…. |
@eikek amazing, I was struggling with the generic bit but it's much more clear now after getting |
I'm trying to use the
JavaMailEmil
class to write a program, but when I try to callemil.run
, I get a type mismatch. See the following code:This is the type mismatch, where
![Screen Shot 2021-06-17 at 10 34 48 AM](https://user-images.githubusercontent.com/49839049/122417682-ab6bb880-cf57-11eb-83be-5cb54d0659c4.png)
emil.run
is expecting anemil.C
connection instead of aJavaMailConnection
forMailOp
:I looked into the
JavaMailEmil
apply method and found that it is returning typeEmil
rather than typeJavaMailEmil
. I published a version of your lib locally where I changed the apply function to return typeJavaMailEmil
and type mismatches go away, everything compiles and runs like a dream.Emil
is the return type on purpose, can you tell me what I'm doing wrong so I can implement it correctly? I'm not sure why it would need to return anEmil
type when we already know it extends theEmil
traitThanks so much!
The text was updated successfully, but these errors were encountered: