From 8d6efb1c1fdddc1fbad167510ce25e56be684130 Mon Sep 17 00:00:00 2001
From: Andreas Grois <andi@grois.info>
Date: Thu, 7 Dec 2023 20:26:51 +0100
Subject: Allow error messages in parsing (for debugging)

And fix an off-by-one in day 5
---
 Main.lean | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

(limited to 'Main.lean')

diff --git a/Main.lean b/Main.lean
index b6d152e..1ad3933 100644
--- a/Main.lean
+++ b/Main.lean
@@ -9,10 +9,7 @@ open DayPart
 
 def try_run_day_part (day : Days) (part : Parts) (data : String) : IO String :=
   let impl : {ι : Type} →  (d : Days) → (p : Parts) → String → [Parse d (ι := ι)] → [Part d p (ι := ι)] → IO String := λ day part data ↦ do
-    let instructions ← if let some instructions := Parse.parse day data then
-      pure instructions
-    else
-      throw $ IO.userError "Failed to parse input file."
+    let instructions ← IO.ofExcept $ Parse.parse day data
     if let some result := (Part.run day part instructions).map ToString.toString then
       pure result
     else
-- 
cgit v1.2.3

