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

Handle enumeration of infinite types properly #309

Open
byorgey opened this issue Jan 6, 2022 · 3 comments
Open

Handle enumeration of infinite types properly #309

byorgey opened this issue Jan 6, 2022 · 3 comments
Labels
A-Confirmed Definitely a bug C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have Minor importance U-Interpreter U-Type Checking Z-Feature Request

Comments

@byorgey
Copy link
Member

byorgey commented Jan 6, 2022

Since Disco is now strict, calling enumerate on an infinite type simply hangs as it tries to strictly construct an infinite list.

We should either (1) disallow enumerate on infinite types, or potentially (2) change enumerate so it returns a function N -> a (and make list do what the old enumerate did?).

@byorgey
Copy link
Member Author

byorgey commented Jan 21, 2022

However, note that it is still useful to be able to enumerate infinite types internally, to be able to test propositions over infinite (but searchable) types. There's just no point to allowing the user to say, e.g. enumerate(N).

@byorgey byorgey added A-Confirmed Definitely a bug C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have Minor importance U-Interpreter U-Type Checking Z-Feature Request labels Jan 27, 2022
@byorgey
Copy link
Member Author

byorgey commented Mar 28, 2022

When typechecking enumerate we simply need to make sure that the type is finite in addition to checking that it is valid.

disco/src/Disco/Typecheck.hs

Lines 1117 to 1119 in 82c9994

typecheck Infer (TTyOp Enumerate t) = do
checkTypeValid t
return $ ATTyOp (TyList t) Enumerate t

Note that #175 is related, and it may make sense to fix them both at the same time.

@byorgey
Copy link
Member Author

byorgey commented Mar 28, 2022

Alternatively, maybe we want to allow returning a function N -> a from enumerate, i.e. give direct access to what the enumeration library is giving us. In other words, enumerate should return a functional sequence rather than a finite list? See also #347 . Maybe list could be overloaded to do what enumerate currently does for finite types.

@byorgey byorgey changed the title Remove enumeration of infinite types Handle enumeration of infinite types properly Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Confirmed Definitely a bug C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have Minor importance U-Interpreter U-Type Checking Z-Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant