-
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
Adding curry/uncurry, leftAdjunct/rightAdjunct #359
Comments
I have no objection to a PR which adds I don't see much utility in having |
On second thought, I wonder if we should actually wait until (if?) #366 is implemented before going through with this. The reason is that we could actually make the types of type family Sing :: k -> Type
newtype WrappedSing (a :: k) = WrapSing (Sing a)
newtype SWrappedSing :: forall k (a :: k). WrappedSing a -> Type where
SWrapSing :: forall k (a :: k) (ws :: WrappedSing a).
Sing a -> SWrappedSing ws
type instance Sing = SWrappedSing
data Sigma (s :: Type) :: (s ~> Type) -> Type where
(:&:) :: forall s t fst. Sing (fst :: s) -> t @@ fst -> Sigma s t
data SSigma :: forall s (t :: s ~> Type). Sigma s t -> Type where
(:%&:) :: forall s t (fst :: s) (sfst :: Sing fst) (snd :: t @@ fst).
Sing (WrapSing sfst) -> Sing snd -> SSigma (sfst :&: snd :: Sigma s t)
type instance Sing = SSigma
currySigma :: forall a (b :: a ~> Type) (c :: Sigma a b ~> Type).
(forall (p :: Sigma a b). Sing p -> c @@ p)
-> (forall (x :: a) (sx :: Sing x) (y :: b @@ x).
Sing (WrapSing sx) -> Sing y -> c @@ (sx :&: y))
currySigma f x y = f (x :%&: y)
uncurrySigma :: forall a (b :: a ~> Type) (c :: Sigma a b ~> Type).
(forall (x :: a) (sx :: Sing x) (y :: b @@ x).
Sing (WrapSing sx) -> Sing y -> c @@ (sx :&: y))
-> (forall (p :: Sigma a b). Sing p -> c @@ p)
uncurrySigma f (x :%&: y) = f x y These more closely resemble how these functions are defined in Agda: curry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : Σ A B → Set c} →
((p : Σ A B) → C p) →
((x : A) → (y : B x) → C (x , y))
curry f x y = f (x , y)
uncurry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : Σ A B → Set c} →
((x : A) → (y : B x) → C (x , y)) →
((p : Σ A B) → C p)
uncurry f (x , y) = f x y |
* `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.
For
Data.Singleton.Sigma
, these functions witness an isomorphism fromSigma
being left adjointAny interest in adding these with better names? There is also
The text was updated successfully, but these errors were encountered: