-
Notifications
You must be signed in to change notification settings - Fork 37
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
Added {,un}currySigma to Data.Singletons.Sigma #360
Conversation
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.
Getting there!
@@ -60,6 +61,46 @@ projSigma1 (a :&: _) = fromSing a | |||
projSigma2 :: forall s t r. (forall (fst :: s). t @@ fst -> r) -> Sigma s t -> r | |||
projSigma2 f ((_ :: Sing (fst :: s)) :&: b) = f @fst b | |||
|
|||
-- | One half to witnessing an isomorphism. Convert a uncurried |
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.
This is looking better. However, this states that this forms one half of an isomorphism, but doesn't explain what the isomorphism is until much later in the Haddocks.
To make this flow better, I would prefer to structure the Haddocks like so:
Convert an uncurried function on 'Sigma' to a curried one.
(Note my use ofan
there—you mistakenly useda
instead.)-
Together, 'currySigma' and 'uncurrySigma' witness an isomorphism such that the following identities hold: <code as before>
-> (forall (a::k). Sing a -> f@@a -> b) | ||
currySigma f sing fa = f (sing :&: fa) | ||
|
||
-- | Elimination of 'Sigma'. Second half of isomorphism. |
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.
Again, I'd prefer to reorganize this (especially to be in tandem with the Haddocks for currySigma
). Something like:
Convert a curried function to a function on 'Sigma'. (In other words, this is an elimination form for 'Sigma'.)
Together, 'currySigma' and 'uncurrySigma' witness an isomorphism. (Refer to the documentation for 'currySigma' for more details.)
-- | One half to witnessing an isomorphism. Convert a uncurried | ||
-- function on 'Sigma' to a curried one. | ||
-- | ||
-- Alternative type |
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.
I hate to say this, but I really don't think that we should bother putting this alternative type in here, for two reasons:
- Without any context, this new type for
currySigma
won't be much more enlightening than the current type. - It order to actually give the new type some context, we'd need to include some sort of exposition on how
Sigma
andConstSym1
form a type-level adjunction. But I don't think that the understanding that most readers would gain from this would justify the sheer amount of jargon and prose needed to explain it.
In short, I'd favor just leaving this part out entirely. (Similarly for uncurrySigma
.)
@@ -3,6 +3,8 @@ Changelog for singletons project | |||
|
|||
2.5 | |||
--- | |||
* Add `currySigma` and `uncurrySigma` to `Data.Singletons.Sigma`. |
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.
Unfortunately, this didn't make the time window for the 2.5 release. Can you move this to a new next
section?
Any updates on this, @Icelandjack? |
* `SSigma`, the singleton type for `Sigma`, has been added. This fixes #366. * A `Show` instance has been added for `Sigma` (and `SSigma`) by using copious amounts of quantified constraints. The behavior of these instances closely resembles the `Show` implementation for `DPair` in Idris' standard library: https://github.com/idris-lang/Idris-dev/blob/dbe521ff74189df85121abe454f86894de7fd75c/libs/prelude/Prelude/Show.idr#L195-L196 * New functions `fstSigma` and `sndSigma` (as well as their type-level counterparts) have been added. To avoid being a duplicate of `fstSigma`, `projSigma1` has been redefined to have a new type signature that uses continuation-passing style, much like its cousin `projSigma2`. * New functions `currySigma` and `uncurrySigma` have been added. This fixes #359 and supersedes #360.
* `SSigma`, the singleton type for `Sigma`, has been added. This fixes #366. * A `Show` instance has been added for `Sigma` (and `SSigma`) by using copious amounts of quantified constraints. The behavior of these instances closely resembles the `Show` implementation for `DPair` in Idris' standard library: https://github.com/idris-lang/Idris-dev/blob/dbe521ff74189df85121abe454f86894de7fd75c/libs/prelude/Prelude/Show.idr#L195-L196 * New functions `fstSigma` and `sndSigma` (as well as their type-level counterparts) have been added. To avoid being a duplicate of `fstSigma`, `projSigma1` has been redefined to have a new type signature that uses continuation-passing style, much like its cousin `projSigma2`. * New functions `currySigma` and `uncurrySigma` have been added. This fixes #359 and supersedes #360.
Superseded by #400. |
Pull request for #359