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

WIP: allow (co)datatypes without live variables #44

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions Qpf/Macro/Data/View.lean
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,14 @@ instance : ToString (DataView) := ⟨
specifications
-/
def DataView.doSanityChecks (view : DataView) : CommandElabM Unit := do
if view.liveBinders.isEmpty then
if view.deadBinders.isEmpty then
if view.command == .Codata then
throwError "Due to a bug, codatatype without any parameters don't quite work yet. Please try adding parameters to your type"
else
throwError "Trying to define a datatype without variables, you probably want an `inductive` type instead"
else
throwErrorAt view.binders "You should mark some variables as live by removing the type ascription (they will be automatically inferred as `Type _`), or if you don't have variables of type `Type _`, you probably want an `inductive` type"

-- TODO: remove once dead variables are fully supported
if !view.deadBinders.isEmpty then
dbg_trace "Dead variables are not fully supported yet"

-- if view.liveBinders.isEmpty then
-- if view.deadBinders.isEmpty then
-- if view.command == .Codata then
-- throwError "Due to a bug, codatatype without any parameters don't quite work yet. Please try adding parameters to your type"
-- else
-- throwError "Trying to define a datatype without variables, you probably want an `inductive` type instead"
-- else
-- throwErrorAt view.binders "You should mark some variables as live by removing the type ascription (they will be automatically inferred as `Type _`), or if you don't have variables of type `Type _`, you probably want an `inductive` type"

-- TODO: make this more intelligent. In particular, allow types like `Type`, `Type 3`, or `Type u`
-- and only throw an error if the user tries to define a family of types
Expand Down
1 change: 1 addition & 0 deletions Test.lean
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ import Test.Tree
-- import Test.Variable
import Test.WithBindersInCtor
import Test.Wrap
import Test.NoLiveVariables
14 changes: 14 additions & 0 deletions Test/NoLiveVars.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Qpf

/-!
Tests to assert we can have (`co`)`data` types without
any live variables
-/

namespace Qpf.Test.NoLiveVars

data Data (α : Type) where
| dat : α → Data α

codata Codata (α : Type) where
| dat : α → Codata α → Codata α
Loading