AshleyYakeley / Truth

Changes and Pinafore projects. Pull requests not accepted.
https://pinafore.info/
GNU General Public License v2.0
32 stars 0 forks source link

More specific types for morphism product & sum combinators #36

Closed AshleyYakeley closed 4 years ago

AshleyYakeley commented 4 years ago

Currently we have:

!** :: (a ~> {-bp,+bq}) -> (a ~> {-cp,+cq}) -> a ~> {-(bp, cp),+(bq, cq)}
!++ :: ({-ap,+aq} ~> c) -> ({-bp,+bq} ~> c) -> {-(Either ap bp),+(Either aq bq)} ~> c

Would prefer:

!** :: ({-ap,+aq} ~> {-bp,+bq}) -> ({-ap,+aq} ~> {-cp,+cq}) -> {-ap,+aq} ~> {-(bp, cp),+(bq, cq)}
!++ :: ({-ap,+aq} ~> {-cp,+cq}) -> ({-bp,+bq} ~> {-cp,+cq}) -> {-(Either ap bp),+(Either aq bq)} ~> {-cp,+cq}
AshleyYakeley commented 4 years ago

Related to #26.

AshleyYakeley commented 4 years ago

Consider:

bodyweight :: Animal ~> Mass;
name :: Human ~> Text;
Human <= Animal;
myDog :: Animal;
myHuman :: Human;

then

bn :: {-Human,+Animal} ~> (Mass,Text)
bn = bodyweight !** name
bn !$% pureRef myHuman :: Ref (Mass,Text)
bn !$% pureRef myDog -- type error
AshleyYakeley commented 4 years ago

It's now

!** :: ({-ap,+Entity,+aq} ~> {-bp,+bq}) -> ({-ap,+Entity,+aq} ~> {-cp,+cq}) -> {-ap,+aq} ~> {-(bp, cp),+(bq, cq)}
!++ :: ({-ap,+aq} ~> c) -> ({-bp,+bq} ~> c) -> {-(Either ap bp),+(Either aq bq)} ~> c
AshleyYakeley commented 4 years ago

OK, now they're both correct:

!** :: ({-ap,+Entity,+aq} ~> {-bp,+bq}) -> ({-ap,+Entity,+aq} ~> {-cp,+cq}) -> {-ap,+aq} ~> {-(bp, cp),+(bq, cq)}
!++ :: ({-ap,+aq} ~> {-cp,+cq}) -> ({-bp,+bq} ~> {-cp,+cq}) -> {-(Either ap bp),+(Either aq bq)} ~> {-cp,+cq}