{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module PlutusIR.MkPir ( module MkPlc
, DatatypeDef
, mkLet
) where
import PlutusIR
import PlutusCore.MkPlc as MkPlc
import Data.List.NonEmpty qualified as NE
type DatatypeDef tyname name uni a = Def (TyVarDecl tyname a) (Datatype tyname name uni a)
mkLet
:: a
-> Recursivity
-> [Binding tyname name uni fun a]
-> Term tyname name uni fun a
-> Term tyname name uni fun a
mkLet :: forall a tyname name (uni :: * -> *) fun.
a
-> Recursivity
-> [Binding tyname name uni fun a]
-> Term tyname name uni fun a
-> Term tyname name uni fun a
mkLet a
x Recursivity
r [Binding tyname name uni fun a]
bs Term tyname name uni fun a
t = case [Binding tyname name uni fun a]
-> Maybe (NonEmpty (Binding tyname name uni fun a))
forall a. [a] -> Maybe (NonEmpty a)
NE.nonEmpty [Binding tyname name uni fun a]
bs of
Maybe (NonEmpty (Binding tyname name uni fun a))
Nothing -> Term tyname name uni fun a
t
Just NonEmpty (Binding tyname name uni fun a)
bs' -> a
-> Recursivity
-> NonEmpty (Binding tyname name uni fun a)
-> Term tyname name uni fun a
-> Term tyname name uni fun a
forall tyname name (uni :: * -> *) fun a.
a
-> Recursivity
-> NonEmpty (Binding tyname name uni fun a)
-> Term tyname name uni fun a
-> Term tyname name uni fun a
Let a
x Recursivity
r NonEmpty (Binding tyname name uni fun a)
bs' Term tyname name uni fun a
t