implicit-params 0.2 → 0.2.1
raw patch · 2 files changed
+28/−10 lines, 2 filesdep ~base
Dependency ranges changed: base
Files
- implicit-params.cabal +5/−5
- src/Data/Implicit.hs +23/−5
implicit-params.cabal view
@@ -1,5 +1,5 @@ name: implicit-params-version: 0.2+version: 0.2.1 synopsis: Named and unnamed implicit parameters with defaults. license: BSD3 license-file: LICENSE@@ -9,8 +9,8 @@ category: Data cabal-version: >= 1.6 build-type: Simple-homepage: http://github.com/duairc/implicit-bug-reports: http://github.com/duairc/implicit/issues+homepage: http://github.com/duairc/implicit-params+bug-reports: http://github.com/duairc/implicit-params/issues description: Named and unnamed implicit parameters with defaults using type classes and constraint hacks. For examples, see "Data.Implicit".@@ -28,11 +28,11 @@ Data.Implicit build-depends:- base >= 4.3 && < 5,+ base >= 4 && < 5, data-default-class > 0 && < 0.1 ghc-options: -Wall source-repository head type: git- location: http://github.com/duairc/implicit+ location: http://github.com/duairc/implicit-params
src/Data/Implicit.hs view
@@ -2,12 +2,12 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds #-}-#endif {-# LANGUAGE Rank2Types #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-}+#if __GLASGOW_HASKELL__ >= 706+{-# LANGUAGE PolyKinds #-}+#endif {-| @@ -110,12 +110,14 @@ , param , setParam , (~$)+ , (~..) , ($$) , Implicit_ , param_ , setParam_ , ($~)+ , (~.) ) where @@ -161,6 +163,14 @@ ------------------------------------------------------------------------------+-- | Modify a named implicit parameter.+(~..) :: Implicit s a => (Implicit s b => c) -> proxy s -> (a -> b) -> c+(~..) f proxy g = f ~$ proxy $$ g (param proxy)+infixl 8 ~..+{-# INLINE (~..) #-}+++------------------------------------------------------------------------------ -- | A left-associated version of '$'. ($$) :: (a -> b) -> a -> b infixl 0 $$@@ -172,13 +182,13 @@ -- | The constraint @'Implicit_' String@ on a function @f@ indicates that an -- unnamed implicit parameter of type @String@ is passed to @f@. class Implicit_ a where+ -- | 'param_' retrieves the unnamed implicit parameter of type @a@ from+ -- the context @'Implicit_' a@. param_ :: a ------------------------------------------------------------------------------ instance Default a => Implicit_ a where- -- | 'param_' retrieves the unnamed implicit parameter of type @a@ from- -- the context @'Implicit_' a@. param_ = def @@ -200,3 +210,11 @@ infixl 1 $~ f $~ a = unsafeCoerce (Param_ f :: Param_ a b) a {-# INLINE ($~) #-}+++------------------------------------------------------------------------------+-- | Modify an unnamed implicit parameter.+(~.) :: Implicit_ a => (Implicit_ b => c) -> (a -> b) -> c+f ~. g = f $~ g param_+infixl 8 ~.+{-# INLINE (~.) #-}