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

Duplicate logic in Expression.Evaluator #9

Closed
gebn opened this issue Feb 19, 2015 · 0 comments
Closed

Duplicate logic in Expression.Evaluator #9

gebn opened this issue Feb 19, 2015 · 0 comments
Assignees

Comments

@gebn
Copy link
Owner

gebn commented Feb 19, 2015

The -' and +' functions carry out the same functionality with a different operator. Given multiplication and division operations will require similar logic, it makes sense to abstract this out into a single function with a signature along the lines of ∀ {a} {A : Set a} → Maybe A → Maybe A → (A → A → A) → Maybe A, which takes two Maybe types along with an operator, and applies the operator if and only if both parameters are not nothing. It could be called like so:

maybeOp (⟦ E ⟧ σ) (⟦ E' ⟧ σ) _+_ -- for addition
maybeOp (⟦ E ⟧ σ) (⟦ E' ⟧ σ) _∸_ -- for subtraction
@gebn gebn self-assigned this Feb 19, 2015
@gebn gebn closed this as completed in 233a16f Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant