Compare commits

..

2 Commits

Author SHA1 Message Date
480073894b Add bytestring and change log message type 2023-12-19 00:21:43 +01:00
9473eabf11 Version bump and new LTS 2023-12-19 00:21:31 +01:00
5 changed files with 28 additions and 21 deletions

View File

@ -20,7 +20,7 @@ description: Please see the README at <https://git.fiskhamn.se/steffenom
dependencies: dependencies:
- base >= 4.7 && < 5 - base >= 4.7 && < 5
- text == 1.2.* - text == 2.*
- effectful-core >= 2.2.2.0 && < 3 - effectful-core >= 2.2.2.0 && < 3
- effectful >= 2.2.2.0 && < 3 - effectful >= 2.2.2.0 && < 3
- effectful-th == 1.* - effectful-th == 1.*
@ -28,6 +28,7 @@ dependencies:
- torsor == 0.1 - torsor == 0.1
- unliftio == 0.2.* - unliftio == 0.2.*
- co-log-core == 0.3.* - co-log-core == 0.3.*
- bytestring == 0.11.*
ghc-options: ghc-options:
- -Wall - -Wall

View File

@ -1,6 +1,6 @@
cabal-version: 1.12 cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.35.1. -- This file has been generated from package.yaml by hpack version 0.36.0.
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
@ -56,12 +56,13 @@ library
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
build-depends: build-depends:
base >=4.7 && <5 base >=4.7 && <5
, bytestring ==0.11.*
, chronos >=1.1.5 && <2 , chronos >=1.1.5 && <2
, co-log-core ==0.3.* , co-log-core ==0.3.*
, effectful >=2.2.2.0 && <3 , effectful >=2.2.2.0 && <3
, effectful-core >=2.2.2.0 && <3 , effectful-core >=2.2.2.0 && <3
, effectful-th ==1.* , effectful-th ==1.*
, text ==1.2.* , text ==2.*
, torsor ==0.1 , torsor ==0.1
, unliftio ==0.2.* , unliftio ==0.2.*
default-language: Haskell2010 default-language: Haskell2010

View File

@ -18,6 +18,9 @@ import Data.Text qualified as T
import Data.Text.IO qualified as T import Data.Text.IO qualified as T
import Data.Text.Lazy qualified as LT import Data.Text.Lazy qualified as LT
import Data.Text.Lazy.Builder qualified as T import Data.Text.Lazy.Builder qualified as T
import Data.Text.Encoding qualified as T
import Data.Text.Lazy.Encoding qualified as LT
import Data.Text.Encoding.Error qualified as T
import Effectful import Effectful
import Effectful.Concurrent.QSem import Effectful.Concurrent.QSem
import Effectful.Dispatch.Dynamic import Effectful.Dispatch.Dynamic
@ -27,10 +30,12 @@ import Effects.Time
import UnliftIO.Exception (bracket_) import UnliftIO.Exception (bracket_)
import UnliftIO.IO (stderr) import UnliftIO.IO (stderr)
import Prelude hiding (log) import Prelude hiding (log)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as LB
import Terminal import Terminal
class Monoid a => LogData a where class LogData a where
toLog :: a -> T.Builder toLog :: a -> T.Builder
instance LogData T.Builder where instance LogData T.Builder where
@ -39,11 +44,20 @@ instance LogData T.Builder where
instance LogData Text where instance LogData Text where
toLog = T.fromText toLog = T.fromText
instance LogData LT.Text where
toLog = T.fromLazyText
instance LogData String where instance LogData String where
toLog = T.fromString toLog = T.fromString
instance LogData B.ByteString where
toLog = toLog . T.decodeUtf8With T.lenientDecode
instance LogData LB.ByteString where
toLog = toLog . LT.decodeUtf8With T.lenientDecode
data Log :: Effect where data Log :: Effect where
Log :: Severity -> T.Builder -> Log m () Log :: (LogData a) => Severity -> a -> Log m ()
makeEffect ''Log makeEffect ''Log
@ -70,11 +84,10 @@ runLogWithQsem lock logger e = do
lock' <- ask lock' <- ask
bracket_ (waitQSem lock') (signalQSem lock') $ do bracket_ (waitQSem lock') (signalQSem lock') $ do
t <- currentTimeB t <- currentTimeB
liftIO $ cmap (addTime t . fmtMessage) logger <& msg `WithSeverity` sev liftIO $ cmap (addTime t . fmtMessage) logger <& toLog msg `WithSeverity` sev
) )
e e
stderrLogger :: stderrLogger ::
(MonadIO m) => (MonadIO m) =>
LogAction m T.Builder LogAction m T.Builder

View File

@ -17,7 +17,7 @@
# #
# resolver: ./custom-snapshot.yaml # resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-20.16 resolver: lts-21.25
# User packages to be built. # User packages to be built.
@ -36,7 +36,6 @@ packages:
# forks / in-progress versions pinned to a git hash. For example: # forks / in-progress versions pinned to a git hash. For example:
# #
extra-deps: extra-deps:
- chronos-1.1.5
# - acme-missiles-0.3 # - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git # - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a

View File

@ -3,17 +3,10 @@
# For more information, please see the documentation at: # For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files # https://docs.haskellstack.org/en/stable/lock_files
packages: packages: []
- completed:
hackage: chronos-1.1.5@sha256:ca35be5fdbbb384414226b4467c6d1c8b44defe59a9c8a3af32c1c5fb250c781,3830
pantry-tree:
sha256: 329bf39a05362a9c1f507a4a529725c757208843b562c55e0b7c88538dc3160f
size: 581
original:
hackage: chronos-1.1.5
snapshots: snapshots:
- completed: - completed:
sha256: dad15e2ec0c09280a5c2e07190fb18710fc54472f029f34f861f686540824d81 sha256: a81fb3877c4f9031e1325eb3935122e608d80715dc16b586eb11ddbff8671ecd
size: 649592 size: 640086
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/16.yaml url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/25.yaml
original: lts-20.16 original: lts-21.25