From 7f690b4f530c368ec0074bb6fc4b1c35155a7615 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Mon, 16 Mar 2026 23:58:01 +0100 Subject: bahnhof-name: more lenient parsing of OSM responses Cassava's (.!) throws exceptions on missing fields even if there's a reasonable default value. Shouldn't do that anymore. --- app/Main.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 0f2e3e7..0c004d5 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -50,12 +50,13 @@ instance FromRecord Platform where Platform <$> v .! 0 <*> v .! 1 <*> - v .! 2 <*> - v .! 3 <*> - (v .! 4 <|> v .! 5) <*> - v .! 6 <*> - v .! 7 <*> - v .! 8 + v .!? 2 <*> + v .!? 3 <*> + (v .!? 4 <|> v .!? 5) <*> + v .!? 6 <*> + v .!? 7 <*> + v .!? 8 + where v .!? b = fromMaybe (pure Nothing) $ fmap parseField (v V.!? b) data Answer = Redirect Text -- cgit v1.2.3