Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hikaru
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
hikaru
Commits
842fafb4
Verified
Commit
842fafb4
authored
3 years ago
by
jan.hamal.dvorak
Browse files
Options
Downloads
Patches
Plain Diff
Make better use of UnliftIO
Signed-off-by:
Jan Hamal Dvořák
<
mordae@anilinux.org
>
parent
678279bd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hikaru.cabal
+1
-0
1 addition, 0 deletions
hikaru.cabal
lib/Hikaru/Action.hs
+6
-6
6 additions, 6 deletions
lib/Hikaru/Action.hs
lib/Hikaru/Config.hs
+4
-5
4 additions, 5 deletions
lib/Hikaru/Config.hs
with
11 additions
and
11 deletions
hikaru.cabal
+
1
−
0
View file @
842fafb4
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
lib/Hikaru/Action.hs
+
6
−
6
View file @
842fafb4
...
...
@@ -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 ------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
lib/Hikaru/Config.hs
+
4
−
5
View file @
842fafb4
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment