Skip to content

Commit

Permalink
[ upstream ] Work around IHoles in type signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed Aug 29, 2024
1 parent efce20f commit 6e26d52
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Language/Reflection/Compat.idr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public export
argName : Arg -> Name
argName = stname . (.name)

cleanupNamedHoles : TTImp -> TTImp
cleanupNamedHoles = mapTTImp $ \case
IHole {} => implicitFalse
e => e

--------------------------------------------------------------------------------
-- General Types
--------------------------------------------------------------------------------
Expand All @@ -40,7 +45,7 @@ record Con where
export
getCon : Elaboration m => Name -> m Con
getCon n = do (n', tt) <- lookupName n
let (args, tpe) = unPi tt
let (args, tpe) = unPi $ cleanupNamedHoles tt
pure $ MkCon n' args tpe

||| Information about a data type
Expand All @@ -64,7 +69,7 @@ export
getInfo' : Elaboration m => Name -> m TypeInfo
getInfo' n = do
(n',tt) <- lookupName n
let (args,IType _) = unPi tt
let (args,IType _) = unPi $ cleanupNamedHoles tt
| (_,_) => fail "Type declaration does not end in IType"
conNames <- getCons n'
cons <- traverse getCon conNames
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module DerivedGen

import AlternativeCore
import PrintDerivation

%default total

record FinInc n where
constructor MkFinInc
val : Nat
prf : LTE val n

%language ElabReflection

%runElab printDerived @{MainCoreDerivator @{LeastEffort}} $ Fuel -> Gen MaybeEmpty (n ** FinInc n)
297 changes: 297 additions & 0 deletions tests/derivation/least-effort/print/regression/fin-inc/expected

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/derivation/least-effort/print/regression/fin-inc/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module DerivedGen

import RunDerivedGen

%default total

record FinInc n where
constructor MkFinInc
val : Nat
prf : LTE val n

Show (FinInc n) where
show (MkFinInc v p) = "MkFinInc \{show v} prf"

checkedGen : Fuel -> Gen MaybeEmpty (n ** FinInc n)
checkedGen = deriveGen @{MainCoreDerivator @{LeastEffort}}

main : IO ()
main = runGs
[ G $ \fl => checkedGen fl
]
24 changes: 24 additions & 0 deletions tests/derivation/least-effort/run/regression/fin-inc/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
1/2: Building RunDerivedGen (RunDerivedGen.idr)
2/2: Building DerivedGen (DerivedGen.idr)
Generated values:
-----
-----
(20 ** MkFinInc 16 prf)
-----
(27 ** MkFinInc 17 prf)
-----
(27 ** MkFinInc 10 prf)
-----
(9 ** MkFinInc 5 prf)
-----
(23 ** MkFinInc 12 prf)
-----
(23 ** MkFinInc 8 prf)
-----
(18 ** MkFinInc 4 prf)
-----
(11 ** MkFinInc 7 prf)
-----
(11 ** MkFinInc 10 prf)
-----
(35 ** MkFinInc 15 prf)
1 change: 1 addition & 0 deletions tests/derivation/least-effort/run/regression/fin-inc/run

0 comments on commit 6e26d52

Please sign in to comment.