packages feed

proxied 0.3.1 → 0.3.2

raw patch · 5 files changed

+375/−5 lines, 5 files

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+### 0.3.2 [2024.04.20]+* Add `Data.Proxyless.RequiredTypeArguments`, a variant of `Data.Proxyless`+  which uses `RequiredTypeArguments` instead of `TypeApplications`.+ ### 0.3.1 [2019.02.20] * Make the build warning-free under `-Wcompat`. 
README.md view
@@ -3,7 +3,7 @@ [![Hackage Dependencies](https://img.shields.io/hackage-deps/v/proxied.svg)](http://packdeps.haskellers.com/reverse/proxied) [![Haskell Programming Language](https://img.shields.io/badge/language-Haskell-blue.svg)][Haskell.org] [![BSD3 License](http://img.shields.io/badge/license-BSD3-brightgreen.svg)][tl;dr Legal: BSD3]-[![Build](https://img.shields.io/travis/RyanGlScott/proxied.svg)](https://travis-ci.org/RyanGlScott/proxied)+[![Build Status](https://github.com/RyanGlScott/proxied/workflows/Haskell-CI/badge.svg)](https://github.com/RyanGlScott/proxied/actions?query=workflow%3AHaskell-CI)  [Hackage: proxied]:   http://hackage.haskell.org/package/proxied@@ -19,4 +19,4 @@   `Proxy`, however, does not carry any of the error-throwing risks of `undefined`, so it is much more preferable to take `Proxy` as an argument to a constant function instead of `undefined`. Unfortunately, `Proxy` wasn't included in `base` until GHC 7.8, so many of `base`'s typeclasses still contain constant functions that aren't amenable to passing `Proxy`. `proxied` addresses this issue by providing variants of those typeclass functions that take an explicit `proxy` value. -This library also contains the `Data.Proxyless` module, which works in the opposite direction. That is, one can take functions which take `Proxy` (or `undefined`) as an argument and convert them to functions which take no arguments. This trick relies on the `-XTypeApplications` extension, so it is only available with GHC 8.0 or later.+This library also contains the `Data.Proxyless` module, which works in the opposite direction. That is, one can take functions which take `Proxy` (or `undefined`) as an argument and convert them to functions which take no arguments. This trick relies on the `-XTypeApplications` extension, so it is only available with GHC 8.0 or later. This library also offers `Data.Proxyless.RequiredTypeArguments`, a variant of `Data.Proxyless` that uses `-XRequiredTypeArguments` to make type arguments explicit, which is only available with GHC 9.10 or later.
proxied.cabal view
@@ -1,5 +1,5 @@ name:                proxied-version:             0.3.1+version:             0.3.2 synopsis:            Make functions consume Proxy instead of undefined description:         @proxied@ is a simple library that exports a function to                      convert constant functions to ones that take a @proxy@@@ -27,6 +27,11 @@                      argument and convert them to functions which take no                      arguments. This trick relies on the @-XTypeApplications@                      extension, so it is only available with GHC 8.0 or later.+                     This library also offers+                     "Data.Proxyless.RequiredTypeArguments", a variant of+                     "Data.Proxyless" that uses @-XRequiredTypeArguments@ to+                     make type arguments explicit, which is only available with+                     GHC 9.10 or later. homepage:            https://github.com/RyanGlScott/proxied bug-reports:         https://github.com/RyanGlScott/proxied/issues license:             BSD3@@ -46,7 +51,15 @@                    , GHC == 8.0.2                    , GHC == 8.2.2                    , GHC == 8.4.4-                   , GHC == 8.6.3+                   , GHC == 8.6.5+                   , GHC == 8.8.4+                   , GHC == 8.10.7+                   , GHC == 9.0.2+                   , GHC == 9.2.8+                   , GHC == 9.4.8+                   , GHC == 9.6.5+                   , GHC == 9.8.2+                   , GHC == 9.10.1 extra-source-files:  CHANGELOG.md, README.md cabal-version:       >=1.10 @@ -58,6 +71,8 @@   exposed-modules:     Data.Proxied   if impl(ghc >= 8.0)     exposed-modules:   Data.Proxyless+  if impl(ghc >= 9.10)+    exposed-modules:   Data.Proxyless.RequiredTypeArguments   build-depends:       base             >= 4.3    && < 5   if !impl(ghc >= 7.6)     build-depends:     generic-deriving >= 1.10.1 && < 2
src/Data/Proxyless.hs view
@@ -5,9 +5,12 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-}-{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} +#if __GLASGOW_HASKELL__ < 806+{-# LANGUAGE TypeInType #-}+#endif+ {-# OPTIONS_GHC -Wno-deprecations #-}  #if __GLASGOW_HASKELL__ == 800 \@@ -26,6 +29,9 @@ Remove the 'Proxy', 'Proxy#', and 'undefined' arguments from functions with 'proxyless', 'proxyHashless', and 'undefinedless', respectively, which produce functions that take type information via GHC's @-XTypeApplications@ extension.++See also "Data.Proxyless.RequiredTypeArguments" for a version of this module+that leverages @-XRequiredTypeArguments@ instead of @-XTypeApplications@.  This module is only available with GHC 8.0 or later. 
+ src/Data/Proxyless/RequiredTypeArguments.hs view
@@ -0,0 +1,345 @@+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE RequiredTypeArguments #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeOperators #-}++{-# OPTIONS_GHC -Wno-deprecations #-}++{-|+Module:      Data.Proxyless.RequiredTypeArguments+Copyright:   (C) 2024 Ryan Scott+License:     BSD-style (see the file LICENSE)+Maintainer:  Ryan Scott+Stability:   Provisional+Portability: GHC++Remove the 'Proxy', 'Proxy#', and 'undefined' arguments from functions with+'proxyless', 'proxyHashless', and 'undefinedless', respectively, which produce+functions that take type information via GHC's @-XRequiredTypeArguments@+extension.++See also "Data.Proxyless" for a version of this module that leverages+@-XTypeApplications@ instead of @-XRequiredTypeArguments@.++This module is only available with GHC 9.10 or later.++/Since: 0.3.2/+-}+module Data.Proxyless.RequiredTypeArguments (+      -- * 'proxyless', 'proxyHashless', and 'undefinedless'+      proxyless+    , proxyHashless+    , undefinedless+      -- * Proxyless functions+      -- ** "Data.Bits"+    , theBitSize+    , theIsSigned+    , theBitSizeMaybe+    , theFiniteBitSize+      -- ** "Data.Data"+    , theDataTypeOf+      -- ** "Data.Typeable"+    , theTypeNatTypeRep+    , theTypeRep+    , theTypeRep#+    , theTypeSymbolTypeRep+      -- ** "Foreign.Storable"+    , theSizeOf+    , theAlignment+      -- ** "GHC.Generics"+    , theDatatypeName+    , theModuleName+    , theIsNewtype+    , thePackageName+    , theConName+    , theConFixity+    , theConIsRecord+    , theSelName+    , theSelSourceUnpackedness+    , theSelSourceStrictness+    , theSelDecidedStrictness+      -- ** "GHC.OverloadedLabels"+    , theFromLabel+      -- ** "GHC.TypeLits"+    , theNatVal+    , theNatVal'+    , theSameNat+    , theSameSymbol+    , theSomeNat+    , theSomeSymbol+    , theSymbolVal+    , theSymbolVal'+      -- ** "Prelude"+    , theFloatRadix+    , theFloatDigits+    , theFloatRange+      -- ** "Text.Printf"+    , theParseFormat+    ) where++import Data.Bits (Bits(..), FiniteBits(..))+import Data.Data (Data(dataTypeOf), DataType)+import Data.Proxy (Proxy(..))+import Data.Proxyless (proxyless, proxyHashless, undefinedless)+import Data.Type.Equality ((:~:))+import Data.Typeable (Typeable, TypeRep, typeRep)++import Foreign.Storable (Storable(..))++import GHC.Generics+import GHC.OverloadedLabels (IsLabel(..))+import GHC.TypeLits++import Text.Printf (PrintfArg(..), ModifierParser)++-------------------------------------------------------------------------------+-- Data.Bits+-------------------------------------------------------------------------------++-- | @'theBitSize' = 'undefinedless' 'bitSize'@+--+-- /Since: 0.3.2/+theBitSize :: forall a -> Bits a => Int+theBitSize a = undefinedless @a bitSize++-- | @'theIsSigned' = 'undefinedless' 'isSigned'@+--+-- /Since: 0.3.2/+theIsSigned :: forall a -> Bits a => Bool+theIsSigned a = undefinedless @a isSigned++-- | @'theBitSizeMaybe' = 'undefinedless' 'bitSizeMaybe'@+--+-- /Since: 0.3.2/+theBitSizeMaybe :: forall a -> Bits a => Maybe Int+theBitSizeMaybe a = undefinedless @a bitSizeMaybe++-- | @'theFiniteBitSize' = 'undefinedless' 'finiteBitSize'@+--+-- /Since: 0.3.2/+theFiniteBitSize :: forall a -> FiniteBits a => Int+theFiniteBitSize a = undefinedless @a finiteBitSize++-------------------------------------------------------------------------------+-- Data.Data+-------------------------------------------------------------------------------++-- | @'theDataTypeOf' = 'undefinedless' 'dataTypeOf'@+--+-- /Since: 0.3.2/+theDataTypeOf :: forall a -> Data a => DataType+theDataTypeOf a = undefinedless @a dataTypeOf++-------------------------------------------------------------------------------+-- Data.Typeable+-------------------------------------------------------------------------------++-- | A type-specialized version of 'theTypeRep'.+--+-- /Since: 0.3.2/+theTypeNatTypeRep :: forall a -> KnownNat a => TypeRep+theTypeNatTypeRep a = theTypeRep a++-- | @'theTypeRep' = 'proxyless' 'typeRep'@+--+-- /Since: 0.3.2/+theTypeRep :: forall k. forall (a :: k) -> Typeable a => TypeRep+theTypeRep a = proxyless @_ @a typeRep++-- | A type-specialized version of 'theTypeRep'.+--+-- /Since: 0.3.2/+theTypeRep# :: forall k. forall (a :: k) -> Typeable a => TypeRep+theTypeRep# a = theTypeRep a++-- | A type-specialized version of 'theTypeRep'.+--+-- /Since: 0.3.2/+theTypeSymbolTypeRep :: forall a -> KnownSymbol a => TypeRep+theTypeSymbolTypeRep a = theTypeRep a++-------------------------------------------------------------------------------+-- Foreign.Storable+-------------------------------------------------------------------------------++-- | @'theSizeOf' = 'undefinedless' 'sizeOf'@+--+-- /Since: 0.3.2/+theSizeOf :: forall a -> Storable a => Int+theSizeOf a = undefinedless @a sizeOf++-- | @'theAlignment' = 'undefinedless' 'alignment'@+--+-- /Since: 0.3.2/+theAlignment :: forall a -> Storable a => Int+theAlignment a = undefinedless @a alignment++-------------------------------------------------------------------------------+-- GHC.Generics+-------------------------------------------------------------------------------++-- | @'theDatatypeName' = 'datatypeName' 'undefined'@+--+-- /Since: 0.3.2/+theDatatypeName :: forall k. forall (d :: k) -> Datatype d => [Char]+theDatatypeName d = datatypeName @d undefined++-- | @'theModuleName' = 'moduleName' 'undefined'@+--+-- /Since: 0.3.2/+theModuleName :: forall k. forall (d :: k) -> Datatype d => [Char]+theModuleName d = moduleName @d undefined++-- | @'theIsNewtype' = 'isNewtype' 'undefined'@+--+-- /Since: 0.3.2/+theIsNewtype :: forall k. forall (d :: k) -> Datatype d => Bool+theIsNewtype d = isNewtype @d undefined++-- | @'thePackageName' = 'packageName' 'undefined'@+--+-- /Since: 0.3.2/+thePackageName :: forall k. forall (d :: k) -> Datatype d => [Char]+thePackageName d = packageName @d undefined++-- | @'theConName' = 'conName' 'undefined'@+--+-- /Since: 0.3.2/+theConName :: forall k. forall (c :: k) -> Constructor c => [Char]+theConName c = conName @c undefined++-- | @'theConFixity' = 'conFixity' 'undefined'@+--+-- /Since: 0.3.2/+theConFixity :: forall k. forall (c :: k) -> Constructor c => Fixity+theConFixity c = conFixity @c undefined++-- | @'theConIsRecord' = 'conIsRecord' 'undefined'@+--+-- /Since: 0.3.2/+theConIsRecord :: forall k. forall (c :: k) -> Constructor c => Bool+theConIsRecord c = conIsRecord @c undefined++-- | @'theSelName' = 'selName' 'undefined'@+--+-- /Since: 0.3.2/+theSelName :: forall k. forall (s :: k) -> Selector s => [Char]+theSelName s = selName @s undefined++-- | @'theSelSourceUnpackedness' = 'selSourceUnpackedness' 'undefined'@+--+-- /Since: 0.3.2/+theSelSourceUnpackedness :: forall k. forall (s :: k) -> Selector s => SourceUnpackedness+theSelSourceUnpackedness s = selSourceUnpackedness @s undefined++-- | @'theSelSourceStrictness' = 'selSourceStrictness' 'undefined'@+--+-- /Since: 0.3.2/+theSelSourceStrictness :: forall k. forall (s :: k) -> Selector s => SourceStrictness+theSelSourceStrictness s = selSourceStrictness @s undefined++-- | @'theSelDecidedStrictness' = 'selDecidedStrictness' 'undefined'@+--+-- /Since: 0.3.2/+theSelDecidedStrictness :: forall k. forall (s :: k) -> Selector s => DecidedStrictness+theSelDecidedStrictness s = selDecidedStrictness @s undefined++-------------------------------------------------------------------------------+-- GHC.OverloadedLabels+-------------------------------------------------------------------------------++-- | In @base-4.10@ and later, this is simply a synonym for 'fromLabel'.+-- In @base-4.9@, 'theFromLabel' is defined as:+--+-- @'theFromLabel' = 'proxyHashless' 'fromLabel'@+--+-- /Since: 0.3.2/+theFromLabel :: forall x -> forall a. IsLabel x a => a+theFromLabel x = fromLabel @x++-------------------------------------------------------------------------------+-- GHC.TypeLits+-------------------------------------------------------------------------------++-- | @'theNatVal' = 'proxyless' 'natVal'@+--+-- /Since: 0.3.2/+theNatVal :: forall n -> KnownNat n => Integer+theNatVal n = proxyless @_ @n natVal++-- | @`theNatVal'` = 'proxyHashless' `natVal'`@+--+-- /Since: 0.3.2/+theNatVal' :: forall n -> KnownNat n => Integer+theNatVal' n = proxyHashless @_ @n natVal'++-- | @'theSameNat' = 'sameNat' 'Proxy' 'Proxy'@+--+-- /Since: 0.3.2/+theSameNat :: forall a b -> (KnownNat a, KnownNat b) => Maybe (a :~: b)+theSameNat a b = sameNat (Proxy @a) (Proxy @b)++-- | @'theSameSymbol' = 'sameSymbol' 'Proxy' 'Proxy'@+--+-- /Since: 0.3.2/+theSameSymbol :: forall a b -> (KnownSymbol a, KnownSymbol b) => Maybe (a :~: b)+theSameSymbol a b = sameSymbol (Proxy @a) (Proxy @b)++-- | @'theSomeNat' = 'proxyless' 'SomeNat'@+--+-- /Since: 0.3.2/+theSomeNat :: forall n -> KnownNat n => SomeNat+theSomeNat n = proxyless @_ @n SomeNat++-- | @'theSomeSymbol' = 'proxyless' 'SomeSymbol'@+--+-- /Since: 0.3.2/+theSomeSymbol :: forall n -> KnownSymbol n => SomeSymbol+theSomeSymbol n = proxyless @_ @n SomeSymbol++-- | @'theSymbolVal' = 'proxyless' 'symbolVal'@+--+-- /Since: 0.3.2/+theSymbolVal :: forall n -> KnownSymbol n => String+theSymbolVal n = proxyless @_ @n symbolVal++-- | @`theSymbolVal'` = 'proxyHashless' `symbolVal'`@+--+-- /Since: 0.3.2/+theSymbolVal' :: forall n -> KnownSymbol n => String+theSymbolVal' n = proxyHashless @_ @n symbolVal'++-------------------------------------------------------------------------------+-- Prelude+-------------------------------------------------------------------------------++-- | @'theFloatRadix' = 'undefinedless' 'floatRadix'@+--+-- /Since: 0.3.2/+theFloatRadix :: forall a -> RealFloat a => Integer+theFloatRadix a = undefinedless @a floatRadix++-- | @'theFloatDigits' = 'undefinedless' 'floatDigits'@+--+-- /Since: 0.3.2/+theFloatDigits :: forall a -> RealFloat a => Int+theFloatDigits a = undefinedless @a floatDigits++-- | @'theFloatRange' = 'undefinedless' 'floatRange'@+--+-- /Since: 0.3.2/+theFloatRange :: forall a -> RealFloat a => (Int, Int)+theFloatRange a = undefinedless @a floatRange++-------------------------------------------------------------------------------+-- Text.Printf+-------------------------------------------------------------------------------++-- | @'theParseFormat' = 'undefinedless' 'parseFormat'@+--+-- /Since: 0.3.2/+theParseFormat :: forall a -> PrintfArg a => ModifierParser+theParseFormat a = undefinedless @a parseFormat