Re: [Haskell-cafe] Is it safe to postulate () has one inhabitant?

Great. My aim is to convert a poly-kinded implementation, s, of
type-aligned sequences into an implementation of regular sequences by using
newtype AsUnitLoop a (x :: ()) (y :: ()) = UL a
newtype Lower s a = Lower' (s (AsUnitLoop a) '() '())
Using the postulate, I can "prove" that
s (AsUnitLoop a) x y ~ s (AsUnitLoop a) '() '()
So when I take the tail/init of a sequence I will again get a sequence, and
two sequences holding values of the same type can be concatenated. The
original reflection-without-remorse code uses
data AsUnitLoop a (x :: *) (y :: *) where
UL : a -> AsUnitLoop a () ()
which adds an extra constructor to each cell. With the postulate, I get
what I want for free. I'm *hoping* it's possible to use a pattern synonym,
Lower, that converts
s (AsUnitLoop a) '() '() (requiring '())
to
Lower s a
but that provides only
exists x y . s (AsUnitLoop a) x y
when matching. This way, the postulate won't "leak" to other code unless it
imports a Postulate module. Unfortunately, the pattern synonym
documentation is a bit vague on types.
On Apr 11, 2016 8:49 PM, "Richard Eisenberg"
participants (1)
-
David Feuer