fix: namespace issues with generated code
This commit is contained in:
parent
bf184dd8d3
commit
b3c48a5d8c
|
@ -73,16 +73,31 @@ allProblems (Pr day' part') = do
|
||||||
|
|
||||||
--- REFLECTION
|
--- REFLECTION
|
||||||
|
|
||||||
public export
|
solutionName : Problem -> Name
|
||||||
fetchSolution : Problem -> Elab (String -> String)
|
solutionName (Pr day part) =
|
||||||
fetchSolution (Pr day part) = do
|
|
||||||
let name =
|
|
||||||
NS (MkNS ["Part" ++ show (partNat part),
|
NS (MkNS ["Part" ++ show (partNat part),
|
||||||
"Day" ++ show day]) `{solution}
|
"Day" ++ show day]) `{solution}
|
||||||
|
|
||||||
|
public export
|
||||||
|
fetchSolution : Problem -> Elab (String -> String)
|
||||||
|
fetchSolution pr = do
|
||||||
|
let name = solutionName pr
|
||||||
check `(\s => show (~(IVar EmptyFC name) s))
|
check `(\s => show (~(IVar EmptyFC name) s))
|
||||||
<|> fail "\{show name} does not exist as a valid solution"
|
<|> fail "\{show name} does not exist as a valid solution"
|
||||||
|
|
||||||
public export
|
public export
|
||||||
fetchAllSols : (latest : Problem) -> Elab (SortedMap Problem (String -> String))
|
fetchAllSols : (latest : Problem) -> Elab (SortedMap Problem (String -> String))
|
||||||
fetchAllSols pr =
|
fetchAllSols pr =
|
||||||
fromList <$> traverse (\p => (p,) <$> fetchSolution p) (allProblems pr)
|
let prs = allProblems pr
|
||||||
|
list = foldr (\pr,tt => `(Prelude.(::)
|
||||||
|
(Builtin.MkPair
|
||||||
|
(Data.Problem.Pr
|
||||||
|
(Prelude.fromInteger
|
||||||
|
~(IPrimVal EmptyFC $ BI $ natToInteger pr.day))
|
||||||
|
~(case pr.part of
|
||||||
|
Part1 => `(Data.Problem.Part1)
|
||||||
|
Part2 => `(Data.Problem.Part2)))
|
||||||
|
(\s => show (~(IVar EmptyFC $ solutionName pr) s)))
|
||||||
|
~(tt))) `(Prelude.Nil) prs
|
||||||
|
ttimp = `(Data.SortedMap.fromList ~(list))
|
||||||
|
in check ttimp
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
module Main
|
module Main
|
||||||
|
|
||||||
import Data.List1
|
|
||||||
import Data.Maybe
|
|
||||||
import Data.String
|
|
||||||
import Data.SortedMap
|
import Data.SortedMap
|
||||||
import Data.SortedMap.Dependent
|
|
||||||
import Data.Problem
|
import Data.Problem
|
||||||
import Utils
|
import Utils
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue