Skip to content
Snippets Groups Projects
Verified Commit 842fafb4 authored by jan.hamal.dvorak's avatar jan.hamal.dvorak
Browse files

Make better use of UnliftIO

parent 678279bd
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,7 @@ common common
, string-conversions >=0.4 && <0.5
, text >=1.2 && <1.3
, time >=1.9 && <1.12
, unliftio >=0.2 && <0.3
, wai >=3.2 && <3.3
, wai-extra >=3.0 && <3.2
, wai-websockets >=3.0 && <3.1
......
......@@ -113,7 +113,7 @@ module Hikaru.Action
, FilePath
)
where
import Relude
import Relude hiding (writeIORef, readIORef, modifyIORef', newIORef)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
......@@ -121,8 +121,8 @@ where
import qualified Data.Text.Lazy as LT
import qualified Network.Wai.Parse as Parse
import Control.Exception (throwIO, bracket_)
import Control.Monad.Trans.Resource
import UnliftIO
import Data.Aeson
import Data.Binary.Builder
import Data.Dynamic
......@@ -177,7 +177,7 @@ where
getActionField :: (MonadAction m) => (ActionEnv -> IORef a) -> m a
getActionField field = do
ref <- field <$> getActionEnv
liftIO $ readIORef ref
readIORef ref
-- |
......@@ -186,7 +186,7 @@ where
setActionField :: (MonadAction m) => (ActionEnv -> IORef a) -> a -> m ()
setActionField field value = do
ref <- field <$> getActionEnv
liftIO $ writeIORef ref value
writeIORef ref value
-- |
......@@ -196,7 +196,7 @@ where
=> (ActionEnv -> IORef a) -> (a -> a) -> m ()
modifyActionField field fn = do
ref <- field <$> getActionEnv
liftIO $ modifyIORef' ref fn
modifyIORef' ref fn
-- |
......@@ -1166,7 +1166,7 @@ where
-- Same an IO exception in the form of ('RequestError', 'Text').
--
throwError :: (MonadAction m) => RequestError -> Text -> m a
throwError exn msg = liftIO $ throwIO (exn, msg)
throwError exn msg = throwIO (exn, msg)
-- Localization ------------------------------------------------------------
......
......@@ -36,15 +36,14 @@ module Hikaru.Config
)
where
import Relude hiding (drop, lines, isPrefixOf, length, span)
import qualified Data.Map as Map
import UnliftIO.Environment
import Crypto.Random.Entropy
import Data.ByteArray.Encoding
import Data.String.Conversions
import Data.Text hiding (map)
import Hikaru.Types
import System.Environment
import qualified Data.Map as Map
-- |
......@@ -57,7 +56,7 @@ where
-- Read configuration from program environment.
--
configFromEnv :: (MonadIO m) => m Config
configFromEnv = Map.fromList <$> map conv <$> liftIO getEnvironment
configFromEnv = Map.fromList <$> map conv <$> getEnvironment
where conv (k, v) = (cs k, cs v)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment