Skip to content
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

Issue: Version 0.4.1 creates Type Exception on getOrElse #95

Closed
zellidev0 opened this issue Mar 3, 2023 · 3 comments · Fixed by #96
Closed

Issue: Version 0.4.1 creates Type Exception on getOrElse #95

zellidev0 opened this issue Mar 3, 2023 · 3 comments · Fixed by #96

Comments

@zellidev0
Copy link
Contributor

I noticed when using 0.4.1 in contrast to 0.4.0 a type exception is thrown when using getOrElse on Option.

type '() => String' is not a subtype of type '() => Never' of 'orElse'

The code responsible for the error is:

model.activeProfile
           .map((final Profile profile) => profile.isActive)
           .getOrElse(() => false)

Is this a known issue? Downgrading to Version 0.4.0 from 0.4.1 works.

@zellidev0
Copy link
Contributor Author

@SandroMaglione Can you elaborate what the issue exactly was? I tried to understand the PR but it just seems to change dependency versions.

@SandroMaglione
Copy link
Owner

@ju851zel you can read details in #92

The issue was with introducing a const factory constructor for None. When calling map, it caused the type to be wrong at runtime.

@qwertylolman
Copy link

qwertylolman commented Aug 3, 2024

well, it's not fixed. i got
type '() => TaskEither<L, R>' is not a subtype of type '() => TaskEither<L, Never>' of 'orElse'<…>

My issue was next:
Option.none().toEither(() => Exception('some message')).toTaskEither();
after toTaskEither I got an TaskEither<Exception, Never> instead of TaskEither<Exception, T>

workaround is Option extension:
option.match(
() => TaskEither<L, T>.leftTask(Task(onNone)),
(s) => TaskEither<L, T>.right(s),
)

similar problem with Option.toIOOption
workarounds
IOOption toIOOption1() => //
IOOption(() => this);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants