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

strategize about implementation for Type::TRelated #13

Open
mhuesch opened this issue Apr 5, 2021 · 1 comment
Open

strategize about implementation for Type::TRelated #13

mhuesch opened this issue Apr 5, 2021 · 1 comment
Assignees

Comments

@mhuesch
Copy link
Contributor

mhuesch commented Apr 5, 2021

try to figure out what a good structure might look like.

relates to #6.

@mhuesch
Copy link
Contributor Author

mhuesch commented Apr 5, 2021

potential route 1

pub enum Type {
    TVar(TV),
    TCon(String),
    TList(Box<Type>),
    TRelated(RelatedOp, Box<Type>, Box<Type>),
}

pub enum RelatedOp {
    RArr,
    RPair,
    RDiv,
    RMul,
}

this adding this as a constructor to Type would allow us to combine types together.

this is perhaps overreaching, but we could refactor/normalize the constructors of TArr and TPair away into the (binary operation) TRelated, but adding them as constructors to RelatedOp. I included that above, just as a sketch.

anyways, back on topic

RDiv and RMul would represent the "multiplication" of two other types. it's possible this is too powerful: we would be able to have stuff like List Int * List (Bool -> Bool) - what would that really mean? a list of integers multiplied by a list of bool to bool functions...

we could also express more sensible things like "meters * seconds", this way.

potential route 2

it's possible we want to only allow TRelated inside of TCon.

that way we can restrict what pieces can get combined together. however we might want TV s inside of our TRelated, to have polymorphism?

so we could say a / sec where a might be Likes, or Claps, or meters...

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

No branches or pull requests

1 participant