imports

module Plutarch.Docs.UsePlet (pfoo, pfoo') where
import Plutarch.Prelude

plet to avoid work duplication

Sometimes, when writing Haskell level functions working on Plutarch terms, you may find yourself needing to re-use the Haskell level function's argument(s) multiple times:

pfoo :: forall s. Term s PString -> Term s PString
pfoo x = x <> x

In such cases, you should use plet on the argument to avoid duplicating work.

pfoo' :: forall s. Term s PString -> Term s PString
pfoo' x = plet x $ \x' -> x' <> x'