-
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
Resolve #11. Rename run to applyNT and nat to makeNT #12
Conversation
Do these names sound reasonable, @andygill? |
No objection in principle, but this is a non-backwards compatible change. The version # should change to reflect this. Also, should it be |
I'm leaning towards |
I see, let's pause and think: There are two representations of natural transformations, and we need a conversion function between them.
We need I'll modify the PR with this reasoning and new names, if we agree. A slight sidetrack:
-- | This is functor exponential
newtype (f -.-> g) a = Fn { apFn :: f a -> g a }
-- | This instance isn't defined anywhere...
instance (Contravariant f, Functor g) => Functor (f -.-> g) where
fmap f (Fn fg) = Fn (fmap f . fg . contramap f)
-- And we have a new way to write a type for natural transformations
type f ~.~> g = forall x. (f -.-> g) x
-- and if we over-engineer, there are two newtype layers now!
newtype f :~.~> g = ExpNat (f ~.~> g) It would be great to have good story how to convert between all of these representations, as Through SO: Should instance Transformation f g (f :~> g) where
Nat f # g = f g
wrapNT = Nat
instance Transformation f IO (Object f) where
Object f # g = Nat f # g
wrapNT = Object |
Additionally / Alternatively, we could change to: newtype f :~> g = NT { ($$):: forall x. f x -> g x } -- not Nat So there would be even less confusion with natural numbers. Then, |
899befd
to
cdff4f0
Compare
ping @RyanGlScott @andygill |
Let me preface this by saying that I don't know how I feel about the You seem to have expanded the scope of this PR since the last time I checked it. In particular, I'm a bit uncomfortable at the idea of making send :: DeviceContext -> Canvas a -> IO a
instance Transformation Canvas IO DeviceContext where
(#) = send But if you look at the implementations of I'm a weak +1 on the idea of renaming the |
I'm not a fan of the On the other hand, I want experimentations like this. We are still trying to get the best natural transformation story for Haskell, and we've not found it yet. |
I'm also not sure about In addition to the example @RyanGlScott gave, what if you have an additional context along with the natural transformation in your type? What if there is no "default" value to put in that context? |
@RyanGlScott, @andygill, @roboguy13 I reverted |
nat = Nat | ||
-- | An alias to 'id', to help type-inference. | ||
-- | ||
-- See <https://github.com/ku-fpg/natural-transformation/issues/9#issuecomment-172121060 comment on GitHub> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of linking to a GitHub comment in the Haddocks, it might be more illustrative to provide a code example which uses applyNT
.
Looking good, @phadej. Just a couple of more changes I'd recommend (besides the inline comment I made):
|
307e078
to
ac62335
Compare
Merged in 72f6167. Thanks! |
It wasn't clear whether you want to preserve the old names in #11 (comment) so I went ahead and renamed.
If done this way, this is a breaking change.