-
Notifications
You must be signed in to change notification settings - Fork 563
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 with synonym expansion in superclass constraints #3734
Comments
Can you please include the errors you're getting? |
I suspect it's to do with not using |
I'd suggest newtyping |
@hdgarrood Apologies, my error is below[1]. @garyb I agree, and in my real application I did end up [1]
|
Yeah, that error is definitely due to a lack of |
@garyb just to make sure I'm being clear, the following code[1] does compile. It only fails if I use a type class alias to provide the same constraint. [1]
|
Yes, that's expected. What do you get if you take that example and only remove |
@hdgarrood [1]
[2]
|
👍 Looks like the |
Thanks! Minimal repro: module Main where
import Prelude
type Env = { foo :: String }
class (Monad m, MonadAsk Env m) <= MonadAskEnv m
test :: forall m. MonadAskEnv m => m Boolean
test = do
{ foo } <- ask
pure (foo == "test") fails with:
|
In this example, I've implemented the
MonadThrow
andMonadAsk
type classes for anewtype
calledApp
. The config provided by myMonadAsk
is a record. Because of the restriction on aliases in type classes, I must useTypeEquals
to define this instance.Once defined, I can interpret function with the
MonadAsk Env m
constraint with myApp
type (seedoStuff
), but if I try to constrain a function with the sameMonadAsk Env m
in a type class alias, it no longer works (seedoStuffA
anddoStuffB
). I think this may be a bug with the type checker.The text was updated successfully, but these errors were encountered: