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

Better code for Pinafore interpretation #298

Open
AshleyYakeley opened this issue Jul 21, 2024 · 0 comments
Open

Better code for Pinafore interpretation #298

AshleyYakeley opened this issue Jul 21, 2024 · 0 comments
Labels
Milestone

Comments

@AshleyYakeley
Copy link
Owner

AshleyYakeley commented Jul 21, 2024

Currently:

evaluate.Eval @A: Text -> Action (Result Text A)

Something like:

pure.Pinafore @A: A -> Pinafore;
parse.Pinafore: Text -> Action (Result Text Pinafore);
let.Pinafore: [(Text,Pinafore)] -> Pinafore -> Pinafore;
evaluate.Pinafore @A: Pinafore -> Action (Result Text A);

Possibilities:

  • Interpreter monad
  • open and closed expressions
namespace Pinafore of  # Reflect?
type Error;
subtype Error <: Showable;

type Positive.Type -a;
const.Positive.Type @A: Positive.Type A;
type Negative.Type +a;
const.Negative.Type @A: Negative.Type A;
unify.Type: PositiveType a -> NegativeType b -> Result UnifyError (a -> b);

type Type {-p,+q};
subtype Type -a <: Positive.Type a;
subtype Type +a <: Negative.Type a;
const.Type @A: Type A;

type Value;
mk.Value: PositiveType a -> a -> Value;
unify.Value: NegativeType a -> Value -> Result UnifyError a;

type OpenExpression +a;
# applicative OpenExpression
evaluate.OpenExpression: OpenExpression a -> Result EvaluateError a;

type Expression;
pure.Expression: Value -> Expression;
mk.Expression: PositiveType a -> OpenExpression a -> Expression;
unify.Expression: NegativeType a -> Expression -> Result UnifyError (OpenExpression a);
evaluate.Expression: Expression -> Result EvaluateError Value;
interpret.Expression: Text -> Action (Result InterpretError Expression);

end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant