-- | This module exports all available examples via a data type which allows to test
-- various procedures (pretty-printing, type checking, etc) over the entire set of examples
-- in a convenient way: each time a function / data type is added to examples, none of the
-- tests is required to be adapted, instead you just add the new definition to 'examples'
-- defined below and all the tests see it automatically.

{-# LANGUAGE ScopedTypeVariables #-}

module PlutusCore.Examples.Everything
    ( examples
    , builtins
    ) where

import PlutusPrelude

import PlutusCore.Core
import PlutusCore.Default
import PlutusCore.FsTree
import PlutusCore.MkPlc

import PlutusCore.StdLib.Type

import PlutusCore.Examples.Builtins
import PlutusCore.Examples.Data.Data
import PlutusCore.Examples.Data.InterList
import PlutusCore.Examples.Data.List
import PlutusCore.Examples.Data.Pair
import PlutusCore.Examples.Data.Shad
import PlutusCore.Examples.Data.TreeForest
import PlutusCore.Examples.Data.Vec

-- | All examples exported as a single value.
examples :: PlcFolderContents DefaultUni (Either DefaultFun ExtensionFun)
examples :: PlcFolderContents DefaultUni (Either DefaultFun ExtensionFun)
examples =
    [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> PlcFolderContents DefaultUni (Either DefaultFun ExtensionFun)
forall a. [FsTree a] -> FolderContents a
FolderContents
      [ String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"Examples"
          [ String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"Data"
              [ String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"ofoldrData" Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
ofoldrData
              ]
          , String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"InterList"
              [ String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"InterList"      (Type TyName DefaultUni ()
 -> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun)))
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a b. (a -> b) -> a -> b
$ RecursiveType DefaultUni Any () -> Type TyName DefaultUni ()
forall (uni :: * -> *) fun ann.
RecursiveType uni fun ann -> Type TyName uni ann
_recursiveType RecursiveType DefaultUni Any ()
forall (uni :: * -> *) fun. RecursiveType uni fun ()
interListData
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"InterNil"       Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun. Term TyName Name uni fun ()
interNil
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"InterCons"      Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun. Term TyName Name uni fun ()
interCons
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"FoldrInterList" Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun.
Includes uni () =>
Term TyName Name uni fun ()
foldrInterList
              ]
          , String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"List"
              [ String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"omapList" Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
omapList
              ]
          , String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"Pair"
              [ String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"obothPair" Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (term :: * -> *).
TermLike
  term TyName Name DefaultUni (Either DefaultFun ExtensionFun) =>
term ()
obothPair
              ]
          , String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"TreeForest"
              [ String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"Tree"       (Type TyName DefaultUni ()
 -> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun)))
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a b. (a -> b) -> a -> b
$ RecursiveType DefaultUni Any () -> Type TyName DefaultUni ()
forall (uni :: * -> *) fun ann.
RecursiveType uni fun ann -> Type TyName uni ann
_recursiveType RecursiveType DefaultUni Any ()
forall (uni :: * -> *) fun. RecursiveType uni fun ()
treeData
              , String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"Forest"     (Type TyName DefaultUni ()
 -> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun)))
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a b. (a -> b) -> a -> b
$ RecursiveType DefaultUni Any () -> Type TyName DefaultUni ()
forall (uni :: * -> *) fun ann.
RecursiveType uni fun ann -> Type TyName uni ann
_recursiveType RecursiveType DefaultUni Any ()
forall (uni :: * -> *) fun. RecursiveType uni fun ()
forestData
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"TreeNode"   Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun.
HasUniApply uni =>
Term TyName Name uni fun ()
treeNode
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"ForestNil"  Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun.
HasUniApply uni =>
Term TyName Name uni fun ()
forestNil
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"ForestCons" Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun.
HasUniApply uni =>
Term TyName Name uni fun ()
forestCons
              ]
          , String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"Vec"
              [ String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"zeroT"            Type TyName DefaultUni ()
forall (uni :: * -> *). Type TyName uni ()
zeroT
              , String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"succT"            Type TyName DefaultUni ()
forall (uni :: * -> *). Type TyName uni ()
succT
              , String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"plusT"            Type TyName DefaultUni ()
forall (uni :: * -> *). Type TyName uni ()
plusT
              , String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"churchVec"        Type TyName DefaultUni ()
forall (uni :: * -> *). Type TyName uni ()
churchVec
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"churchNil"        Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun. Term TyName Name uni fun ()
churchNil
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"churchCons"       Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun. Term TyName Name uni fun ()
churchCons
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"churchConcat"     Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun. Term TyName Name uni fun ()
churchConcat
              , String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"scottVec"         Type TyName DefaultUni ()
forall (uni :: * -> *). Type TyName uni ()
scottVec
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"scottNil"         Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun. Term TyName Name uni fun ()
scottNil
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"scottCons"        Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun. Term TyName Name uni fun ()
scottCons
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"scottHead"        Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun.
Includes uni () =>
Term TyName Name uni fun ()
scottHead
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"scottSumHeadsOr0" (Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
 -> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun)))
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a b. (a -> b) -> a -> b
$ (DefaultFun -> Either DefaultFun ExtensionFun)
-> Term TyName Name DefaultUni DefaultFun ()
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall fun fun' tyname name (uni :: * -> *) ann.
(fun -> fun')
-> Term tyname name uni fun ann -> Term tyname name uni fun' ann
mapFun DefaultFun -> Either DefaultFun ExtensionFun
forall a b. a -> Either a b
Left Term TyName Name DefaultUni DefaultFun ()
forall (uni :: * -> *).
(Includes uni Integer, Includes uni ()) =>
Term TyName Name uni DefaultFun ()
scottSumHeadsOr0
              ]
          , String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"Shad"
              [ String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"shad"   Type TyName DefaultUni ()
forall (uni :: * -> *). Includes uni Integer => Type TyName uni ()
shad
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"mkShad" Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun.
Includes uni Integer =>
Term TyName Name uni fun ()
mkShad
              ]
          , String
