-
Notifications
You must be signed in to change notification settings - Fork 1
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
Issues using id
with natural transformations
#9
Comments
Nice! I'm working on a idea to fix this. I want to try something before adding id. |
Adding an explicit type annotation solves the issue: But using a polymorphic natural transformation doesn't:
All three should compile without error in my mind. Is this one of facets of type-inference that |
The test fails on
for me. (Update: I had the wrong flag, sorry.) |
What if you replace that with this?
|
I believe it is simply that. In the expression That's why you can beta-reduce to We could define a little combinator: -- Please give me a better name
applyNT :: (f ~> g) -> f ~> g
applyNT = id -- or ($), if you like the application metaphor Then this typechecks: (if fl then testFun else applyNT) trans |
Doh. You caught the blunder I made as I was rushing out the door at work. My Really what we want, and what you showed with Good catch. |
What do we call |
Well if functors are homomorphisms between categories and natural transformations are morphisms between functors then what we're talking about is an endomorphism between natural transformations, right? So maybe |
I see this all the time
which is also a natural transformation transformation. Wish I had a name for it as well. |
I tried to write a version of your example that type-checked so I could better understand what you meant:
That looks like it's expressing a homomorphism over natural transformations that changes the domain of the transformation? I'm not sure why the constraint is involved, or if its even important, as the codomain of the transformation will stay fixed even without it. |
The constraint is there because you can use |
Ah, gotcha. So the intended meaning was:
Is that right? |
Yes. It appears again and again. |
That's super interesting, I've never seen that before. It seems like without an accompanying transformation of type Edit: I got that backwards. We'd need |
Attempting to compile this code:
Gives this error:
Note that the definition of
testFun
isid
which GHC accepts, but the use ofid
intest
is rejected.This is with GHC 7.10.x.
The text was updated successfully, but these errors were encountered: