Executable now prints the diff between two files asynchronously
4XD3XLRSTHAURHKAJF6LIJHUOTLZLJTF6OOLJWR4CNJTP6G7RE3AC
J4QXG3NCNCHLF2Z7FERKXPBZKL45MPMZQ2XLKPLURAOIRGHGF7IQC
DRHZBHR7G5UEXWJNZ4FWF63YCUIYMIM3B7JEUL5CC4ZY2UKE3CJAC
DOPKLXQZP3TDISHODQNI6GZ57EYE42NG225WHSZMQ3L355YVYPNAC
DN2F55HBRBTHQAJDU4GOOGAEAXH5MIFPQSPEK2NNAPDJPZOOFJFQC
IOHZMH4DV2QFBNQZTI456DJXL2AUMV2EUTDQUTXMMLNT64QM4AGQC
A5WEQR35VYRX4XL5DWHFJPW3BGMIHIWFNCKG767LLNPMOIJ557MQC
SNYOEZI7JMTLJNLM2YTAHBPJEKK2BJZJDOHRIX5676JCF2VNET3QC
view :: DiffR a -> Text
view = unDiffR
view' :: (Traversable t) => t (DiffR (DeckRep DiffR) -> DiffR (DeckRep DiffR)) -> DeckRep DiffR
view' = unDiffR . foldl' (\acc f -> f acc) (deck mempty)
readDiffFiles :: FilePath -> FilePath -> IO (Either [ReadError] (Map Text Card, Map Text Card))
readDiffFiles oldFile newFile = do
oldTask <- async (fmap evalMany <$> readDeckList oldFile)
newTask <- async (fmap evalMany <$> readDeckList newFile)
finished <- waitEither oldTask newTask
case finished of
Left (Left e) -> cancel newTask >> pure (Left e)
Right (Left e) -> cancel oldTask >> pure (Left e)
Left (Right x) -> do
y <- wait newTask
case y of
Left e -> pure $ Left e
Right n -> pure . Right $ (x, n)
Right (Right x) -> do
y <- wait oldTask
case y of
Left e -> pure $ Left e
Right n -> pure . Right $ (n, x)
import qualified Data.Text.IO as TIO
import Options.Applicative
import Deck.Diff
import Parser
import Repr.DiffRep
diffP :: Parser (String, String)
diffP = (,) <$> strArgument (metavar "OLDFILE") <*> strArgument (metavar "NEWFILE")
runParser :: IO (String, String)
runParser = execParser opts
where
opts = info (diffP <**> helper) fullDesc