Skip to content

Commit

Permalink
[ upstream ] Update elab for WithFC (#77)
Browse files Browse the repository at this point in the history
* fix elab for WithFC

* Fix elab-doc
  • Loading branch information
andrevidela authored Dec 2, 2024
1 parent 61a57dd commit ddccca6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Doc/Enum1.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enumDecl1 name cons = IData EmptyFC (specified Public) Nothing dat
enumName = UN $ Basic name
mkCon : String -> ITy
mkCon n = MkTy EmptyFC EmptyFC (UN $ Basic n) (IVar EmptyFC enumName)
mkCon n = MkTy EmptyFC (NoFC $ UN $ Basic n) (IVar EmptyFC enumName)
dat : Data
dat = MkData EmptyFC enumName (Just (IType EmptyFC)) [] (map mkCon cons)
Expand Down
1 change: 1 addition & 0 deletions src/Doc/Generic4.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ deriveGeneral ns fs = do
, "Record"
, "Clause"
, "Decl"
, "IClaimData"
] [Generic', Eq', Ord']
```

Expand Down
7 changes: 6 additions & 1 deletion src/Language/Reflection/Pretty.idr
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export
Pretty FC where
prettyPrec _ _ = line "emptyFC"

export
Pretty a => Pretty (WithFC a) where
prettyPrec n x = prettyPrec n x.value

export
Pretty a => Pretty (WithDefault a def') where
prettyPrec p withDef =
Expand Down Expand Up @@ -155,10 +159,11 @@ prettyImplITy : Pretty ITy
, "IField"
, "Record"
, "Decl"
, "IClaimData"
] [Pretty]

prettyImplITy = MkPretty $ \p,v => case v of
(MkTy _ _ n ty) => recordH p "mkTy" [("name", n), ("type", ty)]
(MkTy _ n ty) => recordH p "mkTy" [("name", n.value), ("type", ty)]

prettyImplArg = MkPretty $ \p,v =>
conH p "MkArg" [v.count, v.piInfo, v.name, v.type]
Expand Down
4 changes: 2 additions & 2 deletions src/Language/Reflection/Syntax.idr
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ as = IAs EmptyFC EmptyFC UseLeft
||| This is an alias for `MkTyp EmptyFC`.
public export %inline
mkTy : (name : Name) -> (type : TTImp) -> ITy
mkTy = MkTy EmptyFC EmptyFC
mkTy = MkTy EmptyFC . MkFCVal EmptyFC

||| Type declaration of a function.
|||
Expand All @@ -488,7 +488,7 @@ claim :
-> (name : Name)
-> (type : TTImp)
-> Decl
claim c v opts n tp = IClaim EmptyFC c v opts (mkTy n tp)
claim c v opts n tp = IClaim $ MkFCVal EmptyFC $ MkIClaimData c v opts (mkTy n tp)

||| `simpleClaim v n t` is an alias for `claim MW v [] (mkTy n t)`
public export %inline
Expand Down
1 change: 1 addition & 0 deletions src/Language/Reflection/Types.idr
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,4 @@ getParamInfo' n = do
export %macro
getParamInfo : Name -> Elab ParamTypeInfo
getParamInfo = getParamInfo'

3 changes: 1 addition & 2 deletions src/Test/Enum2.idr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import Language.Reflection.Util

ex1 : List Decl
ex1 =
[ IClaim
emptyFC
[ IClaim $ NoFC $ MkIClaimData
MW
Private
[]
Expand Down
11 changes: 4 additions & 7 deletions src/Test/Inspect.idr
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ ex9 =

ex10 : List Decl
ex10 =
[ IClaim
emptyFC
[ IClaim $ NoFC $ MkIClaimData
MW
Export
[Inline]
(MkTy
emptyFC
emptyFC
"test"
(NoFC "test")
( MkArg MW ExplicitArg Nothing (primVal (PrT IntType))
.-> primVal (PrT IntType)))
, IDef
Expand All @@ -103,10 +101,9 @@ ex11 =
[]
[ MkTy
emptyFC
emptyFC
"A"
(NoFC "A")
( MkArg MW ExplicitArg Nothing (bindVar "t")
.-> var "Foo" .$ bindVar "t")
, MkTy emptyFC emptyFC "B" (var "Foo" .$ bindVar "t")
, MkTy emptyFC (NoFC "B") (var "Foo" .$ bindVar "t")
])
]

0 comments on commit ddccca6

Please sign in to comment.