@@ -53,73 +53,73 @@ considerNewType ty = do
5353Deriving . DepTyCheck . Gen . ForAllNeededTypes . Interface . DerivationClosure m = (DeriveBodyForType , Monad m, Elaboration m, ClosuringContext m)
5454
5555Deriving . DepTyCheck . Gen . ForAllNeededTypes . Interface . needWeightFun ty = when (not ! (gets $ contains ty. name)) $ do
56- modify {stateType= SortedSet Name } $ insert ty. name
57- _ : (NamesInfoInTypes, ConsRecs) <- get
58- whenJust (deriveWeightingFun ty) $ tell . mapHom singleton
56+ modify {stateType= SortedSet Name } $ insert ty. name
57+ _ : (NamesInfoInTypes, ConsRecs) <- get
58+ whenJust (deriveWeightingFun ty) $ tell . mapHom singleton
5959
6060Deriving . DepTyCheck . Gen . ForAllNeededTypes . Interface . callGen sig fuel values = do
6161
62- -- look for external gens, and call it if exists
63- let Nothing = lookupLengthChecked sig ! ask
64- | Just (name, Element extSig lenEq) =>
65- logValue Details " deptycheck.derive.closuring.external" [sig] " is used as an external generator" $
66- (callExternalGen extSig name (var outmostFuelArg) $ rewrite lenEq in values, Just (_ ** extSig. gendOrder))
62+ -- look for external gens, and call it if exists
63+ let Nothing = lookupLengthChecked sig ! ask
64+ | Just (name, Element extSig lenEq) =>
65+ logValue Details " deptycheck.derive.closuring.external" [sig] " is used as an external generator" $
66+ (callExternalGen extSig name (var outmostFuelArg) $ rewrite lenEq in values, Just (_ ** extSig. gendOrder))
6767
68- -- check if we are the first, then we need to start the loop, and say that no one needs any more startups, we are in charge
69- startLoop <- get <* put False
68+ -- check if we are the first, then we need to start the loop, and say that no one needs any more startups, we are in charge
69+ startLoop <- get <* put False
7070
71- -- update names info in types and cons recs if the asked type is not there
72- considerNewType sig. targetType
71+ -- update names info in types and cons recs if the asked type is not there
72+ considerNewType sig. targetType
7373
74- -- get the expression of calling the internal gen, derive if necessary
75- internalGenCall <- do
74+ -- get the expression of calling the internal gen, derive if necessary
75+ internalGenCall <- do
7676
77- -- look for existing (already derived) internals, use it if exists
78- let Nothing = List . Map . lookup sig ! get
79- | Just name => pure $ callCanonic sig name fuel values
77+ -- look for existing (already derived) internals, use it if exists
78+ let Nothing = List . Map . lookup sig ! get
79+ | Just name => pure $ callCanonic sig name fuel values
8080
81- -- nothing found, then derive! acquire the name
82- let name = nameForGen sig
81+ -- nothing found, then derive! acquire the name
82+ let name = nameForGen sig
8383
84- -- remember that we're responsible for this signature derivation
85- modify $ List . Map . insert sig name
84+ -- remember that we're responsible for this signature derivation
85+ modify $ List . Map . insert sig name
8686
87- -- remember the task to derive
88- modify {stateType= List _ } $ (:: ) (sig, name)
87+ -- remember the task to derive
88+ modify {stateType= List _ } $ (:: ) (sig, name)
8989
90- -- return the name of the newly derived generator
91- pure $ callCanonic sig name fuel values
90+ -- return the name of the newly derived generator
91+ pure $ callCanonic sig name fuel values
9292
93- -- if we were first to start the derivation loop, then...
94- when startLoop $ do
95- -- start the derivation loop itself
96- deriveAll
97- -- we now are not in charge of the derivation loop, so reset the flag
98- put True
93+ -- if we were first to start the derivation loop, then...
94+ when startLoop $ do
95+ -- start the derivation loop itself
96+ deriveAll
97+ -- we now are not in charge of the derivation loop, so reset the flag
98+ put True
9999
100- -- call the internal gen
101- logValue DetailedDebug " deptycheck.derive.closuring.internal" [sig] " is used as an internal generator"
102- (internalGenCall, Nothing )
100+ -- call the internal gen
101+ logValue DetailedDebug " deptycheck.derive.closuring.internal" [sig] " is used as an internal generator"
102+ (internalGenCall, Nothing )
103103
104- where
104+ where
105105
106- deriveOne : (GenSignature, Name) -> m ()
107- deriveOne (sig, name) = do
106+ deriveOne : (GenSignature, Name) -> m ()
107+ deriveOne (sig, name) = do
108108
109- -- derive declaration and body for the asked signature. It's important to call it AFTER update of the map in the state to not to cycle
110- let genFunClaim = export' name $ canonicSig sig
111- _ : (NamesInfoInTypes, ConsRecs) <- get
112- genFunBody <- logBounds Info " deptycheck.derive.type" [sig] $ def name <$> assert_total canonicBody sig name
109+ -- derive declaration and body for the asked signature. It's important to call it AFTER update of the map in the state to not to cycle
110+ let genFunClaim = export' name $ canonicSig sig
111+ _ : (NamesInfoInTypes, ConsRecs) <- get
112+ genFunBody <- logBounds Info " deptycheck.derive.type" [sig] $ def name <$> assert_total canonicBody sig name
113113
114- -- remember the derived stuff
115- tell ([genFunClaim], [genFunBody])
114+ -- remember the derived stuff
115+ tell ([genFunClaim], [genFunBody])
116116
117- deriveAll : m ()
118- deriveAll = do
119- toDerive <- get {stateType= List _ }
120- put {stateType= List _ } []
121- for_ toDerive deriveOne
122- when (not $ null toDerive) $ assert_total $ deriveAll
117+ deriveAll : m ()
118+ deriveAll = do
119+ toDerive <- get {stateType= List _ }
120+ put {stateType= List _ } []
121+ for_ toDerive deriveOne
122+ when (not $ null toDerive) $ assert_total $ deriveAll
123123
124124-- - Canonic-dischagring function ---
125125
0 commit comments