[Haskell] Add example recipe to justfile

This commit is contained in:
Felix Bargfeldt 2023-12-09 10:46:40 +01:00
parent 5c3fb9da47
commit a647c55505
Signed by: Defelo
GPG key ID: 2A05272471204DD3
2 changed files with 8 additions and 3 deletions

View file

@ -18,7 +18,8 @@ aoc year day setup part1 part2 examples = do
main :: (Print b, Print c) => Int -> Int -> (String -> a) -> (a -> b) -> (a -> c) -> IO ()
main year day setup part1 part2 = do
let path = inputPath year day
args <- getArgs
let path = if length args == 1 then head args else inputPath year day
input <- readFile path <&> setup
(putStrLn . toString . part1) input
(putStrLn . toString . part2) input

View file

@ -1,4 +1,5 @@
alias b := build
alias e := example
alias r := run
alias t := test
alias ty := test-year
@ -11,8 +12,11 @@ build year day:
mkdir -p .build/{{year}}/{{day}}
ghc -o .build/{{year}}/{{day}}/{{day}} -outputdir .build/{{year}}/{{day}} -O {{year}}/{{day}}.hs >&2
run year day: (build year day)
.build/{{year}}/{{day}}/{{day}}
example year day ex: (build year day)
.build/{{year}}/{{day}}/{{day}} ../examples/{{year}}/{{trim_start_match(day, "0")}}/{{ex}}
run year day *args: (build year day)
.build/{{year}}/{{day}}/{{day}} {{args}}
test year day: (build year day)
.build/{{year}}/{{day}}/{{day}} test