Skip to content

Commit

Permalink
Add composition of plutarch functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesku committed Jan 18, 2022
1 parent 231267e commit b5977fe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Plutarch.hs
Expand Up @@ -29,6 +29,7 @@ module Plutarch (
printScript,
(#$),
(#),
(#.),
pinl,
PCon (..),
PMatch (..),
Expand Down Expand Up @@ -85,6 +86,17 @@ infixl 8 #

infixr 0 #$

{- |
Composition of Plutarch level functions
>>> f #. g #$ x
f (g x)
-}
(#.) :: Term s (b :--> c) -> Term s (a :--> b) -> Term s (a :--> c)
(#.) bc ab = plam $ \a -> bc #$ ab # a

infixr 7 #.

{- $plam
Lambda abstraction.
Expand Down Expand Up @@ -234,3 +246,4 @@ pfix = phoistAcyclic $
plam $ \f ->
(plam $ \(x :: Term s POpaque) -> f # (plam $ \(v :: Term s POpaque) -> (punsafeCoerce x) # x # v))
# punsafeCoerce (plam $ \(x :: Term s POpaque) -> f # (plam $ \(v :: Term s POpaque) -> (punsafeCoerce x) # x # v))

0 comments on commit b5977fe

Please sign in to comment.