expect1 :: MonadBooks m => BookList -> m Book
expect1 bl = case Set.toAscList bl of
                []  -> throwError [st|Unable to find such a book.|]
                [b] -> return b
                _   -> do putLn "The query matched:"
                          printBookList bl
                          throwError "Please refine the query."

-- | Finds exactly one book that matches the given query and throws an error
-- otherwise.
expect1 :: MonadBooks m => BookList -> m Book
expect1 bl = case Set.toAscList bl of
                []  -> throwError [st|Unable to find such a book.|]
                [b] -> return b
                _   -> do putLn "The query matched:"
                          printBookList bl
                          throwError "Please refine the query."

-- | Finds exactly one book that matches the given query and throws an error
-- otherwise.
expect1 bl = case Set.toAscList bl of
                []  -> throwError [st|Unable to find such a book.|]
                [b] -> return b
                _   -> do putLn "The query matched:"
                          printBookList bl
                          throwError "Please refine the query."

-- | Finds exactly one book that matches the given query and throws an error
-- otherwise.