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

Added {,un}currySigma to Data.Singletons.Sigma #360

Closed
wants to merge 2 commits into from

Conversation

Icelandjack
Copy link
Contributor

Pull request for #359

CHANGES.md Outdated Show resolved Hide resolved
src/Data/Singletons/Sigma.hs Outdated Show resolved Hide resolved
Copy link
Collaborator

@RyanGlScott RyanGlScott left a 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
Copy link
Collaborator

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:

  1. Convert an uncurried function on 'Sigma' to a curried one. (Note my use of an there—you mistakenly used a instead.)
  2. 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.
Copy link
Collaborator

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:

  1. Convert a curried function to a function on 'Sigma'. (In other words, this is an elimination form for 'Sigma'.)
  2. 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
Copy link
Collaborator

@RyanGlScott RyanGlScott Sep 2, 2018

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:

  1. Without any context, this new type for currySigma won't be much more enlightening than the current type.
  2. It order to actually give the new type some context, we'd need to include some sort of exposition on how Sigma and ConstSym1 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`.
Copy link
Collaborator

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?

@RyanGlScott
Copy link
Collaborator

Any updates on this, @Icelandjack?

RyanGlScott added a commit that referenced this pull request Jul 11, 2019
* `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.
RyanGlScott added a commit that referenced this pull request Jul 12, 2019
* `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.
@RyanGlScott
Copy link
Collaborator

Superseded by #400.

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 this pull request may close these issues.

2 participants