Skip to content

Commit 0468c1c

Browse files
authored
Replace inelegant elemIndex+!! with lookup in compileDataConRef (#7732)
1 parent 9d5b6d7 commit 0468c1c

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

  • plutus-tx-plugin/src/PlutusTx/Compiler

plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,11 @@ compileDataConRef dc = do
296296
dcs <- getDataCons tc
297297
constrs <- getConstructors tc
298298

299-
-- TODO: this is inelegant
300-
index <- case elemIndex dc dcs of
301-
Just i -> pure i
299+
case lookup dc (zip dcs constrs) of
300+
Just constr -> pure constr
302301
Nothing ->
303302
throwPlain $
304303
CompilationError "Data constructor not in the type constructor's list of constructors"
305-
306-
pure $ constrs !! index
307304
where
308305
tc = GHC.dataConTyCon dc
309306

0 commit comments

Comments
 (0)