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

Changes to rec records #160

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions src/DblParser/Desugar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ let tr_ctor_name' (cname : Raw.ctor_name) =

let with_nowhere data = { pos = Position.nowhere; data = data}

let rec node_is_rec_data (def : Raw.def) =
match def.data with
| DRecord _ -> true
| DData _ -> true
| DLabel _ -> true
| _ -> false

let node_is_data_def (def : def) =
match def.data with
| DData _ -> true
| DLabel _ -> true
| _ -> false

let annot_tp e tp =
{ pos = e.pos;
data = Raw.EAnnot(e, with_nowhere tp)
Expand Down Expand Up @@ -751,6 +764,11 @@ and tr_def ?(public=false) (def : Raw.def) =
| DOpen(pub, path) ->
let public = public || pub in
[ make (DOpen(public, path)) ]
| DRec(pub, defs) when List.for_all node_is_rec_data defs ->
ppolesiuk marked this conversation as resolved.
Show resolved Hide resolved
let public = public || pub in
let dds, accessors = tr_defs ~public defs
|> List.partition node_is_data_def in
make (DRec dds) :: accessors
| DRec(pub, defs) ->
let public = public || pub in
[ make (DRec (tr_defs ~public defs)) ]
Expand Down