packages feed

serokell-util 0.3 → 0.3.1

raw patch · 3 files changed

+47/−2 lines, 3 filesdep ~formattingPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: formatting

API changes (from Hackage documentation)

+ Serokell.Util.Trace: instance Print.Print p => Serokell.Util.Trace.VarArgTrace (x -> p) (x -> x)
+ Serokell.Util.Trace: instance Serokell.Util.Trace.VarArgTrace fmt f => Serokell.Util.Trace.VarArgTrace (a -> fmt) (a -> f)
+ Serokell.Util.Trace: traceIdF :: VarArgTrace fmt a => Format Text fmt -> a

Files

serokell-util.cabal view
@@ -1,5 +1,5 @@ name:                serokell-util-version:             0.3+version:             0.3.1 synopsis:            General-purpose functions by Serokell homepage:            https://github.com/serokell/serokell-util license:             MIT@@ -43,6 +43,7 @@                        Serokell.Util.StaticAssert                        Serokell.Util.Text                        Serokell.Util.Time+                       Serokell.Util.Trace                        Serokell.Util.Verify   other-modules:       Serokell.Data.Variant.Class                        Serokell.Data.Variant.Helpers@@ -66,7 +67,7 @@                      , exceptions                      , extra                      , filepath-                     , formatting+                     , formatting >= 6.2.0                      , hashable >= 1.2.4.0                      , lens                      , log-warper
src/Serokell/Util.hs view
@@ -15,4 +15,5 @@ import           Serokell.Util.StaticAssert as Exports import           Serokell.Util.Text         as Exports import           Serokell.Util.Time         as Exports+import           Serokell.Util.Trace        as Exports import           Serokell.Util.Verify       as Exports
+ src/Serokell/Util/Trace.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE FlexibleInstances      #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses  #-}+{-# LANGUAGE UndecidableInstances   #-}+{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}++-- | Utility trace-like functions.++module Serokell.Util.Trace+    ( traceIdF+    ) where++import           Universum++import           Data.Text           (Text)+import           Formatting          (Format, now, sformat)+import           Formatting.Internal (runFormat)++-- | Class for supplying various variable-arguments traces+class VarArgTrace fmt f | fmt -> f where+    traceIdFHelper :: fmt -> f++instance {-# OVERLAPPING #-}+         Print p => VarArgTrace (x -> p) (x -> x) where+    traceIdFHelper fmt x = trace (fmt x) x++instance VarArgTrace fmt f => VarArgTrace (a -> fmt) (a -> f) where+    traceIdFHelper fmt a = traceIdFHelper (fmt a)++-- | Generalized version of `traceShowId`.+-- Accepts formatter as first parameter, and then multiple arguments to print.+--+-- Examples:+-- >>> traceIdF F.ords 1+-- 1st+-- 1+--+-- >>> traceIdF ("Item no "%F.int%": "%F.build) 5 True+-- Item no 5: True+-- True+{-# WARNING traceIdF "'traceIdF' remains in code" #-}+traceIdF :: VarArgTrace fmt a => Format Text fmt -> a+traceIdF fmt = traceIdFHelper (runFormat fmt (sformat . now))