diff options
| author | stuebinm | 2026-03-16 23:58:01 +0100 |
|---|---|---|
| committer | stuebinm | 2026-03-16 23:58:01 +0100 |
| commit | 7f690b4f530c368ec0074bb6fc4b1c35155a7615 (patch) | |
| tree | 63978f3a7ed9b4fb8215b592bbc7b7fe83057072 | |
| parent | 699c0e04de96dfe25714b87758c1a151c3ee2408 (diff) | |
bahnhof-name: more lenient parsing of OSM responsesrnv
Cassava's (.!) throws exceptions on missing fields even if there's a
reasonable default value. Shouldn't do that anymore.
Diffstat (limited to '')
| -rw-r--r-- | app/Main.hs | 13 |
1 files 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 |
