diff --git a/plutus-tx/src/PlutusTx/IsData/Class.hs b/plutus-tx/src/PlutusTx/IsData/Class.hs index a542049147a..723e738ba2e 100644 --- a/plutus-tx/src/PlutusTx/IsData/Class.hs +++ b/plutus-tx/src/PlutusTx/IsData/Class.hs @@ -1,14 +1,16 @@ -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -fno-strictness #-} {-# OPTIONS_GHC -fno-specialise #-} module PlutusTx.IsData.Class where import Data.ByteString as BS -import Prelude (Integer, Maybe (..)) +import Prelude (Int, Integer, Maybe (..), error) import PlutusTx.Data @@ -18,6 +20,9 @@ import PlutusTx.Traversable import Data.Kind import Data.Void +import GHC.TypeLits (ErrorMessage (..), TypeError) + + {-# ANN module "HLint: ignore" #-} -- | A typeclass for types that can be converted to and from 'Data'. @@ -32,6 +37,11 @@ instance IsData Data where {-# INLINABLE fromData #-} fromData d = Just d +instance (TypeError ('Text "Int is not supported, use Integer instead")) + => IsData Int where + toData = error "unsupported" + fromData = error "unsupported" + instance IsData Integer where {-# INLINABLE toData #-} toData = I diff --git a/plutus-tx/src/PlutusTx/Lift/Instances.hs b/plutus-tx/src/PlutusTx/Lift/Instances.hs index 6e42f6c4efe..48c5b8510cd 100644 --- a/plutus-tx/src/PlutusTx/Lift/Instances.hs +++ b/plutus-tx/src/PlutusTx/Lift/Instances.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -22,6 +23,8 @@ import PlutusIR.MkPir import qualified Data.ByteString as BS import Data.Proxy +import GHC.TypeLits (ErrorMessage (..), TypeError) + -- Derived instances -- This instance ensures that we can apply typeable type constructors to typeable arguments and get a typeable @@ -61,6 +64,14 @@ liftBuiltin => a -> RTCompile uni fun (Term TyName Name uni fun ()) liftBuiltin = pure . mkConstant () +instance (TypeError ('Text "Int is not supported, use Integer instead")) + => Typeable uni Int where + typeRep = Prelude.error "unsupported" + +instance (TypeError ('Text "Int is not supported, use Integer instead")) + => Lift uni Int where + lift = Prelude.error "unsupported" + instance uni `PLC.Includes` Integer => Typeable uni Integer where typeRep = typeRepBuiltin