Skip to content

Commit

Permalink
enumerating bytestrings, enabled bytestring constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchapman committed Jan 20, 2021
1 parent 5a5b762 commit bdc2075
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions plutus-core/generators/Language/PlutusCore/Generators/NEAT/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ module Language.PlutusCore.Generators.NEAT.Type
import Control.Enumerable
import Control.Monad.Except
import Data.Bifunctor.TH
import Data.ByteString (ByteString, pack)
import Data.Coolean (Cool, false, toCool, true, (&&&))
import qualified Data.Stream as Stream
import qualified Data.Text as Text
import Language.PlutusCore
import Language.PlutusCore.Generators.NEAT.Common
import Text.Printf
--import qualified Data.ByteString as B

newtype Neutral a = Neutral
{ unNeutral :: a
Expand Down Expand Up @@ -131,9 +131,14 @@ instance Enumerable tyname => Enumerable (Neutral (TypeG tyname)) where

-- ** Enumerating terms

-- Word8 is enumerable so we get an enumerable instance via pack
instance Enumerable ByteString where
enumerate = share $ fmap pack access

data TermConstantG = TmIntegerG Integer
-- | TmByteStringG B.ByteString
| TmByteStringG ByteString
| TmStringG String
| TmBoolG Bool
deriving (Show, Eq)

deriveEnumerable ''TermConstantG
Expand Down Expand Up @@ -204,6 +209,8 @@ convertTypeBuiltin :: TypeBuiltinG -> Some (TypeIn DefaultUni)
convertTypeBuiltin TyByteStringG = Some (TypeIn DefaultUniByteString)
convertTypeBuiltin TyIntegerG = Some (TypeIn DefaultUniInteger)
convertTypeBuiltin TyStringG = Some (TypeIn DefaultUniString)
convertTypeBuiltin TyBoolG = Some (TypeIn DefaultUniBool)


-- |Convert well-kinded generated types to Plutus types.
--
Expand Down Expand Up @@ -267,9 +274,9 @@ convertClosedType tynames = convertType (emptyTyNameState tynames)
-- term. Violating this would point to an error in the
-- generator/checker.
convertTermConstant :: TermConstantG -> Some (ValueOf DefaultUni)
--convertTermConstant (TmByteStringG b) = Some $ ValueOf DefaultUniByteString b
convertTermConstant (TmIntegerG i) = Some $ ValueOf DefaultUniInteger i
convertTermConstant (TmStringG s) = Some $ ValueOf DefaultUniString s
convertTermConstant (TmByteStringG b) = Some $ ValueOf DefaultUniByteString b
convertTermConstant (TmIntegerG i) = Some $ ValueOf DefaultUniInteger i
convertTermConstant (TmStringG s) = Some $ ValueOf DefaultUniString s

convertBuiltin :: TermBuiltinG -> DefaultFun
convertBuiltin AddIntegerG = AddInteger
Expand Down

0 comments on commit bdc2075

Please sign in to comment.