-- | This module defines tools for associating PLC terms with their corresponding
-- Haskell values.

{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs           #-}
{-# LANGUAGE RankNTypes      #-}

module PlutusCore.Generators.Hedgehog.Denotation
    ( KnownType
    , Denotation(..)
    , DenotationContextMember(..)
    , DenotationContext(..)
    , lookupInContext
    , denoteVariable
    , insertVariable
    , insertBuiltin
    , typedBuiltins
    ) where

import PlutusCore.Builtin
import PlutusCore.Core
import PlutusCore.Default
import PlutusCore.Name.Unique
import PlutusPrelude

import Data.Dependent.Map (DMap)
import Data.Dependent.Map qualified as DMap
import Data.Functor.Compose
import Type.Reflection

type KnownType val a = (KnownTypeAst TyName (UniOf val) a, MakeKnown val a)

-- | Haskell denotation of a PLC object. An object can be a 'Builtin' or a variable for example.
data Denotation term object res = forall args. Denotation
    { forall term object res. Denotation term object res -> object
_denotationObject :: object
      -- ^ A PLC object.
    , forall term object res.
Denotation term object res -> object -> term
_denotationToTerm :: object -> term
      -- ^ How to embed the object into a term.
    , ()
_denotationItself :: FoldArgs args res
      -- ^ The denotation of the object. E.g. the denotation of 'AddInteger' is '(+)'.
    , ()
_denotationScheme :: TypeScheme term args res
      -- ^ The 'TypeScheme' of the object.
    }

-- | A member of a 'DenotationContext'.
-- @object@ is existentially quantified, so the only thing that can be done with it,
-- is turning it into a 'Term' using '_denotationToTerm'.
data DenotationContextMember term res =
    forall object. DenotationContextMember (Denotation term object res)

-- | A context of 'DenotationContextMember's.
-- Each row is a mapping from a type to a list of things that can return that type.
-- For example it can contain a mapping from @integer@ to
--   1. a bound variable of type @integer@
--   2. a bound variable of functional type with the result being @integer@
--   3. the 'AddInteger' 'Builtin' or any other 'Builtin' which returns an @integer@.
newtype DenotationContext term = DenotationContext
    { forall term.
DenotationContext term
-> DMap TypeRep (Compose [] (DenotationContextMember term))
unDenotationContext :: DMap TypeRep (Compose [] (DenotationContextMember term))
    }

-- | Look up a list of 'Denotation's from 'DenotationContext' each of which has a type that ends in
-- the same type as the one that the 'TypeRep' argument represents.
lookupInContext
    :: forall a term.
       TypeRep a
    -> DenotationContext term
    -> [DenotationContextMember term a]
lookupInContext :: forall a term.
TypeRep a
-> DenotationContext term -> [DenotationContextMember term a]
lookupInContext TypeRep a
tr = (Compose [] (DenotationContextMember term) a
 -> [DenotationContextMember term a])
-> Maybe (Compose [] (DenotationContextMember term) a)
-> [DenotationContextMember term a]
forall m a. Monoid m => (a -> m) -> Maybe a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap Compose [] (DenotationContextMember term) a
-> [DenotationContextMember term a]
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Maybe (Compose [] (DenotationContextMember term) a)
 -> [DenotationContextMember term a])
-> (DenotationContext term
    -> Maybe (Compose [] (DenotationContextMember term) a))
-> DenotationContext term
-> [DenotationContextMember term a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeRep a
-> DMap TypeRep (Compose [] (DenotationContextMember term))
-> Maybe (Compose [] (DenotationContextMember term) a)
forall {k1} (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare k2 =>
k2 v -> DMap k2 f -> Maybe (f v)
DMap.lookup TypeRep a
tr (DMap TypeRep (Compose [] (DenotationContextMember term))
 -> Maybe (Compose [] (DenotationContextMember term) a))
-> (DenotationContext term
    -> DMap TypeRep (Compose [] (DenotationContextMember term)))
-> DenotationContext term
-> Maybe (Compose [] (DenotationContextMember term) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DenotationContext term
-> DMap TypeRep (Compose [] (DenotationContextMember term))
forall term.
DenotationContext term
-> DMap TypeRep (Compose [] (DenotationContextMember term))
unDenotationContext

-- Here the only search that we need to perform is the search for things that return an appropriate
-- @r@, be them variables or functions. Better if we also take types of arguments into account,
-- but it is not required as we can always generate an argument out of thin air in a rank-0 setting
-- (without @Void@).

-- | The resulting type of a 'TypeScheme'.
withTypeSchemeResult :: TypeScheme term args res -> (KnownType term res => TypeRep res -> c) -> c
withTypeSchemeResult :: forall term (args :: [*]) res c.
TypeScheme term args res
-> (KnownType term res => TypeRep res -> c) -> c
withTypeSchemeResult TypeScheme term args res
TypeSchemeResult       (KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
TypeRep res -> c
k = TypeRep res -> c
(KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
TypeRep res -> c
k TypeRep res
forall {k} (a :: k). Typeable a => TypeRep a
typeRep
withTypeSchemeResult (TypeSchemeArrow TypeScheme term args1 res
schB) (KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
TypeRep res -> c
k = TypeScheme term args1 res
-> ((KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
    TypeRep res -> c)
-> c
forall term (args :: [*]) res c.
TypeScheme term args res
-> (KnownType term res => TypeRep res -> c) -> c
withTypeSchemeResult TypeScheme term args1 res
schB TypeRep res -> c
(KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
TypeRep res -> c
k
withTypeSchemeResult (TypeSchemeAll Proxy '(text, uniq, kind)
_ TypeScheme term args res
schK) (KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
TypeRep res -> c
k = TypeScheme term args res
-> ((KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
    TypeRep res -> c)
-> c
forall term (args :: [*]) res c.
TypeScheme term args res
-> (KnownType term res => TypeRep res -> c) -> c
withTypeSchemeResult TypeScheme term args res
schK TypeRep res -> c
(KnownTypeAst TyName (UniOf term) res, MakeKnown term res) =>
TypeRep res -> c
k

-- | Get the 'Denotation' of a variable.
denoteVariable
    :: KnownType (Term TyName Name uni fun ()) res
    => Name -> TypeRep res -> res -> Denotation (Term TyName Name uni fun ()) Name res
denoteVariable :: forall (uni :: * -> *) fun res.
KnownType (Term TyName Name uni fun ()) res =>
Name
-> TypeRep res
-> res
-> Denotation (Term TyName Name uni fun ()) Name res
denoteVariable Name
name TypeRep res
tr res
meta = TypeRep res
-> (Typeable res =>
    Denotation (Term TyName Name uni fun ()) Name res)
-> Denotation (Term TyName Name uni fun ()) Name res
forall k (a :: k) r. TypeRep a -> (Typeable a => r) -> r
withTypeable TypeRep res
tr ((Typeable res =>
  Denotation (Term TyName Name uni fun ()) Name res)
 -> Denotation (Term TyName Name uni fun ()) Name res)
-> (Typeable res =>
    Denotation (Term TyName Name uni fun ()) Name res)
-> Denotation (Term TyName Name uni fun ()) Name res
forall a b. (a -> b) -> a -> b
$ Name
-> (Name -> Term TyName Name uni fun ())
-> FoldArgs '[] res
-> TypeScheme (Term TyName Name uni fun ()) '[] res
-> Denotation (Term TyName Name uni fun ()) Name res
forall term object res (args :: [*]).
object
-> (object -> term)
-> FoldArgs args res
-> TypeScheme term args res
-> Denotation term object res
Denotation Name
name (() -> Name -> Term TyName Name uni fun ()
forall tyname name (uni :: * -> *) fun ann.
ann -> name -> Term tyname name uni fun ann
Var ()) res
FoldArgs '[] res
meta TypeScheme (Term TyName Name uni fun ()) '[] res
forall res val.
(Typeable res, KnownTypeAst TyName (UniOf val) res,
 MakeKnown val res) =>
TypeScheme val '[] res
TypeSchemeResult

-- | Insert the 'Denotation' of an object into a 'DenotationContext'.
insertDenotation
    :: TypeRep res -> Denotation term object res -> DenotationContext term -> DenotationContext term
insertDenotation :: forall res term object.
TypeRep res
-> Denotation term object res
-> DenotationContext term
-> DenotationContext term
insertDenotation TypeRep res
tr Denotation term object res
denotation (DenotationContext DMap TypeRep (Compose [] (DenotationContextMember term))
vs) = DMap TypeRep (Compose [] (DenotationContextMember term))
-> DenotationContext term
forall term.
DMap TypeRep (Compose [] (DenotationContextMember term))
-> DenotationContext term
DenotationContext (DMap TypeRep (Compose [] (DenotationContextMember term))
 -> DenotationContext term)
-> DMap TypeRep (Compose [] (DenotationContextMember term))
-> DenotationContext term
forall a b. (a -> b) -> a -> b
$
    (Compose [] (DenotationContextMember term) res
 -> Compose [] (DenotationContextMember term) res
 -> Compose [] (DenotationContextMember term) res)
-> TypeRep res
-> Compose [] (DenotationContextMember term) res
-> DMap TypeRep (Compose [] (DenotationContextMember term))
-> DMap TypeRep (Compose [] (DenotationContextMember term))
forall {k1} (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare k2 =>
(f v -> f v -> f v) -> k2 v -> f v -> DMap k2 f -> DMap k2 f
DMap.insertWith'
        (\(Compose [DenotationContextMember term res]
xs) (Compose [DenotationContextMember term res]
ys) -> [DenotationContextMember term res]
-> Compose [] (DenotationContextMember term) res
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose ([DenotationContextMember term res]
 -> Compose [] (DenotationContextMember term) res)
-> [DenotationContextMember term res]
-> Compose [] (DenotationContextMember term) res
forall a b. (a -> b) -> a -> b
$ [DenotationContextMember term res]
xs [DenotationContextMember term res]
-> [DenotationContextMember term res]
-> [DenotationContextMember term res]
forall a. [a] -> [a] -> [a]
++ [DenotationContextMember term res]
ys)
        TypeRep res
tr
        ([DenotationContextMember term res]
-> Compose [] (DenotationContextMember term) res
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose [Denotation term object res -> DenotationContextMember term res
forall term res object.
Denotation term object res -> DenotationContextMember term res
DenotationContextMember Denotation term object res
denotation])
        DMap TypeRep (Compose [] (DenotationContextMember term))
vs

-- | Insert a variable into a 'DenotationContext'.
insertVariable
    :: KnownType (Term TyName Name uni fun ()) a
    => Name
    -> TypeRep a
    -> a
    -> DenotationContext (Term TyName Name uni fun ())
    -> DenotationContext (Term TyName Name uni fun ())
insertVariable :: forall (uni :: * -> *) fun a.
KnownType (Term TyName Name uni fun ()) a =>
Name
-> TypeRep a
-> a
-> DenotationContext (Term TyName Name uni fun ())
-> DenotationContext (Term TyName Name uni fun ())
insertVariable Name
name TypeRep a
tr = TypeRep a
-> Denotation (Term TyName Name uni fun ()) Name a
-> DenotationContext (Term TyName Name uni fun ())
-> DenotationContext (Term TyName Name uni fun ())
forall res term object.
TypeRep res
-> Denotation term object res
-> DenotationContext term
-> DenotationContext term
insertDenotation TypeRep a
tr (Denotation (Term TyName Name uni fun ()) Name a
 -> DenotationContext (Term TyName Name uni fun ())
 -> DenotationContext (Term TyName Name uni fun ()))
-> (a -> Denotation (Term TyName Name uni fun ()) Name a)
-> a
-> DenotationContext (Term TyName Name uni fun ())
-> DenotationContext (Term TyName Name uni fun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name
-> TypeRep a
-> a
-> Denotation (Term TyName Name uni fun ()) Name a
forall (uni :: * -> *) fun res.
KnownType (Term TyName Name uni fun ()) res =>
Name
-> TypeRep res
-> res
-> Denotation (Term TyName Name uni fun ()) Name res
denoteVariable Name
name TypeRep a
tr

-- | Insert a builtin into a 'DenotationContext'.
insertBuiltin
    :: DefaultFun
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin :: DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
fun =
    case BuiltinSemanticsVariant DefaultFun
-> DefaultFun
-> BuiltinMeaning
     (Term TyName Name DefaultUni DefaultFun ())
     (CostingPart DefaultUni DefaultFun)
forall val.
HasMeaningIn DefaultUni val =>
BuiltinSemanticsVariant DefaultFun
-> DefaultFun
-> BuiltinMeaning val (CostingPart DefaultUni DefaultFun)
forall (uni :: * -> *) fun val.
(ToBuiltinMeaning uni fun, HasMeaningIn uni val) =>
BuiltinSemanticsVariant fun
-> fun -> BuiltinMeaning val (CostingPart uni fun)
toBuiltinMeaning BuiltinSemanticsVariant DefaultFun
forall a. Default a => a
def DefaultFun
fun of
        BuiltinMeaning TypeScheme (Term TyName Name DefaultUni DefaultFun ()) args res
sch FoldArgs args res
meta CostingPart DefaultUni DefaultFun
-> BuiltinRuntime (Term TyName Name DefaultUni DefaultFun ())
_ ->
            TypeScheme (Term TyName Name DefaultUni DefaultFun ()) args res
-> (KnownType (Term TyName Name DefaultUni DefaultFun ()) res =>
    TypeRep res
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall term (args :: [*]) res c.
TypeScheme term args res
-> (KnownType term res => TypeRep res -> c) -> c
withTypeSchemeResult TypeScheme (Term TyName Name DefaultUni DefaultFun ()) args res
sch ((KnownType (Term TyName Name DefaultUni DefaultFun ()) res =>
  TypeRep res
  -> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
  -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (KnownType (Term TyName Name DefaultUni DefaultFun ()) res =>
    TypeRep res
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall a b. (a -> b) -> a -> b
$ \TypeRep res
tr ->
                TypeRep res
-> Denotation
     (Term TyName Name DefaultUni DefaultFun ()) DefaultFun res
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall res term object.
TypeRep res
-> Denotation term object res
-> DenotationContext term
-> DenotationContext term
insertDenotation TypeRep res
tr (Denotation
   (Term TyName Name DefaultUni DefaultFun ()) DefaultFun res
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> Denotation
     (Term TyName Name DefaultUni DefaultFun ()) DefaultFun res
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall a b. (a -> b) -> a -> b
$ DefaultFun
-> (DefaultFun -> Term TyName Name DefaultUni DefaultFun ())
-> FoldArgs args res
-> TypeScheme (Term TyName Name DefaultUni DefaultFun ()) args res
-> Denotation
     (Term TyName Name DefaultUni DefaultFun ()) DefaultFun res
forall term object res (args :: [*]).
object
-> (object -> term)
-> FoldArgs args res
-> TypeScheme term args res
-> Denotation term object res
Denotation DefaultFun
fun (() -> DefaultFun -> Term TyName Name DefaultUni DefaultFun ()
forall tyname name (uni :: * -> *) fun ann.
ann -> fun -> Term tyname name uni fun ann
Builtin ()) FoldArgs args res
meta TypeScheme (Term TyName Name DefaultUni DefaultFun ()) args res
sch

-- | A 'DenotationContext' that consists of 'DefaultFun's.
--
-- DEPRECATED: No need to update for a new builtin.
-- Outdated, since we moved to quickcheck generators.
typedBuiltins
    :: DenotationContext (Term TyName Name DefaultUni DefaultFun ())
typedBuiltins :: DenotationContext (Term TyName Name DefaultUni DefaultFun ())
typedBuiltins
    = DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
AddInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
SubtractInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
MultiplyInteger
    -- We insert those, but they don't really get selected, because the 'TypeRep' of
    -- @EvaluationResult Integer@ is different to the one of @Integer@ and when selection is
    -- performed only the latter is considered. Maybe we should add @EvaluationResult Integer@ to
    -- the set of built-in types to pick up from. Or maybe we should stop using 'TypeRep' and use
    -- something custom. Or maybe we should just remove these tests altogether.
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
DivideInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
RemainderInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
QuotientInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
ModInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
LessThanInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
LessThanEqualsInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
EqualsInteger
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
AppendByteString
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
Sha2_256
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
Sha3_256
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
Blake2b_224
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
Blake2b_256
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
Keccak_256
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
Ripemd_160
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
    -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultFun
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
insertBuiltin DefaultFun
EqualsByteString
    (DenotationContext (Term TyName Name DefaultUni DefaultFun ())
 -> DenotationContext (Term TyName Name DefaultUni DefaultFun ()))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall a b. (a -> b) -> a -> b
$ DMap
  TypeRep
  (Compose
     []
     (DenotationContextMember
        (Term TyName Name DefaultUni DefaultFun ())))
-> DenotationContext (Term TyName Name DefaultUni DefaultFun ())
forall term.
DMap TypeRep (Compose [] (DenotationContextMember term))
-> DenotationContext term
DenotationContext DMap
  TypeRep
  (Compose
     []
     (DenotationContextMember
        (Term TyName Name DefaultUni DefaultFun ())))
forall a. Monoid a => a
mempty