Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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'