1 parent 9d5b6d7 commit 0468c1cCopy full SHA for 0468c1c
1 file changed
plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs
@@ -296,14 +296,11 @@ compileDataConRef dc = do
296
dcs <- getDataCons tc
297
constrs <- getConstructors tc
298
299
- -- TODO: this is inelegant
300
- index <- case elemIndex dc dcs of
301
- Just i -> pure i
+ case lookup dc (zip dcs constrs) of
+ Just constr -> pure constr
302
Nothing ->
303
throwPlain $
304
CompilationError "Data constructor not in the type constructor's list of constructors"
305
-
306
- pure $ constrs !! index
307
where
308
tc = GHC.dataConTyCon dc
309
0 commit comments