packages feed

refined 0.6.3 → 0.8.2

raw patch · 5 files changed

Files

changelog.md view
@@ -4,6 +4,29 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## [0.8.1] - 2023-04-05+### Added+- `Weaken` instances for `SizeGreaterThan`, `SizeLessThan`.+- `weakenAndLeft`, `weakenAndRight`, `weakenOrLeft`, `weakenOrRight`+  type inference helper functions.++### Changed+- bump `base`: "< 4.18" -> "< 4.19"+- bump `mtl`: "< 2.3" -> "< 2.4"+- bump `template-haskell`: "< 2.20" -> "< 2.21"++## [0.8] - 2022-10-09+### Changed+- on GHC >=9, make `refineTH` and `refineTH_` work in any monad+  `(Quote m, MonadFail m)`.+- bump `base`: "< 4.17" -> "< 4.18"+- bump `template-haskell`: "< 2.19" -> "< 2.20"+- bump `aeson`: "< 2.1" -> "< 2.2"++## [0.7] - 2022-07-01+### Changed+- make `Refined` predicate type `p` kind polymorphic (`p :: Type` -> `p :: k`)+ ## [0.6.3] - 2022-01-14 ### Added - `Hashable` instance for `Refined`
refined.cabal view
@@ -1,9 +1,8 @@-cabal-version:-  2.0+cabal-version: 3.0 name:   refined version:-  0.6.3+  0.8.2 synopsis:   Refinement types with static and runtime checking description:@@ -35,7 +34,9 @@   , GHC == 8.8.5   , GHC == 8.10.7   , GHC == 9.0.2-  , GHC == 9.2.1+  , GHC == 9.2.4+  , GHC == 9.4.2+  , GHC == 9.6.1 extra-source-files:     README.md   , changelog.md@@ -72,32 +73,22 @@   default-language:     Haskell2010   build-depends:-      base             >= 4.11 && < 4.17-    , bytestring       >= 0.10 && < 0.12-    , deepseq          >= 1.4 && < 1.5-    , exceptions       >= 0.8 && < 0.11-    , hashable         >= 1.0 && < 1.5-    , mtl              >= 2.2.2 && < 2.3-    , template-haskell >= 2.9 && < 2.19-    , text             >= 1.2 && < 2.1-    , these-skinny     >= 0.7.5 && < 0.8+    , base             >= 4.11 && < 5+    , bytestring       >= 0.10+    , deepseq          >= 1.4+    , exceptions       >= 0.8+    , hashable         >= 1.0+    , mtl              >= 2.2.2+    , template-haskell >= 2.9+    , text             >= 1.2+    , these-skinny     >= 0.7.5   if flag(aeson)-    build-depends: aeson >= 0.9 && < 2.1+    build-depends: aeson >= 0.9     cpp-options: -DHAVE_AESON   if flag(QuickCheck)-    build-depends: QuickCheck >= 2.1 && < 2.15+    build-depends: QuickCheck >= 2.1     cpp-options: -DHAVE_QUICKCHECK ---test-suite doctest---  type: exitcode-stdio-1.0---  hs-source-dirs: test---  main-is: Doctests.hs---  build-depends:---      base---    , refined---    , doctest >= 0.10---  default-language: Haskell2010- test-suite arbitrary   type: exitcode-stdio-1.0   hs-source-dirs: test@@ -116,12 +107,3 @@       base     , refined   default-language: Haskell2010----test-suite doesnt-compile---   type: exitcode-stdio-1.0---   hs-source-dirs: test---   main-is: DoesntCompile.hs---   build-depends:---       base---     , refined---   default-language: Haskell2010
src/Refined.hs view
@@ -45,12 +45,14 @@ {-# LANGUAGE MultiParamTypeClasses      #-} {-# LANGUAGE OverloadedStrings          #-} {-# LANGUAGE PackageImports             #-}+{-# LANGUAGE PolyKinds                  #-} {-# LANGUAGE RoleAnnotations            #-} {-# LANGUAGE ScopedTypeVariables        #-}-{-# LANGUAGE TemplateHaskell            #-}+{-# LANGUAGE TemplateHaskellQuotes      #-} {-# LANGUAGE TypeApplications           #-} {-# LANGUAGE TypeFamilies               #-} {-# LANGUAGE TypeOperators              #-}+{-# LANGUAGE UndecidableInstances       #-}  -------------------------------------------------------------------------------- @@ -134,6 +136,10 @@   , andRight   , leftOr   , rightOr+  , weakenAndLeft+  , weakenAndRight+  , weakenOrLeft+  , weakenOrRight      -- * Strengthening   , strengthen@@ -225,14 +231,22 @@  -- | Helper function, stolen from the flow package. (|>) :: a -> (a -> b) -> b-(|>) = flip ($)+x |> f = apply x f {-# INLINE (|>) #-}  -- | Helper function, stolen from the flow package. (.>) :: (a -> b) -> (b -> c) -> a -> c-f .> g = \x -> g (f x)+f .> g = compose f g {-# INLINE (.>) #-} +-- | Helper function, stolen from the flow package.+apply :: a -> (a -> b) -> b+apply x f = f x++-- | Helper function, stolen from the flow package.+compose :: (a -> b) -> (b -> c) -> (a -> c)+compose f g x = g (f x)+ -- | FIXME: doc data Ordered a = Empty | Decreasing a | Increasing a @@ -438,9 +452,9 @@ -- --   @since 0.1.0.0 #if MIN_VERSION_template_haskell(2,17,0)-refineTH :: forall p x. (Predicate p x, TH.Lift x)+refineTH :: forall p x m. (Predicate p x, TH.Lift x, TH.Quote m, MonadFail m)   => x-  -> TH.Code TH.Q (Refined p x)+  -> TH.Code m (Refined p x) refineTH =   let showException = refineExceptionToTree         .> showTree True@@ -467,9 +481,9 @@ -- --   @since 0.4.4 #if MIN_VERSION_template_haskell(2,17,0)-refineTH_ :: forall p x. (Predicate p x, TH.Lift x)+refineTH_ :: forall p x m. (Predicate p x, TH.Lift x, TH.Quote m, MonadFail m)   => x-  -> TH.Code TH.Q x+  -> TH.Code m x refineTH_ =   refineTH @p @x   .> TH.examineCode@@ -567,7 +581,7 @@     )  -- | @since 0.1.0.0-instance (Predicate p x, Typeable p) => Predicate (Not p) x where+instance (Predicate (p :: k) x, Typeable p, Typeable k) => Predicate (Not p) x where   validate p x = do     maybe (Just (RefineNotException (typeRep p)))           (const Nothing)@@ -598,7 +612,7 @@ type (&&) = And  -- | @since 0.1.0.0-instance ( Predicate l x, Predicate r x, Typeable l, Typeable r+instance ( Predicate (l :: k) x, Predicate (r :: k) x, Typeable l, Typeable r, Typeable k          ) => Predicate (And l r) x where   validate p x = do     let a = validate @l undefined x@@ -638,7 +652,7 @@ type (||) = Or  -- | @since 0.2.0.0-instance ( Predicate l x, Predicate r x, Typeable l, Typeable r+instance ( Predicate (l :: k) x, Predicate (r :: k) x, Typeable l, Typeable r, Typeable k          ) => Predicate (Or l r) x where   validate p x = do     let left  = validate @l undefined x@@ -675,7 +689,7 @@ -- type (^) = Xor  -- | @since 0.5-instance ( Predicate l x, Predicate r x, Typeable l, Typeable r+instance ( Predicate (l :: k) x, Predicate (r :: k) x, Typeable l, Typeable r, Typeable k          ) => Predicate (Xor l r) x where   validate p x = do     let left = validate @l undefined x@@ -1277,7 +1291,7 @@ --   @since 0.2.0.0 type NonZero = NotEqualTo 0 --- | A 'Predicate' ensuring that the type is non-empty.+-- | A 'Predicate' ensuring that the type is empty. -- --   @since 0.5 type Empty = SizeEqualTo 0@@ -1292,7 +1306,7 @@ -- | A typeclass containing "safe" conversions between refined --   predicates where the target is /weaker/ than the source: --   that is, all values that satisfy the first predicate will---   be guaranteed to satisy the second.+--   be guaranteed to satisfy the second. -- --   Take care: writing an instance declaration for your custom --   predicates is the same as an assertion that 'weaken' is@@ -1312,23 +1326,27 @@   weaken = coerce  -- | @since 0.2.0.0-instance (n <= m)         => Weaken (LessThan n)    (LessThan m)+instance (n <= m)         => Weaken (LessThan n)        (LessThan m) -- | @since 0.2.0.0-instance (n <= m)         => Weaken (LessThan n)    (To m)+instance (n <= m)         => Weaken (LessThan n)        (To m) -- | @since 0.2.0.0-instance (n <= m)         => Weaken (To n)          (To m)+instance (n <= m)         => Weaken (To n)              (To m) -- | @since 0.2.0.0-instance (m <= n)         => Weaken (GreaterThan n) (GreaterThan m)+instance (m <= n)         => Weaken (GreaterThan n)     (GreaterThan m) -- | @since 0.2.0.0-instance (m <= n)         => Weaken (GreaterThan n) (From m)+instance (m <= n)         => Weaken (GreaterThan n)     (From m) -- | @since 0.2.0.0-instance (m <= n)         => Weaken (From n)        (From m)+instance (m <= n)         => Weaken (From n)            (From m) -- | @since 0.2.0.0-instance (p <= n, m <= q) => Weaken (FromTo n m)    (FromTo p q)+instance (p <= n, m <= q) => Weaken (FromTo n m)        (FromTo p q) -- | @since 0.2.0.0-instance (p <= n)         => Weaken (FromTo n m)    (From p)+instance (p <= n)         => Weaken (FromTo n m)        (From p) -- | @since 0.2.0.0-instance (m <= q)         => Weaken (FromTo n m)    (To q)+instance (m <= q)         => Weaken (FromTo n m)        (To q)+-- | @since 0.8.1+instance (n <= m)         => Weaken (SizeLessThan n)    (SizeLessThan m)+-- | @since 0.8.1+instance (m <= n)         => Weaken (SizeGreaterThan n) (SizeGreaterThan m)  -- | This function helps type inference. --   It is equivalent to the following:@@ -1373,6 +1391,50 @@ --   @since 0.2.0.0 rightOr :: Refined r x -> Refined (Or l r) x rightOr = coerce++-- | This function helps type inference.+--   It is equivalent to the following:+--+-- @+-- instance Weaken from to => Weaken (And from x) (And to x)+-- @+--+--   @since 0.8.1.0+weakenAndLeft :: Weaken from to => Refined (And from x) a -> Refined (And to x) a+weakenAndLeft = coerce++-- | This function helps type inference.+--   It is equivalent to the following:+--+-- @+-- instance Weaken from to => Weaken (And x from) (And x to)+-- @+--+--   @since 0.8.1.0+weakenAndRight :: Weaken from to => Refined (And x from) a -> Refined (And x to) a+weakenAndRight = coerce++-- | This function helps type inference.+--   It is equivalent to the following:+--+-- @+-- instance Weaken from to => Weaken (Or from x) (Or to x)+-- @+--+--   @since 0.8.1.0+weakenOrLeft :: Weaken from to => Refined (And from x) a -> Refined (And to x) a+weakenOrLeft = coerce++-- | This function helps type inference.+--   It is equivalent to the following:+--+-- @+-- instance Weaken from to => Weaken (Or x from) (Or x to)+-- @+--+--   @since 0.8.1.0+weakenOrRight :: Weaken from to => Refined (And x from) a -> Refined (And x to) a+weakenOrRight = coerce  -- | Strengthen a refinement by composing it with another. --
src/Refined/Unsafe.hs view
@@ -29,6 +29,7 @@  {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE PolyKinds #-} #if __GLASGOW_HASKELL__ >= 805 {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE RankNTypes #-}
src/Refined/Unsafe/Type.hs view
@@ -31,6 +31,7 @@ {-# LANGUAGE DeriveFoldable             #-} {-# LANGUAGE DerivingStrategies         #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE PolyKinds                  #-} {-# LANGUAGE RoleAnnotations            #-} {-# LANGUAGE TemplateHaskell            #-} @@ -54,7 +55,7 @@ -- | A refinement type, which wraps a value of type @x@. -- --   @since 0.1.0.0-newtype Refined p x+newtype Refined (p :: k) x   = Refined x -- ^ @since 0.1.0.0   deriving newtype     ( Eq -- ^ @since 0.1.0.0