Skip to content

Commit

Permalink
Fix docstrings on constructors, and show proper help for constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
yav committed Jan 16, 2024
1 parent 5e0594f commit 1db3dbc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Cryptol/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ enum_body :: { [TopLevel (EnumCon PName)] }

enum_con :: { TopLevel (EnumCon PName) }
: app_type {% mkConDecl Nothing Public $1 }
| doc 'v{' app_type 'v}' {% mkConDecl (Just $1) Public $3 }
| doc app_type {% mkConDecl (Just $1) Public $2 }
| 'private' 'v{' app_type 'v}' {% mkConDecl Nothing Private $3 }
| doc 'private' 'v{' app_type 'v}' {% mkConDecl (Just $1) Private $4 }

Expand Down
19 changes: 15 additions & 4 deletions src/Cryptol/REPL/Help.hs
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,21 @@ showValHelp ctxparams env nameEnv qname name =

doShowDocString ifDeclDoc

-- XXX: enum constructors
fromNewtype =
do _ <- Map.lookup name (M.ifNewtypes env)
return $ return ()
fromNewtype = Map.lookup name allCons

allCons = foldr addCons mempty (M.ifNewtypes env)
where
getDocs nt =
case T.ntDef nt of
T.Struct {} -> [ T.ntDoc nt ]
T.Enum cs -> map T.ecDoc cs

addCons nt mp = foldr addCon mp
(zip (T.newtypeConTypes nt) (getDocs nt))
addCon ((c,t),d) = Map.insert c $
do rPutStrLn ""
rPrint (runDoc nameEnv $ indent 4 $ hsep [ pp c, ":", pp t ])
doShowDocString d

allParamNames =
case ctxparams of
Expand Down

0 comments on commit 1db3dbc

Please sign in to comment.