loadDeck :: String -> Kerchief (Maybe Deck)
loadDeck name = getDeck >>= \mdeck -> case mdeck of
    Nothing -> loadDeck'
    Just deck
        | name == deck^.deckName -> return (Just deck)
        | otherwise              -> loadDeck'
  where
    loadDeck' :: Kerchief (Maybe Deck)
    loadDeck' = readDeck name >>=
        maybe (return Nothing) (\d -> do
            ksDeck .= Just d
            ksModified .= False
            return (Just d))

-- | Read a deck from file, by deck name. Also update it after reading, since
-- this function is the single function with which decks are read from file.
loadDeck :: String -> Kerchief (Maybe Deck)
loadDeck name = getDeck >>= \mdeck -> case mdeck of
    Nothing -> loadDeck'
    Just deck
        | name == deck^.deckName -> return (Just deck)
        | otherwise              -> loadDeck'
  where
    loadDeck' :: Kerchief (Maybe Deck)
    loadDeck' = readDeck name >>=
        maybe (return Nothing) (\d -> do
            ksDeck .= Just d
            ksModified .= False
            return (Just d))

-- | Read a deck from file, by deck name. Also update it after reading, since
-- this function is the single function with which decks are read from file.
loadDeck name = getDeck >>= \mdeck -> case mdeck of
    Nothing -> loadDeck'
    Just deck
        | name == deck^.deckName -> return (Just deck)
        | otherwise              -> loadDeck'
  where
    loadDeck' :: Kerchief (Maybe Deck)
    loadDeck' = readDeck name >>=
        maybe (return Nothing) (\d -> do
            ksDeck .= Just d
            ksModified .= False
            return (Just d))

-- | Read a deck from file, by deck name. Also update it after reading, since
-- this function is the single function with which decks are read from file.