{-# LANGUAGE OverloadedStrings #-}
module PlutusCore.Check.Value
    ( isTermValue
    ) where

import PlutusCore.Core
import PlutusCore.Error

import Data.Either

isTermValue :: Term tyname name uni fun ann -> Bool
isTermValue :: Term tyname name uni fun ann -> Bool
isTermValue = Either (NormCheckError tyname name uni fun ann) () -> Bool
forall a b. Either a b -> Bool
isRight (Either (NormCheckError tyname name uni fun ann) () -> Bool)
-> (Term tyname name uni fun ann
    -> Either (NormCheckError tyname name uni fun ann) ())
-> Term tyname name uni fun ann
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term tyname name uni fun ann
-> Either (NormCheckError tyname name uni fun ann) ()
forall tyname name (uni :: * -> *) fun ann.
Term tyname name uni fun ann
-> Either (NormCheckError tyname name uni fun ann) ()
termValue

termValue :: Term tyname name uni fun ann -> Either (NormCheckError tyname name uni fun ann) ()
termValue :: Term tyname name uni fun ann
-> Either (NormCheckError tyname name uni fun ann) ()
termValue (IWrap ann
_ Type tyname uni ann
_ Type tyname uni ann
_ Term tyname name uni fun ann
term) = Term tyname name uni fun ann
-> Either (NormCheckError tyname name uni fun ann) ()
forall tyname name (uni :: * -> *) fun ann.
Term tyname name uni fun ann
-> Either (NormCheckError tyname name uni fun ann) ()
termValue Term tyname name uni fun ann
term
termValue LamAbs {}          = () -> Either (NormCheckError tyname name uni fun ann) ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
termValue TyAbs {}           = () -> Either (NormCheckError tyname name uni fun ann) ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
termValue Constant {}        = () -> Either (NormCheckError tyname name uni fun ann) ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
termValue Term tyname name uni fun ann
t                  = NormCheckError tyname name uni fun ann
-> Either (NormCheckError tyname name uni fun ann) ()
forall a b. a -> Either a b
Left (NormCheckError tyname name uni fun ann
 -> Either (NormCheckError tyname name uni fun ann) ())
-> NormCheckError tyname name uni fun ann
-> Either (NormCheckError tyname name uni fun ann) ()
forall a b. (a -> b) -> a -> b
$ ann
-> Term tyname name uni fun ann
-> Text
-> NormCheckError tyname name uni fun ann
forall tyname name (uni :: * -> *) fun ann.
ann
-> Term tyname name uni fun ann
-> Text
-> NormCheckError tyname name uni fun ann
BadTerm (Term tyname name uni fun ann -> ann
forall tyname name (uni :: * -> *) fun ann.
Term tyname name uni fun ann -> ann
termAnn Term tyname name uni fun ann
t) Term tyname name uni fun ann
t Text
"term value"