Skip to content

Commit

Permalink
Added ~. and ~.. for composing functions that take implicit parameter…
Browse files Browse the repository at this point in the history
…s with functions that take implicit parameters.
  • Loading branch information
duairc committed Dec 22, 2013
1 parent 00e484d commit 6094235
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions implicit-params.cabal
@@ -1,5 +1,5 @@
name: implicit-params
version: 0.2.0.1
version: 0.2.1
synopsis: Named and unnamed implicit parameters with defaults.
license: BSD3
license-file: LICENSE
Expand Down Expand Up @@ -28,7 +28,7 @@ library
Data.Implicit

build-depends:
base >= 4.2 && < 5,
base >= 4 && < 5,
data-default-class > 0 && < 0.1

ghc-options: -Wall
Expand Down
18 changes: 18 additions & 0 deletions src/Data/Implicit.hs
Expand Up @@ -110,12 +110,14 @@ module Data.Implicit
, param
, setParam
, (~$)
, (~..)
, ($$)

, Implicit_
, param_
, setParam_
, ($~)
, (~.)
)
where

Expand Down Expand Up @@ -160,6 +162,14 @@ infixl 1 ~$
{-# INLINE (~$) #-}


------------------------------------------------------------------------------
-- | 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
Expand Down Expand Up @@ -200,3 +210,11 @@ setParam_ a f = unsafeCoerce (Param_ f :: Param_ a b) a
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 ~. #-}

0 comments on commit 6094235

Please sign in to comment.