Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package ghc-th-utilities for
openSUSE:Factory checked in at 2022-10-13 15:43:17
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-th-utilities (Old)
and /work/SRC/openSUSE:Factory/.ghc-th-utilities.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-th-utilities"
Thu Oct 13 15:43:17 2022 rev:14 rq:1008531 version:0.2.5.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-th-utilities/ghc-th-utilities.changes
2021-04-24 23:10:10.679481761 +0200
+++
/work/SRC/openSUSE:Factory/.ghc-th-utilities.new.2275/ghc-th-utilities.changes
2022-10-13 15:43:34.858906095 +0200
@@ -1,0 +2,11 @@
+Wed Sep 21 03:38:20 UTC 2022 - Peter Simons <[email protected]>
+
+- Update th-utilities to version 0.2.5.0.
+ ## 0.2.5.0
+
+ * Adds `tupT` and `promotedTupT`.
+
+ * Adds `TH.FixQ.fixQ`, a compatibility shim to provide fixQ for
+ `template-haskell <= 2.17` (`ghc <= 9.0.1`).
+
+-------------------------------------------------------------------
Old:
----
th-utilities-0.2.4.3.tar.gz
New:
----
th-utilities-0.2.5.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-th-utilities.spec ++++++
--- /var/tmp/diff_new_pack.NzwX8l/_old 2022-10-13 15:43:35.610907563 +0200
+++ /var/tmp/diff_new_pack.NzwX8l/_new 2022-10-13 15:43:35.618907579 +0200
@@ -1,7 +1,7 @@
#
# spec file for package ghc-th-utilities
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
%global pkg_name th-utilities
%bcond_with tests
Name: ghc-%{pkg_name}
-Version: 0.2.4.3
+Version: 0.2.5.0
Release: 0
Summary: Collection of useful functions for use with Template Haskell
License: MIT
++++++ th-utilities-0.2.4.3.tar.gz -> th-utilities-0.2.5.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/th-utilities-0.2.4.3/ChangeLog.md
new/th-utilities-0.2.5.0/ChangeLog.md
--- old/th-utilities-0.2.4.3/ChangeLog.md 2021-04-10 05:59:16.000000000
+0200
+++ new/th-utilities-0.2.5.0/ChangeLog.md 2022-09-21 05:35:26.000000000
+0200
@@ -1,5 +1,12 @@
# ChangeLog
+## 0.2.5.0
+
+* Adds `tupT` and `promotedTupT`.
+
+* Adds `TH.FixQ.fixQ`, a compatibility shim to provide fixQ for
+ `template-haskell <= 2.17` (`ghc <= 9.0.1`).
+
## 0.2.4.3
* Adds a lower bound for `th-abstraction` dependency. Also released as
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/th-utilities-0.2.4.3/src/TH/FixQ.hs
new/th-utilities-0.2.5.0/src/TH/FixQ.hs
--- old/th-utilities-0.2.4.3/src/TH/FixQ.hs 1970-01-01 01:00:00.000000000
+0100
+++ new/th-utilities-0.2.5.0/src/TH/FixQ.hs 2022-09-21 05:21:58.000000000
+0200
@@ -0,0 +1,31 @@
+{-# LANGUAGE CPP #-}
+-- | A compat module to take fixed points in 'Q'.
+module TH.FixQ (fixQ) where
+
+#if MIN_VERSION_template_haskell(2,17,0)
+import Control.Monad.Fix (mfix)
+import Language.Haskell.TH.Syntax (Q (..))
+
+fixQ :: (a -> Q a) -> Q a
+fixQ = mfix
+
+#else
+
+-- We don't have a MonadFix instance for Q
+import Control.Concurrent.MVar (newEmptyMVar, readMVar, putMVar)
+import Control.Exception (BlockedIndefinitelyOnMVar (..), catch, throwIO)
+import Control.Exception.Base (FixIOException (..))
+import Language.Haskell.TH.Syntax (Q (..), runIO)
+import GHC.IO.Unsafe (unsafeDupableInterleaveIO)
+
+fixQ :: (a -> Q a) -> Q a
+fixQ k = do
+ m <- runIO newEmptyMVar
+ ans <- runIO (unsafeDupableInterleaveIO
+ (readMVar m `catch` \BlockedIndefinitelyOnMVar ->
+ throwIO FixIOException))
+ result <- k ans
+ runIO (putMVar m result)
+ return result
+
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/th-utilities-0.2.4.3/src/TH/Utilities.hs
new/th-utilities-0.2.5.0/src/TH/Utilities.hs
--- old/th-utilities-0.2.4.3/src/TH/Utilities.hs 2021-03-24
03:52:43.000000000 +0100
+++ new/th-utilities-0.2.5.0/src/TH/Utilities.hs 2022-09-21
05:21:58.000000000 +0200
@@ -1,3 +1,4 @@
+{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
@@ -9,11 +10,13 @@
-- packages in the th-utilities repo and elsewhere.
module TH.Utilities where
+import Control.Monad (foldM)
import Data.Data
import Data.Generics
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import Language.Haskell.TH.Datatype.TyVarBndr (TyVarBndr_, tvName)
+import TH.FixQ (fixQ)
-- | Get the 'Name' of a 'TyVarBndr'
tyVarBndrName :: TyVarBndr_ flag -> Name
@@ -32,6 +35,46 @@
go xs (AppT l x) = go (x : xs) l
go xs ty = ty : xs
+-- | Given a list of types, produce the type of a tuple of
+-- those types. This is analogous to 'tupE' and 'tupP'.
+--
+-- @
+-- tupT [[t|Int|], [t|Char|], [t|Bool]] = [t| (Int, Char, Bool) |]
+-- @
+--
+-- @since FIXME
+tupT :: [Q Type] -> Q Type
+tupT ts = do
+ -- We build the expression with a thunk inside that will be filled in with
+ -- the length of the list once that's been determined. This works
+ -- efficiently (in one pass) because TH.Type is rather lazy.
+ (res, !_n) <- fixQ (\ ~(_res, n) -> foldM go (TupleT n, 0) ts)
+ pure res
+ where
+ go (acc, !k) ty = do
+ ty' <- ty
+ pure (acc `AppT` ty', k + 1)
+
+-- | Given a list of types, produce the type of a promoted tuple of
+-- those types. This is analogous to 'tupE' and 'tupP'.
+--
+-- @
+-- promotedTupT [[t|3|], [t| 'True|], [t|Bool]] = [t| '(3, 'True, Bool) |]
+-- @
+--
+-- @since FIXME
+promotedTupT :: [Q Type] -> Q Type
+promotedTupT ts = do
+ -- We build the expression with a thunk inside that will be filled in with
+ -- the length of the list once that's been determined. This works
+ -- efficiently (in one pass) because TH.Type is rather lazy.
+ (res, !_n) <- fixQ (\ ~(_res, n) -> foldM go (PromotedTupleT n, 0) ts)
+ pure res
+ where
+ go (acc, !k) ty = do
+ ty' <- ty
+ pure (acc `AppT` ty', k + 1)
+
-- | Given a 'Type', returns a 'Just' value if it's a named type
-- constructor applied to arguments. This value contains the name of the
-- type and a list of arguments.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/th-utilities-0.2.4.3/th-utilities.cabal
new/th-utilities-0.2.5.0/th-utilities.cabal
--- old/th-utilities-0.2.4.3/th-utilities.cabal 2021-04-10 05:59:44.000000000
+0200
+++ new/th-utilities-0.2.5.0/th-utilities.cabal 2022-09-21 05:35:49.000000000
+0200
@@ -1,13 +1,11 @@
cabal-version: 1.12
--- This file has been generated from package.yaml by hpack version 0.33.0.
+-- This file has been generated from package.yaml by hpack version 0.34.4.
--
-- see: https://github.com/sol/hpack
---
--- hash: 8dd4245123726939dae99503cb0aad9bcf8c9a56feeb5eb1ec3f2859ef21e581
name: th-utilities
-version: 0.2.4.3
+version: 0.2.5.0
synopsis: Collection of useful functions for use with Template Haskell
category: Template Haskell
homepage: https://github.com/fpco/th-utilities#readme
@@ -29,6 +27,7 @@
exposed-modules:
TH.Derive
TH.Derive.Storable
+ TH.FixQ
TH.ReifySimple
TH.RelativePaths
TH.Utilities