-> [FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))]
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"RecUnit"
              [ String
-> Type TyName DefaultUni ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Type TyName uni () -> PlcFsTree uni fun
plcTypeFile String
"recUnit"    Type TyName DefaultUni ()
forall (uni :: * -> *). Includes uni () => Type TyName uni ()
recUnit
              , String
-> Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
-> FsTree (PlcEntity DefaultUni (Either DefaultFun ExtensionFun))
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile String
"runRecUnit" Term TyName Name DefaultUni (Either DefaultFun ExtensionFun) ()
forall (uni :: * -> *) fun.
Includes uni () =>
Term TyName Name uni fun ()
runRecUnit
              ]
          ]
      ]

builtins :: PlcFolderContents DefaultUni ExtensionFun
builtins :: PlcFolderContents DefaultUni ExtensionFun
builtins =
    [FsTree (PlcEntity DefaultUni ExtensionFun)]
-> PlcFolderContents DefaultUni ExtensionFun
forall a. [FsTree a] -> FolderContents a
FolderContents
        [ String
-> [FsTree (PlcEntity DefaultUni ExtensionFun)]
-> FsTree (PlcEntity DefaultUni ExtensionFun)
forall a. String -> [FsTree a] -> FsTree a
treeFolderContents String
"Builtins" ([FsTree (PlcEntity DefaultUni ExtensionFun)]
 -> FsTree (PlcEntity DefaultUni ExtensionFun))
-> [FsTree (PlcEntity DefaultUni ExtensionFun)]
-> FsTree (PlcEntity DefaultUni ExtensionFun)
forall a b. (a -> b) -> a -> b
$
            (ExtensionFun -> FsTree (PlcEntity DefaultUni ExtensionFun))
-> [ExtensionFun] -> [FsTree (PlcEntity DefaultUni ExtensionFun)]
forall a b. (a -> b) -> [a] -> [b]
map (\ExtensionFun
fun -> String
-> Term TyName Name DefaultUni ExtensionFun ()
-> FsTree (PlcEntity DefaultUni ExtensionFun)
forall (uni :: * -> *) fun.
String -> Term TyName Name uni fun () -> PlcFsTree uni fun
plcTermFile (ExtensionFun -> String
forall a. Show a => a -> String
show ExtensionFun
fun) (Term TyName Name DefaultUni ExtensionFun ()
 -> FsTree (PlcEntity DefaultUni ExtensionFun))
-> Term TyName Name DefaultUni ExtensionFun ()
-> FsTree (PlcEntity DefaultUni ExtensionFun)
forall a b. (a -> b) -> a -> b
$ () -> ExtensionFun -> Term TyName Name DefaultUni ExtensionFun ()
forall (term :: * -> *) tyname name (uni :: * -> *) fun ann.
TermLike term tyname name uni fun =>
ann -> fun -> term ann
builtin () ExtensionFun
fun) [ExtensionFun]
forall a. (Bounded a, Enum a) => [a]
enumeration
        ]