Use CPS Writer Monad
This commit is contained in:
parent
9d530a3fe7
commit
f80a50ed53
20
default.nix
20
default.nix
|
@ -1,9 +1,9 @@
|
|||
{ mkDerivation, ansi-terminal, async, attoparsec, base, bytestring
|
||||
, cassava, containers, data-default, directory, extra, filepath
|
||||
, hermes-json, HUnit, lib, lock-file, MemoTrie, mtl, nix-derivation
|
||||
, hermes-json, HUnit, lib, lock-file, MemoTrie, nix-derivation
|
||||
, optics, random, relude, safe, stm, streamly-core, strict
|
||||
, strict-types, terminal-size, text, time, typed-process, unix
|
||||
, word8
|
||||
, strict-types, terminal-size, text, time, transformers
|
||||
, typed-process, unix, word8
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "nix-output-monitor";
|
||||
|
@ -14,21 +14,21 @@ mkDerivation {
|
|||
libraryHaskellDepends = [
|
||||
ansi-terminal async attoparsec base bytestring cassava containers
|
||||
data-default directory extra filepath hermes-json lock-file
|
||||
MemoTrie mtl nix-derivation optics relude safe stm streamly-core
|
||||
strict strict-types terminal-size text time word8
|
||||
MemoTrie nix-derivation optics relude safe stm streamly-core strict
|
||||
strict-types terminal-size text time transformers word8
|
||||
];
|
||||
executableHaskellDepends = [
|
||||
ansi-terminal async attoparsec base bytestring cassava containers
|
||||
data-default directory extra filepath hermes-json lock-file
|
||||
MemoTrie mtl nix-derivation optics relude safe stm streamly-core
|
||||
strict strict-types terminal-size text time typed-process unix
|
||||
word8
|
||||
MemoTrie nix-derivation optics relude safe stm streamly-core strict
|
||||
strict-types terminal-size text time transformers typed-process
|
||||
unix word8
|
||||
];
|
||||
testHaskellDepends = [
|
||||
ansi-terminal async attoparsec base bytestring cassava containers
|
||||
data-default directory extra filepath hermes-json HUnit lock-file
|
||||
MemoTrie mtl nix-derivation optics random relude safe stm
|
||||
streamly-core strict strict-types terminal-size text time
|
||||
MemoTrie nix-derivation optics random relude safe stm streamly-core
|
||||
strict strict-types terminal-size text time transformers
|
||||
typed-process word8
|
||||
];
|
||||
homepage = "https://github.com/maralorn/nix-output-monitor";
|
||||
|
|
|
@ -2,7 +2,7 @@ module Main (main) where
|
|||
|
||||
import Control.Concurrent (ThreadId, myThreadId, throwTo)
|
||||
import Control.Exception qualified as Exception
|
||||
import Control.Monad.Writer.Strict (WriterT (runWriterT))
|
||||
import Control.Monad.Trans.Writer.CPS (runWriterT)
|
||||
import Data.ByteString qualified as ByteString
|
||||
import Data.IORef qualified as IORef
|
||||
import Data.Text.IO (hPutStrLn)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module NOM.Update (updateStateNixJSONMessage, updateStateNixOldStyleMessage, maintainState, detectLocalFinishedBuilds, appendDifferingPlatform) where
|
||||
|
||||
import Control.Monad.Writer (MonadWriter (tell))
|
||||
import Control.Monad.Writer.Strict (WriterT (runWriterT))
|
||||
import Control.Monad.Trans.Writer.CPS (WriterT, runWriterT, tell)
|
||||
import Data.ByteString.Char8 qualified as ByteString
|
||||
import Data.IntMap.Strict qualified as IntMap
|
||||
import Data.Map.Strict qualified as Map
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
{-# LANGUAGE UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||
|
||||
module NOM.Update.Monad (
|
||||
UpdateMonad,
|
||||
MonadNow (..),
|
||||
|
@ -7,16 +10,15 @@ module NOM.Update.Monad (
|
|||
) where
|
||||
|
||||
import Control.Exception (try)
|
||||
import Control.Monad.Writer.Strict (WriterT)
|
||||
import Control.Monad.Trans.Writer.CPS (WriterT)
|
||||
-- attoparsec
|
||||
import Data.Attoparsec.Text (eitherResult, parse)
|
||||
import Data.Text.IO qualified as TextIO
|
||||
-- nix-derivation
|
||||
|
||||
import GHC.Clock qualified
|
||||
import NOM.Builds (Derivation, StorePath)
|
||||
import NOM.Error (NOMError (..))
|
||||
import NOM.Update.Monad.CacheBuildReports
|
||||
-- nix-derivation
|
||||
import Nix.Derivation qualified as Nix
|
||||
import Relude
|
||||
import System.Directory (doesPathExist)
|
||||
|
@ -32,7 +34,7 @@ instance MonadNow IO where
|
|||
instance (MonadNow m) => MonadNow (StateT a m) where
|
||||
getNow = lift getNow
|
||||
|
||||
instance (Monoid a, MonadNow m) => MonadNow (WriterT a m) where
|
||||
instance (MonadNow m) => MonadNow (WriterT a m) where
|
||||
getNow = lift getNow
|
||||
|
||||
class (Monad m) => MonadReadDerivation m where
|
||||
|
@ -56,7 +58,7 @@ instance (MonadReadDerivation m) => MonadReadDerivation (StateT a m) where
|
|||
instance (MonadReadDerivation m) => MonadReadDerivation (ExceptT a m) where
|
||||
getDerivation = lift . getDerivation
|
||||
|
||||
instance (Monoid a, MonadReadDerivation m) => MonadReadDerivation (WriterT a m) where
|
||||
instance (MonadReadDerivation m) => MonadReadDerivation (WriterT a m) where
|
||||
getDerivation = lift . getDerivation
|
||||
|
||||
class (Monad m) => MonadCheckStorePath m where
|
||||
|
@ -68,5 +70,10 @@ instance MonadCheckStorePath IO where
|
|||
instance (MonadCheckStorePath m) => MonadCheckStorePath (StateT a m) where
|
||||
storePathExists = lift . storePathExists
|
||||
|
||||
instance (Monoid a, MonadCheckStorePath m) => MonadCheckStorePath (WriterT a m) where
|
||||
instance (MonadCheckStorePath m) => MonadCheckStorePath (WriterT a m) where
|
||||
storePathExists = lift . storePathExists
|
||||
|
||||
instance (MonadState s m) => MonadState s (WriterT w m) where
|
||||
get = lift get
|
||||
put = lift . put
|
||||
state = lift . state
|
||||
|
|
|
@ -7,7 +7,7 @@ module NOM.Update.Monad.CacheBuildReports (
|
|||
) where
|
||||
|
||||
import Control.Exception (IOException, catch)
|
||||
import Control.Monad.Writer.Strict (WriterT)
|
||||
import Control.Monad.Trans.Writer.CPS (WriterT)
|
||||
-- cassava
|
||||
import Data.Csv (FromRecord, HasHeader (NoHeader), ToRecord, decode, encode)
|
||||
-- data-default
|
||||
|
@ -55,7 +55,7 @@ instance (MonadCacheBuildReports m) => MonadCacheBuildReports (StateT a m) where
|
|||
getCachedBuildReports = lift getCachedBuildReports
|
||||
updateBuildReports = lift . updateBuildReports
|
||||
|
||||
instance (Monoid a, MonadCacheBuildReports m) => MonadCacheBuildReports (WriterT a m) where
|
||||
instance (MonadCacheBuildReports m) => MonadCacheBuildReports (WriterT a m) where
|
||||
getCachedBuildReports = lift getCachedBuildReports
|
||||
updateBuildReports = lift . updateBuildReports
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@ common common-config
|
|||
, hermes-json >=0.6.0.0
|
||||
, lock-file
|
||||
, MemoTrie
|
||||
, mtl
|
||||
, nix-derivation
|
||||
, optics
|
||||
, relude
|
||||
|
@ -84,6 +83,7 @@ common common-config
|
|||
, terminal-size
|
||||
, text
|
||||
, time
|
||||
, transformers
|
||||
, word8
|
||||
|
||||
default-language: GHC2021
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Main (main) where
|
||||
|
||||
import Control.Monad.Writer.Strict (WriterT (runWriterT))
|
||||
import Control.Monad.Trans.Writer.CPS (runWriterT)
|
||||
import Data.ByteString.Char8 qualified as ByteString
|
||||
import Data.Text qualified as Text
|
||||
import NOM.Builds (parseStorePath)
|
||||
|
|
Loading…
Reference in a new issue