packages feed

composite-base 0.8.0.0 → 0.8.1.0

raw patch · 4 files changed

+51/−12 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Composite.CoRecord: instance Data.Functor.Contravariant.Contravariant (Composite.CoRecord.Case b)
+ Composite.CoRecord: instance GHC.Base.Functor f => Data.Functor.Contravariant.Contravariant (Composite.CoRecord.Case' f b)
- Composite.Record: class RecWithContext (ss :: [*]) (ts :: [*])
+ Composite.Record: class RecWithContext (ss :: [Type]) (ts :: [Type])
- Composite.Record: class ReifyNames (rs :: [*])
+ Composite.Record: class ReifyNames (rs :: [Type])
- Composite.Record: reifyDicts :: forall u. forall (cs :: [u -> Constraint]) (f :: u -> *) (rs :: [u]) (proxy :: [u -> Constraint] -> *). (AllHave cs rs, RecApplicative rs) => proxy cs -> (forall proxy' (a :: u). HasInstances a cs => proxy' a -> f a) -> Rec f rs
+ Composite.Record: reifyDicts :: forall u. forall (cs :: [u -> Constraint]) (f :: u -> Type) (rs :: [u]) (proxy :: [u -> Constraint] -> Type). (AllHave cs rs, RecApplicative rs) => proxy cs -> (forall proxy' (a :: u). HasInstances a cs => proxy' a -> f a) -> Rec f rs

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2017 Confer Health, Inc.++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Confer Health nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
composite-base.cabal view
@@ -1,21 +1,22 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.5.+-- This file has been generated from package.yaml by hpack version 0.34.7. -- -- see: https://github.com/sol/hpack ----- hash: da6b479a20217b518ebbd91837b9c0a301f0bdef21bbc050013198b028cb8868+-- hash: 828a26708bec6f39a24df0756a3d2dd777fdf99297084fbc1c4296c62d49b8fb  name:           composite-base-version:        0.8.0.0+version:        0.8.1.0 synopsis:       Shared utilities for composite-* packages. description:    Shared helpers for the various composite packages. category:       Records-homepage:       https://github.com/ConferOpenSource/composite#readme+homepage:       https://github.com/composite-hs/composite-base#readme author:         Confer Health, Inc. maintainer:     oss@vitalbio.com copyright:      2017 Confer Health, Inc., 2020-2021 Vital Biosciences license:        BSD3+license-file:   LICENSE build-type:     Simple  library
src/Composite/CoRecord.hs view
@@ -6,6 +6,7 @@ import Prelude import Composite.Record (AllHave, HasInstances, (:->)(getVal, Val), reifyDicts, reifyVal, val, zipRecsWith) import Control.Lens (Prism', prism')+import Data.Functor.Contravariant (Contravariant(contramap)) import Data.Functor.Identity (Identity(Identity), runIdentity) import Data.Kind (Constraint) import Data.Maybe (fromMaybe)@@ -190,6 +191,9 @@ -- |An extractor function @f a -> b@ which can be passed to 'foldCoRec' to eliminate one possible alternative of a 'CoRec'. newtype Case' f b a = Case' { unCase' :: f a -> b } +instance Functor f => Contravariant (Case' f b) where+  contramap f (Case' r) = Case' $ \x -> r (fmap f x) + -- |A record of @Case'@ eliminators for each @r@ in @rs@ representing the pieces of a total function from @'CoRec' f@ to @b@. type Cases' f rs b = Rec (Case' f b) rs @@ -212,6 +216,10 @@ {-# INLINE matchCoRec #-}  newtype Case b a = Case { unCase :: a -> b }++instance Contravariant (Case b) where+  contramap f (Case r) = Case $ r . f+ type Cases rs b = Rec (Case b) rs  -- |Fold a 'Field' using 'Cases' which eliminate each possible value held by the 'Field', yielding the @b@ produced by whichever case matches.
src/Composite/Record.hs view
@@ -17,7 +17,7 @@ import Control.Lens.TH (makeWrapped) import Data.Functor.Identity (Identity(Identity)) import Data.Functor.Contravariant (Contravariant(contramap))-import Data.Kind (Constraint)+import Data.Kind (Constraint, Type) import Data.List.NonEmpty (NonEmpty((:|))) import Data.Proxy (Proxy(Proxy)) import Data.String (IsString)@@ -80,7 +80,7 @@   traverse k (Val a) = Val <$> k a   {-# INLINE traverse #-} instance Monad ((:->) s) where-  return = Val+  return = pure   {-# INLINE return #-}   Val a >>= k = k a   {-# INLINE (>>=) #-}@@ -299,14 +299,14 @@ -- |Given a list of constraints @cs@, apply some function for each @r@ in the target record type @rs@ with proof that those constraints hold for @r@, -- generating a record with the result of each application. reifyDicts-  :: forall u. forall (cs :: [u -> Constraint]) (f :: u -> *) (rs :: [u]) (proxy :: [u -> Constraint] -> *).+  :: forall u. forall (cs :: [u -> Constraint]) (f :: u -> Type) (rs :: [u]) (proxy :: [u -> Constraint] -> Type).      (AllHave cs rs, RecApplicative rs)   => proxy cs   -> (forall proxy' (a :: u). HasInstances a cs => proxy' a -> f a)   -> Rec f rs reifyDicts x f = go x (rpure (Const ())) f   where-    go :: forall (f :: u -> *) (cs :: [u -> Constraint]) (rs' :: [u]) (proxy :: [u -> Constraint] -> *). AllHave cs rs'+    go :: forall (f :: u -> Type) (cs :: [u -> Constraint]) (rs' :: [u]) (proxy :: [u -> Constraint] -> Type). AllHave cs rs'        => proxy cs        -> Rec (Const ()) rs'        -> (forall proxy' (a :: u). HasInstances a cs => proxy' a -> f a)@@ -316,18 +316,18 @@ {-# INLINE reifyDicts #-}  -- |Class which reifies the symbols of a record composed of ':->' fields as 'Text'.-class ReifyNames (rs :: [*]) where+class ReifyNames (rs :: [Type]) where   -- |Given a @'Rec' f rs@ where each @r@ in @rs@ is of the form @s ':->' a@, make a record which adds the 'Text' for each @s@.   reifyNames :: Rec f rs -> Rec ((,) Text :. f) rs  instance ReifyNames '[] where   reifyNames _ = RNil -instance forall (s :: Symbol) a (rs :: [*]). (KnownSymbol s, ReifyNames rs) => ReifyNames (s :-> a ': rs) where+instance forall (s :: Symbol) a (rs :: [Type]). (KnownSymbol s, ReifyNames rs) => ReifyNames (s :-> a ': rs) where   reifyNames (fa :& rs) = Compose ((,) (pack $ symbolVal (Proxy @s)) fa) :& reifyNames rs  -- |Class with 'Data.Vinyl.rmap' but which gives the natural transformation evidence that the value its working over is contained within the overall record @ss@.-class RecWithContext (ss :: [*]) (ts :: [*]) where+class RecWithContext (ss :: [Type]) (ts :: [Type]) where   -- |Apply a natural transformation from @f@ to @g@ to each field of the given record, except that the natural transformation can be mildly unnatural by having   -- evidence that @r@ is in @ss@.   rmapWithContext :: proxy ss -> (forall r. r ∈ ss => f r -> g r) -> Rec f ts -> Rec g ts@@ -335,7 +335,7 @@ instance RecWithContext ss '[] where   rmapWithContext _ _ _ = RNil -instance forall r (ss :: [*]) (ts :: [*]). (r ∈ ss, RecWithContext ss ts) => RecWithContext ss (r ': ts) where+instance forall r (ss :: [Type]) (ts :: [Type]). (r ∈ ss, RecWithContext ss ts) => RecWithContext ss (r ': ts) where   rmapWithContext proxy n (r :& rs) = n r :& rmapWithContext proxy n rs  -- |Type function which removes the first element @r@ from a list @rs@, and doesn't expand if @r@ is not present in @rs@.