From 19f97dd4dc143018ed6760e0088ca733409696ed Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 19 Oct 2015 01:59:18 +0200 Subject: [PATCH] better unpack these ByteStrings --- Migrations/0.0.4-0.0.5/Migration.hs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Migrations/0.0.4-0.0.5/Migration.hs b/Migrations/0.0.4-0.0.5/Migration.hs index 87f48a0..1c8e4c2 100755 --- a/Migrations/0.0.4-0.0.5/Migration.hs +++ b/Migrations/0.0.4-0.0.5/Migration.hs @@ -11,6 +11,7 @@ import Control.Exception import qualified Data.Text as T import Data.Text.Encoding (decodeUtf8) import qualified Data.ByteString.Char8 as B +import qualified Data.ByteString.Lazy.Char8 as BL import Data.Aeson as A import Data.Time.Clock import Data.Yaml as Y @@ -79,9 +80,9 @@ main = do liftIO $ putStrLn $ (show u) ++ "\n" resp <- indexDocument (IndexName "user") (MappingName "user") defaultIndexDocumentSettings u dId case statusCode (responseStatus resp) of - 200 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - 201 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (show $ responseBody resp) + 200 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + 201 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (BL.unpack $ responseBody resp) bla -> error $ "malformed entry" ++ show bla ) userRows @@ -93,9 +94,9 @@ main = do liftIO $ putStrLn $ (show a) ++ "\n" resp <- indexDocument (IndexName "album") (MappingName "album") defaultIndexDocumentSettings a dId case statusCode (responseStatus resp) of - 200 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - 201 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (show $ responseBody resp) + 200 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + 201 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (BL.unpack $ responseBody resp) bla -> error $ "malformed entry: " ++ show bla ) albumRows @@ -107,9 +108,9 @@ main = do liftIO $ putStrLn $ (show m) ++ "\n" resp <- indexDocument (IndexName "medium") (MappingName "medium") defaultIndexDocumentSettings m dId case statusCode (responseStatus resp) of - 200 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - 201 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (show $ responseBody resp) + 200 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + 201 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (BL.unpack $ responseBody resp) bla -> error $ "malformed entry" ++ show bla ) mediumRows @@ -121,9 +122,9 @@ main = do liftIO $ putStrLn $ (show c) ++ "\n" resp <- indexDocument (IndexName "medium") (MappingName "medium") defaultIndexDocumentSettings c dId case statusCode (responseStatus resp) of - 200 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - 201 -> liftIO $ putStrLn $ "OK: " ++ (show $ responseBody resp) - _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (show $ responseBody resp) + 200 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + 201 -> liftIO $ putStrLn $ "OK: " ++ (BL.unpack $ responseBody resp) + _ -> liftIO $ putStrLn $ "!!Failure!!: " ++ (BL.unpack $ responseBody resp) bla -> error $ "malformed entry" ++ show bla ) commentRows