Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/dcreager/expression-problem-rust
/ types & classes
Types & classes
32 in github.com/dcreager/expression-problem-rust
⨍
Functions
96
◇
Types & classes
32
↓ 5 callers
Class
Expr
src/old.rs:123
↓ 3 callers
Class
Expr
src/ch02_open_sum.rs:51
↓ 3 callers
Class
SafeIntOrPair
src/ch07d_safer_pair_evaluation.rs:23
↓ 2 callers
Class
Pair
Creates a new pair, whose contents are given by two subexpressions.
src/ch07a_pairs.rs:22
↓ 1 callers
Class
Add
src/old.rs:30
↓ 1 callers
Class
IntegerLiteral
src/old.rs:22
↓ 1 callers
Class
MultExpr
src/ch05a_multiplication.rs:45
↓ 1 callers
Class
NoAddExpr
src/ch05a_multiplication.rs:64
↓ 1 callers
Class
PairExpr
src/ch07a_pairs.rs:61
Class
Add
We can add two expressions together, but since we don't have an Expression type (yet), we don't know what type the left- and right-hand sides should h
src/ch02_open_sum.rs:31
Enum
CoproductPair
src/old.rs:45
Interface
Eval
Each term type should implement this trait to define how it should be evaluated. If the term has any subexpressions, it should use `eval_subexpr` to
src/ch08b_open_recursion_evaluation.rs:58
Interface
Evaluate
src/old.rs:87
Interface
Evaluate
src/ch08b_open_recursion_evaluation.rs:190
Interface
EvaluateAny
Well that was easy. (Not really! Don't worry, we'll run into wrinkles.)
src/ch07b_generic_evaluation.rs:24
Interface
EvaluateInt
Each kind of term in our language should implement this trait to define how it's evaluated.
src/ch03_evaluation.rs:25
Enum
Expression
We can use an enum to represent all of the different kinds of term that can appear in our toy language.
src/ch01a_before.rs:18
Enum
Expression
This is the closest we can get: we create a new Expression type, containing each of the new kinds of term, and use a wrapper variant at the end to inc
src/ch01c_sad_face.rs:26
Interface
Expression
An Expression represents the AST of one of our mini-languages. It has a `Signature` associated type, which is a `Sum` of all of the possible terms in
src/ch08a_expressions.rs:27
Class
First
Extract the first element of a pair.
src/ch07a_pairs.rs:28
Interface
Increment
I'm going to make the bold claim that most of Swierstra §6 isn't relevant in Rust — we don't typically use monads to express stateful computations, we
src/ch06_calculator_monad.rs:21
Enum
IntOrPair
src/ch07c_pair_evaluation.rs:75
Class
IntegerLiteral
Instead of having a single Expression enum, with different variants for each kind of term, we create a separate type for each kind of term. We're goi
src/ch02_open_sum.rs:24
Class
Mem
The simplest memory store is just a struct containing the current contents.
src/ch06_calculator_monad.rs:32
Class
Multiply
First a type for the new term
src/ch05a_multiplication.rs:22
Interface
NotEq
src/old.rs:19
Interface
NotEq
src/ch04_smart_constructors.rs:35
Interface
ProjectPair
We don't have a trait that we can reuse for the evaluation rules for First and Second, like we could with std::ops::Add for our Add term. So let's ma
src/ch07c_pair_evaluation.rs:37
Interface
Recall
If you only want to read the contents of the memory, you can get away with non-mutable access to it.
src/ch06_calculator_monad.rs:27
Interface
Result
src/old.rs:84
Class
Second
Extract the second element of a pair.
src/ch07a_pairs.rs:33
Enum
Sum
This is how we'll create the different Expression types from ch01! This corresponds to the :+: "coproduct" operator from the paper.
src/ch02_open_sum.rs:38