<p>There is problem with pattern matching on <code>Integer</code> types according to Input Output Global. The Plutus compiler will currently reject any pattern matching on <code>Integer</code> types.</p>
<p>Therefore the best solution is to adjust the code in the following way:</p>
<pre><code>checkMint :: Integer -&gt; Bool
checkMint i
    | i == 1    = True
    | i == -1   = True
    | otherwise = False
</code></pre>

CC BY-SA 4.0
2022-07-28T13:38:08.447Z
2022-07-28T13:38:08.447Z
Will
<p>I want to do Integer pattern matching <strong>on-chain</strong> but always get an error:</p>
<pre><code>GHC Core to PLC plugin: E042:Error: Unsupported feature: Use of Haskell Integer equality, possibly via the Haskell Eq typeclass Context: Compiling expr...
</code></pre>
<p>It seems to relate to this piece of code:</p>
<pre><code>checkMint :: Integer -&gt; Bool
checkMint (1)  = True
checkMint (-1) = True
checkMint _    = False
</code></pre>
<p>It seems that it uses the Prelude Integer equality operator instead of <code>PlutusTx.Prelude</code>. But how can I change that instead of rewriting the function and make it us <code>PlutusTx.Prelude (==)</code> instead?</p>

CC BY-SA 4.0
2022-07-12T07:20:14.717Z
Have you tried adding the pragma `{-# LANGUAGE NoImplicitPrelude #-}` ? This make sure that the standard prelude is not imported. This prevents the use of the Haskell Eq type class instead of the Plutus one.
Fermat
CC BY-SA 4.0
2022-07-12T11:48:18.687Z
Yes, good point. It was indeed the problem of using the standard haskell == pattern match. I resolved it by slightly rewriting this function bc I still need the Haskell Prelude in my code.
Will
<plutus><minting><on-chain><mint>
How to do on-chain Integer pattern matching?
# How to do on-chain Integer pattern matching?

(Asked by: username_0 on 2022-06-06)

I want to do Integer pattern matching on-chain but always get an error:
GHC Core to PLC plugin: E042:Error: Unsupported feature: Use of Haskell Integer equality, possibly via the Haskell Eq typeclass Context: Compiling expr...

It seems to relate to this piece of code:
checkMint :: Integer -> Bool
checkMint (1)  = True
checkMint (-1) = True
checkMint _    = False

It seems that it uses the Prelude Integer equality operator instead of PlutusTx.Prelude. But how can I change that instead of rewriting the function and make it us PlutusTx.Prelude (==) instead?

**Tags:** plutus, minting, on-chain, mint
> **Comments:**
> **username_1**: Have you tried adding the pragma `{-# LANGUAGE NoImplicitPrelude #-}` ? This make sure that the standard prelude is not imported. This prevents the use of the Haskell Eq type class instead of the Plutus one.  
> **username_0**: Yes, good point. It was indeed the problem of using the standard haskell == pattern match. I resolved it by slightly rewriting this function bc I still need the Haskell Prelude in my code.  

---

## 1 answers

### Answer by username_0 on 2022-07-28. Score: 1 | Accepted answer

There is problem with pattern matching on Integer types according to Input Output Global. The Plutus compiler will currently reject any pattern matching on Integer types.
Therefore the best solution is to adjust the code in the following way:
checkMint :: Integer -> Bool
checkMint i
    | i == 1    = True
    | i == -1   = True
    | otherwise = False


---

