prolude 0.0.0.17 → 0.0.0.18
raw patch · 3 files changed
+48/−23 lines, 3 filesdep ~generic-randomPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: generic-random
API changes (from Hackage documentation)
+ Prolude.Core: bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d
+ Prolude.Core: class Bifunctor (p :: Type -> Type -> Type)
+ Prolude.Core: first :: Bifunctor p => (a -> b) -> p a c -> p b c
+ Prolude.Core: second :: Bifunctor p => (b -> c) -> p a b -> p a c
+ Prolude.Swagger: nameSchema :: Typeable a => proxy a -> Schema -> NamedSchema
- Prolude.Swagger: defaultDeclareNamedSchema :: Applicative f => (Schema -> Schema) -> proxy a -> f NamedSchema
+ Prolude.Swagger: defaultDeclareNamedSchema :: (Typeable a, Applicative f) => (Schema -> Schema) -> proxy a -> f NamedSchema
Files
- Prolude/Core.hs +2/−0
- Prolude/Swagger.hs +44/−21
- prolude.cabal +2/−2
Prolude/Core.hs view
@@ -7,6 +7,7 @@ , module Data.Monoid -- * Base re-exports , module Data.Bool+ , module Data.Bifunctor , module Data.Either , module Data.Eq , module Data.Foldable@@ -48,6 +49,7 @@ import Control.Monad (Monad((>>), (>>=))) import Control.Monad.Fail (MonadFail(fail)) import Data.Bool (Bool(False, True), not, otherwise, (&&), (||))+import Data.Bifunctor (Bifunctor(bimap, first, second)) import Data.Char (Char, chr, ord) import Data.Either (Either(Left, Right), either) import Data.Eq (Eq((/=), (==)))
Prolude/Swagger.hs view
@@ -1,30 +1,53 @@ {-# LANGUAGE ConstraintKinds #-} -module Prolude.Swagger - ( -- * SwaggerType re-export- Swagger.SwaggerType(..)- -- * Alias types- -- $alias- , SwaggerToSchema- , SwaggerToParamSchema- -- * Functions- , defaultDeclareNamedSchema- )-where+module Prolude.Swagger+ ( -- * SwaggerType re-export+ Swagger.SwaggerType(..)+ -- * Alias types+ , SwaggerToSchema+ , SwaggerToParamSchema+ -- * Functions+ , defaultDeclareNamedSchema+ , nameSchema+ ) where import qualified Data.Swagger as Swagger-import qualified Data.Swagger.Declare as Swagger-import qualified Data.Swagger.Internal.Schema as Swagger-import qualified Data.Swagger.Internal.TypeShape as Swagger--{- $alias-We created type aliases for Swagger.ToSchema and Swagger.ToParamSchema.--}+import qualified Data.Text as Text+import qualified Data.Typeable as Typeable type SwaggerToParamSchema = Swagger.ToParamSchema+ type SwaggerToSchema = Swagger.ToSchema --- | Function to help with Swagger.ToSchema instances+-- | This function makes it easy to define a 'Swagger.ToSchema' instance. Just+-- pass in a function that modifies the default empty schema and you're good to+-- go. For example:+--+-- > instance ToSchema SomeType where+-- > declareNamedSchema = defaultDeclareNamedSchema+-- > $ set type_ (Just SwaggerObject)+-- > . set title (Just "some type") defaultDeclareNamedSchema- :: Applicative f => (Swagger.Schema -> Swagger.Schema) -> proxy a -> f Swagger.NamedSchema-defaultDeclareNamedSchema f = const . pure . Swagger.NamedSchema Nothing $ f mempty+ :: (Typeable.Typeable a, Applicative f)+ => (Swagger.Schema -> Swagger.Schema)+ -> proxy a+ -> f Swagger.NamedSchema+defaultDeclareNamedSchema modify proxy =+ let+ schema = modify mempty+ namedSchema = nameSchema proxy schema+ in pure namedSchema++-- | Generates a unique name for the given type and adds that name to the+-- schema. The generated name will be like @ModuleName.TypeName@. For example+-- it might be @Data.Maybe.Maybe@.+nameSchema :: Typeable.Typeable a => proxy a -> Swagger.Schema -> Swagger.NamedSchema+nameSchema proxy schema =+ let+ typeRep = Typeable.typeRep proxy+ tyCon = Typeable.typeRepTyCon typeRep+ moduleName = Typeable.tyConModule tyCon+ typeName = Typeable.tyConName tyCon+ nameString = mconcat [moduleName, ".", typeName]+ nameText = Text.pack nameString+ in Swagger.NamedSchema (Just nameText) schema
prolude.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.10 name: prolude-version: 0.0.0.17+version: 0.0.0.18 synopsis: ITProTV's custom prelude description: Prolude is ITProTV's custom prelude.@@ -52,7 +52,7 @@ , bytestring >= 0.10.10 && < 0.11 , cassava >= 0.5.2.0 && < 0.6 , containers >= 0.6.2 && < 0.7- , generic-random >= 1.3.0 && < 1.4+ , generic-random >= 1.3.0 && < 1.5 , mongoDB >= 2.7.0 && < 2.8 , mtl >= 2.2.2 && < 2.3 , QuickCheck >= 2.13.2 && < 2.15