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

Create way of mapping uninvertible positive type #248

Closed AshleyYakeley closed 3 months ago

AshleyYakeley commented 5 months ago

Let T be an uninvertible positive type (e.g. Maybe None). Given this:

data W of
    Mk of
        t: T;
    end;
end;
newT: Action T;

It ought to be possible to create newW: Action W, but it currently isn't.

AshleyYakeley commented 5 months ago

Note that, given someT: T, it is possible to create someW: W: someW = let t = someT in Mk.W.

This is because let p = e in b does not simply reduce to (fn p => b) e.

AshleyYakeley commented 3 months ago

This might be a bad idea actually. Consider:

data AnyRef of
    Mk of
        ref: Ref {-a,+a};
    end;
end;

newRef: Action (Ref {-a,+a});

newAnyRef: Action AnyRef; # unsound

Note that, given some someRef: Ref {-a,+a} it is possible to create someAnyRef: AnyRef. This is not unsound.