Skip to content

Commit

Permalink
Welp, now it can fetch linsen again
Browse files Browse the repository at this point in the history
  • Loading branch information
The1Penguin committed Dec 19, 2024
1 parent 829e530 commit 233d763
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Model/Linsen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ import Control.Monad ( (>=>)
import Control.Monad.Catch ( MonadThrow )
import Control.Monad.IO.Class ( MonadIO (liftIO) )
import Data.Aeson ( (.:)
, (.:?)
, (.!=)
, withObject
, Value )
import Data.Aeson.Types ( Parser
, parseEither )
import Data.Bifunctor ( first )
import qualified Data.ByteString.Lazy.Char8 as BL8
import Data.Char ( isSpace )
import Data.Functor ( (<&>) )
import Data.List.Extra ( (!?) )
import Data.Text.Lazy ( Text
, all
Expand Down Expand Up @@ -108,10 +111,8 @@ parse day =
>=> filterM (withObject "filter whitespace"
$ (.: "children")
>=> \case
[] -> fail "Empty list"
(v:_) -> pure v
>=> (.: "text")
>=> (pure . not . all isSpace))
[] -> pure False
(v:_) -> (v .:? "text" .!= " ") <&> not . all isSpace)
>=> (\v' ->
(case v' !? 1 of
Nothing -> fail "failed to index into food"
Expand Down

0 comments on commit 233d763

Please sign in to comment.