diff --git a/download-sdmf/Main.hs b/download-sdmf/Main.hs index b6e3f8be284e1d8e6eb369c49464b911fa33a995..1f38473e57a6346cc3a4414703747545deb74550 100644 --- a/download-sdmf/Main.hs +++ b/download-sdmf/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE LambdaCase #-} module Main where @@ -23,16 +24,16 @@ main = =<< ( runExceptT $ do [announcementPath, readCap] <- lift getArgs - -- Parse read capability - cap <- mightFail "Failed to parse capability: " . pure . parse pCapability "<argv>" . T.pack $ readCap -- Load server announcements announcements <- mightFail "Failed to parse announcements: " $ decodeFileEither announcementPath - case cap of - (SDMFVerifier _) -> ExceptT . pure . Left . Failed $ "Nothing implemented for verifier capabilities." - (SDMFWriter rwcap) -> go announcements (writerReader rwcap) - (SDMFReader rocap) -> go announcements rocap + -- Parse read capability + (mightFail "Failed to parse capability: " . pure . parse pCapability "<argv>" . T.pack) readCap + >>= \case + SDMFVerifier _ -> ExceptT . pure . Left . Failed $ "Nothing implemented for verifier capabilities." + SDMFWriter rwcap -> go announcements (writerReader rwcap) + SDMFReader rocap -> go announcements rocap ) where go :: Announcements -> Reader -> ExceptT Failed IO BL.ByteString