<p>Any type that works with <code>PlutusTx.unstableMakeIsData</code> (or its equivalent) should work, since <code>Datum</code> &amp; <code>Redeemer</code> are wrappers for <code>BuiltInData</code> which is a &quot;wrapper&quot; for <code>Data</code>.</p>
<p>EDIT:</p>
<p>I tried the following example:</p>
<pre><code>data MySampleType = Dummy (Set Bool) deriving (Show)

instance PlutusTx.FromData (Set Bool)
instance PlutusTx.UnsafeFromData (Set Bool)
instance PlutusTx.ToData (Set Bool)
PlutusTx.unstableMakeIsData ''MySampleType 
</code></pre>
<p>but got the following error messages:</p>
<pre><code>GHC Core to PLC plugin: E042:Error: Unsupported feature: Int: use Integer instead
Context: Compiling type: Data.Set.Internal.Size
Context: Compiling data constructor type: Data.Set.Internal.Bin
Context: Compiling type: Data.Set.Internal.Set GHC.Types.Bool
Context: Compiling data constructor type: SampleStateMachine.Dummy
Context: Compiling type: SampleStateMachine.MySampleType
Context: Compiling type: SampleStateMachine.MySampleType
                         -&gt; Plutus.V1.Ledger.Contexts.ScriptContext
                         -&gt; GHC.Types.Bool
Context: Compiling type: Model.Bid.OrderBid
                         -&gt; SampleStateMachine.MySampleType
                         -&gt; Plutus.V1.Ledger.Contexts.ScriptContext
                         -&gt; GHC.Types.Bool
Context: Compiling type: Model.Order.Order
                         -&gt; Model.Bid.OrderBid
                         -&gt; SampleStateMachine.MySampleType
                         -&gt; Plutus.V1.Ledger.Contexts.ScriptContext
                         -&gt; GHC.Types.Bool
Context: Compiling definition of: SampleStateMachine.mkValidator
Context: Compiling expr: SampleStateMachine.mkValidator
Context: Compiling expr at &quot;sample-0.1.0.0-inplace:SampleStateMachine:(206,9)-(206,48)&quot;
</code></pre>
<p>Which, to the best of my understanding, means that it's not a valid On-Chain code.</p>
<p>Fazit: It's currently not possible. But you could create an issue <a href="https://github.com/input-output-hk/plutus/issues" rel="nofollow noreferrer">here</a> and request the feature :)</p>

CC BY-SA 4.0
2021-10-18T12:33:13.100Z
2021-10-18T12:46:03.730Z
2021-10-18T12:46:03.730Z
Aoaddeola
<p>As the title of the question says, is it possible for me to use a <code>Set</code> data structure for the <code>Datum</code> and/or <code>Redeemer</code>?</p>

<plutus><plutustx>
Is it possible to have an On-chain Set data structure?
# Is it possible to have an On-chain Set data structure?

(Asked by: username_0 on 2021-10-18)

As the title of the question says, is it possible for me to use a `Set` data structure for the `Datum` and/or `Redeemer`?

**Tags:** plutus, plutustx

---

## 1 answers

### Answer by username_1 on 2021-10-18. Score: 3 | Accepted answer

Any type that works with PlutusTx.unstableMakeIsData (or its equivalent) should work, since Datum & Redeemer are wrappers for BuiltInData which is a "wrapper" for Data.
EDIT:
I tried the following example:
data MySampleType = Dummy (Set Bool) deriving (Show)

instance PlutusTx.FromData (Set Bool)
instance PlutusTx.UnsafeFromData (Set Bool)
instance PlutusTx.ToData (Set Bool)
PlutusTx.unstableMakeIsData ''MySampleType 

but got the following error messages:
GHC Core to PLC plugin: E042:Error: Unsupported feature: Int: use Integer instead
Context: Compiling type: Data.Set.Internal.Size
Context: Compiling data constructor type: Data.Set.Internal.Bin
Context: Compiling type: Data.Set.Internal.Set GHC.Types.Bool
Context: Compiling data constructor type: SampleStateMachine.Dummy
Context: Compiling type: SampleStateMachine.MySampleType
Context: Compiling type: SampleStateMachine.MySampleType
                         -> Plutus.V1.Ledger.Contexts.ScriptContext
                         -> GHC.Types.Bool
Context: Compiling type: Model.Bid.OrderBid
                         -> SampleStateMachine.MySampleType
                         -> Plutus.V1.Ledger.Contexts.ScriptContext
                         -> GHC.Types.Bool
Context: Compiling type: Model.Order.Order
                         -> Model.Bid.OrderBid
                         -> SampleStateMachine.MySampleType
                         -> Plutus.V1.Ledger.Contexts.ScriptContext
                         -> GHC.Types.Bool
Context: Compiling definition of: SampleStateMachine.mkValidator
Context: Compiling expr: SampleStateMachine.mkValidator
Context: Compiling expr at "sample-0.1.0.0-inplace:SampleStateMachine:(206,9)-(206,48)"

Which, to the best of my understanding, means that it's not a valid On-Chain code.
Fazit: It's currently not possible. But you could create an issue here and request the feature :)


---

