Skip to content

Commit 67f122d

Browse files
committed
[Evaluation] [Performance] Use the strict 'List' for 'Constr'
1 parent a9a6789 commit 67f122d

File tree

18 files changed

+56
-33
lines changed

18 files changed

+56
-33
lines changed

plutus-core/plutus-core.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ library
332332
, semigroups >=0.19.1
333333
, serialise
334334
, some
335+
, strict-base
335336
, template-haskell
336337
, text
337338
, th-compat

plutus-core/plutus-core/src/PlutusCore/Compiler/Erase.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module PlutusCore.Compiler.Erase (eraseTerm, eraseProgram) where
22

33
import Data.Vector (fromList)
4+
import GHC.IsList qualified as GHC
45
import PlutusCore.Core
56
import PlutusCore.Name.Unique
67
import UntypedPlutusCore.Core qualified as UPLC
@@ -24,8 +25,8 @@ eraseTerm (TyInst ann term _) = UPLC.Force ann (eraseTerm term)
2425
eraseTerm (Unwrap _ term) = eraseTerm term
2526
eraseTerm (IWrap _ _ _ term) = eraseTerm term
2627
eraseTerm (Error ann _) = UPLC.Error ann
27-
eraseTerm (Constr ann _ i args) = UPLC.Constr ann i (fmap eraseTerm args)
28-
eraseTerm (Case ann _ arg cs) = UPLC.Case ann (eraseTerm arg) (fromList $ fmap eraseTerm cs)
28+
eraseTerm (Constr ann _ i args) = UPLC.Constr ann i (GHC.fromList $ map eraseTerm args)
29+
eraseTerm (Case ann _ arg cs) = UPLC.Case ann (eraseTerm arg) (fromList $ map eraseTerm cs)
2930

3031
eraseProgram :: HasUnique name TermUnique
3132
=> Program tyname name uni fun ann

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Instance/Eq.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ eqTermM (Error ann1) (Error ann2) = eqM ann1 ann2
9999
eqTermM (Constr ann1 i1 args1) (Constr ann2 i2 args2) = do
100100
eqM ann1 ann2
101101
eqM i1 i2
102-
case zipExact args1 args2 of
102+
case zipExact (toList args1) (toList args2) of
103103
Just ps -> for_ ps $ \(t1, t2) -> eqTermM t1 t2
104104
Nothing -> empty
105105
eqTermM (Case ann1 a1 cs1) (Case ann2 a2 cs2) = do

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Instance/Flat.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Flat
2424
import Flat.Decoder
2525
import Flat.Encoder
2626
import Flat.Encoder.Strict (sizeListWith)
27+
import GHC.IsList qualified as GHC
2728
import Universe
2829

2930
{-
@@ -122,7 +123,7 @@ encodeTerm = \case
122123
Force ann t -> encodeTermTag 5 <> encode ann <> encodeTerm t
123124
Error ann -> encodeTermTag 6 <> encode ann
124125
Builtin ann bn -> encodeTermTag 7 <> encode ann <> encode bn
125-
Constr ann i es -> encodeTermTag 8 <> encode ann <> encode i <> encodeListWith encodeTerm es
126+
Constr ann i es -> encodeTermTag 8 <> encode ann <> encode i <> encodeListWith encodeTerm (GHC.toList es)
126127
Case ann arg cs -> encodeTermTag 9 <> encode ann <> encodeTerm arg <> encodeListWith encodeTerm (V.toList cs)
127128

128129
decodeTerm
@@ -157,7 +158,7 @@ decodeTerm version builtinPred = go
157158
Just e -> fail e
158159
handleTerm 8 = do
159160
unless (version >= PLC.plcVersion110) $ fail $ "'constr' is not allowed before version 1.1.0, this program has version: " ++ (show $ pretty version)
160-
Constr <$> decode <*> decode <*> decodeListWith go
161+
Constr <$> decode <*> decode <*> (GHC.fromList <$> decodeListWith go)
161162
handleTerm 9 = do
162163
unless (version >= PLC.plcVersion110) $ fail $ "'case' is not allowed before version 1.1.0, this program has version: " ++ (show $ pretty version)
163164
Case <$> decode <*> go <*> (V.fromList <$> decodeListWith go)

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Instance/Pretty/Classic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ instance (PrettyClassicBy configName name, PrettyUni uni, Pretty fun, Pretty ann
4646
sexp "force" (consAnnIf config ann
4747
[prettyBy config term])
4848
Constr ann i es ->
49-
sexp "constr" (consAnnIf config ann (pretty i : fmap (prettyBy config) es))
49+
sexp "constr" (consAnnIf config ann (pretty i : fmap (prettyBy config) (toList es)))
5050
Case ann arg cs ->
5151
sexp "case" (consAnnIf config ann
5252
(prettyBy config arg : fmap (prettyBy config) (toList cs)))

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Instance/Pretty/Readable.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ instance
5151
-- Always rendering the tag on the same line for more compact output, it's just a tiny integer
5252
-- anyway.
5353
Constr _ i es -> iterAppDocM $ \_ prettyArg ->
54-
("constr" <+> prettyArg i) :| [prettyArg es]
54+
("constr" <+> prettyArg i) :| [prettyArg (toList es)]
5555
Case _ arg cs -> iterAppDocM $ \_ prettyArg -> "case" :| [prettyArg arg, prettyArg (toList cs)]
5656

5757
instance

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Type.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ module UntypedPlutusCore.Core.Type
2828
import Control.Lens
2929
import PlutusPrelude
3030

31+
import Data.Hashable
32+
import Data.Strict.List
3133
import Data.Vector
3234
import Data.Word
35+
import GHC.IsList qualified as GHC
3336
import PlutusCore.Builtin qualified as TPLC
3437
import PlutusCore.Core qualified as TPLC
3538
import PlutusCore.MkPlc
@@ -85,10 +88,13 @@ data Term name uni fun ann
8588
-- TODO: worry about overflow, maybe use an Integer
8689
-- TODO: try spine-strict list or strict list or vector
8790
-- See Note [Constr tag type]
88-
| Constr !ann !Word64 ![Term name uni fun ann]
91+
| Constr !ann !Word64 !(List (Term name uni fun ann))
8992
| Case !ann !(Term name uni fun ann) !(Vector (Term name uni fun ann))
9093
deriving stock (Functor, Generic)
9194

95+
deriving anyclass instance NFData a => NFData (List a)
96+
deriving anyclass instance Hashable a => Hashable (List a)
97+
9298
deriving stock instance (Show name, GShow uni, Everywhere uni Show, Show fun, Show ann, Closed uni)
9399
=> Show (Term name uni fun ann)
94100

@@ -123,7 +129,7 @@ instance TermLike (Term name uni fun) TPLC.TyName name uni fun where
123129
unwrap = const id
124130
iWrap = \_ _ _ -> id
125131
error = \ann _ -> Error ann
126-
constr = \ann _ i es -> Constr ann i es
132+
constr = \ann _ i es -> Constr ann i $ GHC.fromList es
127133
kase = \ann _ arg cs -> Case ann arg (fromList cs)
128134

129135
instance TPLC.HasConstant (Term name uni fun ()) where

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Zip.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module UntypedPlutusCore.Core.Zip
1111
import Control.Monad (void, when)
1212
import Control.Monad.Except (MonadError, throwError)
1313
import Data.Vector
14+
import GHC.IsList qualified as GHC
1415
import UntypedPlutusCore.Core.Instance.Eq ()
1516
import UntypedPlutusCore.Core.Type
1617

@@ -60,7 +61,8 @@ tzipWith f term1 term2 = do
6061
go (Apply a1 t1a t1b) (Apply a2 t2a t2b) = Apply (f a1 a2) <$> go t1a t2a <*> go t1b t2b
6162
go (Force a1 t1) (Force a2 t2) = Force (f a1 a2) <$> go t1 t2
6263
go (Delay a1 t1) (Delay a2 t2) = Delay (f a1 a2) <$> go t1 t2
63-
go (Constr a1 i1 ts1) (Constr a2 _i2 ts2) = Constr (f a1 a2) i1 <$> zipExactWithM go ts1 ts2
64+
go (Constr a1 i1 ts1) (Constr a2 _i2 ts2) =
65+
Constr (f a1 a2) i1 <$> (GHC.fromList <$> zipExactWithM go (GHC.toList ts1) (GHC.toList ts2))
6466
go (Case a1 t1 vs1) (Case a2 t2 vs2) =
6567
Case (f a1 a2) <$> go t1 t2 <*> (fromList <$> zipExactWithM go (toList vs1) (toList vs2))
6668
go _ _ =

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Evaluation/Machine/Cek/Internal.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import Data.Hashable (Hashable)
9898
import Data.Kind qualified as GHC
9999
import Data.Proxy
100100
import Data.Semigroup (stimes)
101+
import Data.Strict.List (List (..))
101102
import Data.Text (Text)
102103
import Data.Vector qualified as V
103104
import Data.Word
@@ -565,9 +566,9 @@ dischargeCekValue = \case
565566
VBuiltin _ term _ -> term
566567
VConstr i es -> Constr () i (fmap dischargeCekValue $ stack2list es)
567568
where
568-
stack2list = go []
569+
stack2list = go Nil
569570
go acc EmptyStack = acc
570-
go acc (ConsStack arg rest) = go (arg : acc) rest
571+
go acc (ConsStack arg rest) = go (arg :! acc) rest
571572

572573
instance (PrettyUni uni, Pretty fun) => PrettyBy PrettyConfigPlc (CekValue uni fun ann) where
573574
prettyBy cfg = prettyBy cfg . dischargeCekValue
@@ -598,7 +599,7 @@ data Context uni fun ann
598599
| FrameForce !(Context uni fun ann)
599600
-- ^ @(force _)@
600601
-- See Note [Accumulators for terms]
601-
| FrameConstr !(CekValEnv uni fun ann) {-# UNPACK #-} !Word64 ![NTerm uni fun ann] !(ArgStack uni fun ann) !(Context uni fun ann)
602+
| FrameConstr !(CekValEnv uni fun ann) {-# UNPACK #-} !Word64 !(List (NTerm uni fun ann)) !(ArgStack uni fun ann) !(Context uni fun ann)
602603
-- ^ @(constr i V0 ... Vj-1 _ Nj ... Nn)@
603604
| FrameCases !(CekValEnv uni fun ann) !(V.Vector (NTerm uni fun ann)) !(Context uni fun ann)
604605
-- ^ @(case _ C0 .. Cn)@
@@ -727,8 +728,8 @@ enterComputeCek = computeCek
727728
computeCek !ctx !env (Constr _ i es) = do
728729
stepAndMaybeSpend BConstr
729730
case es of
730-
(t : rest) -> computeCek (FrameConstr env i rest EmptyStack ctx) env t
731-
[] -> returnCek ctx $ VConstr i EmptyStack
731+
(t :! rest) -> computeCek (FrameConstr env i rest EmptyStack ctx) env t
732+
Nil -> returnCek ctx $ VConstr i EmptyStack
732733
-- s ; ρ ▻ case S C0 ... Cn ↦ s , case _ (C0 ... Cn, ρ) ; ρ ▻ S
733734
computeCek !ctx !env (Case _ scrut cs) = do
734735
stepAndMaybeSpend BCase
@@ -771,8 +772,8 @@ enterComputeCek = computeCek
771772
returnCek (FrameConstr env i todo done ctx) e = do
772773
let done' = ConsStack e done
773774
case todo of
774-
(next : todo') -> computeCek (FrameConstr env i todo' done' ctx) env next
775-
[] -> returnCek ctx $ VConstr i done'
775+
(next :! todo') -> computeCek (FrameConstr env i todo' done' ctx) env next
776+
Nil -> returnCek ctx $ VConstr i done'
776777
-- s , case _ (C0 ... CN, ρ) ◅ constr i V1 .. Vm ↦ s , [_ V1 ... Vm] ; ρ ▻ Ci
777778
returnCek (FrameCases env cs ctx) e = case e of
778779
-- If the index is larger than the max bound of an Int, or negative, then it's a bad index

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Evaluation/Machine/SteppableCek/Internal.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Control.Monad.Primitive
6060
import Data.Proxy
6161
import Data.RandomAccessList.Class qualified as Env
6262
import Data.Semigroup (stimes)
63+
import Data.Strict.List (List (..))
6364
import Data.Text (Text)
6465
import Data.Vector qualified as V
6566
import Data.Word (Word64)
@@ -99,7 +100,7 @@ data Context uni fun ann
99100
| FrameAwaitFunTerm ann !(CekValEnv uni fun ann) !(NTerm uni fun ann) !(Context uni fun ann) -- ^ @[_ N]@
100101
| FrameAwaitFunValue ann !(CekValue uni fun ann) !(Context uni fun ann)
101102
| FrameForce ann !(Context uni fun ann) -- ^ @(force _)@
102-
| FrameConstr ann !(CekValEnv uni fun ann) {-# UNPACK #-} !Word64 ![NTerm uni fun ann] !(ArgStack uni fun ann) !(Context uni fun ann)
103+
| FrameConstr ann !(CekValEnv uni fun ann) {-# UNPACK #-} !Word64 !(List (NTerm uni fun ann)) !(ArgStack uni fun ann) !(Context uni fun ann)
103104
| FrameCases ann !(CekValEnv uni fun ann) !(V.Vector (NTerm uni fun ann)) !(Context uni fun ann)
104105
| NoFrame
105106

@@ -158,8 +159,8 @@ computeCek !ctx !_ (Builtin _ bn) = do
158159
computeCek !ctx !env (Constr ann i es) = do
159160
stepAndMaybeSpend BConstr
160161
pure $ case es of
161-
(t : rest) -> Computing (FrameConstr ann env i rest EmptyStack ctx) env t
162-
[] -> Returning ctx $ VConstr i EmptyStack
162+
(t :! rest) -> Computing (FrameConstr ann env i rest EmptyStack ctx) env t
163+
Nil -> Returning ctx $ VConstr i EmptyStack
163164
-- s ; ρ ▻ case S C0 ... Cn ↦ s , case _ (C0 ... Cn, ρ) ; ρ ▻ S
164165
computeCek !ctx !env (Case ann scrut cs) = do
165166
stepAndMaybeSpend BCase
@@ -196,8 +197,8 @@ returnCek (FrameAwaitFunValue ann arg ctx) fun =
196197
returnCek (FrameConstr ann env i todo done ctx) e = do
197198
let done' = ConsStack e done
198199
case todo of
199-
(next : todo') -> computeCek (FrameConstr ann env i todo' done' ctx) env next
200-
[] -> returnCek ctx $ VConstr i done'
200+
(next :! todo') -> computeCek (FrameConstr ann env i todo' done' ctx) env next
201+
Nil -> returnCek ctx $ VConstr i done'
201202
-- s , case _ (C0 ... CN, ρ) ◅ constr i V1 .. Vm ↦ s , [_ V1 ... Vm] ; ρ ▻ Ci
202203
returnCek (FrameCases ann env cs ctx) e = case e of
203204
-- If the index is larger than the max bound of an Int, or negative, then it's a bad index

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Parser.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import UntypedPlutusCore.Rename (Rename (rename))
2929

3030
import Data.Text (Text)
3131
import Data.Vector qualified as V
32+
import GHC.IsList qualified as GHC
3233
import PlutusCore.Error (AsParserErrorBundle)
3334
import PlutusCore.MkPlc (mkIterApp)
3435
import PlutusCore.Parser hiding (parseProgram, parseTerm, program)
@@ -75,7 +76,9 @@ errorTerm = withSpan $ \sp ->
7576
constrTerm :: Parser PTerm
7677
constrTerm = withSpan $ \sp ->
7778
inParens $ do
78-
res <- UPLC.Constr sp <$> (symbol "constr" *> lexeme Lex.decimal) <*> many term
79+
res <- UPLC.Constr sp
80+
<$> (symbol "constr" *> lexeme Lex.decimal)
81+
<*> (GHC.fromList <$> many term)
7982
whenVersion (\v -> v < plcVersion110) $ fail "'constr' is not allowed before version 1.1.0"
8083
pure res
8184

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Transform/CaseReduce.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import UntypedPlutusCore.Transform.Simplifier (SimplifierStage (CaseReduce), Sim
1111

1212
import Control.Lens (transformOf)
1313
import Data.Vector qualified as V
14+
import GHC.IsList qualified as GHC
1415

1516
caseReduce
1617
:: Monad m
@@ -24,5 +25,5 @@ caseReduce term = do
2425
processTerm :: Term name uni fun a -> Term name uni fun a
2526
processTerm = \case
2627
Case ann (Constr _ i args) cs | Just c <- (V.!?) cs (fromIntegral i) ->
27-
mkIterApp c ((ann,) <$> args)
28+
mkIterApp c ((ann,) <$> GHC.toList args)
2829
t -> t

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Transform/Inline.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ costIsAcceptable = \case
410410
Apply{} -> False
411411
-- Inlining constructors of size 1 or 0 seems okay, but does result in doing
412412
-- the work for the elements at each use site.
413-
Constr _ _ es -> case es of
413+
Constr _ _ es -> case toList es of
414414
[] -> True
415415
[e] -> costIsAcceptable e
416416
_ -> False
@@ -434,7 +434,7 @@ sizeIsAcceptable inlineConstants = \case
434434
-- See Note [Differences from PIR inliner] 4
435435
LamAbs{} -> False
436436
-- Inlining constructors of size 1 or 0 seems okay
437-
Constr _ _ es -> case es of
437+
Constr _ _ es -> case toList es of
438438
[] -> True
439439
[e] -> sizeIsAcceptable inlineConstants e
440440
_ -> False

plutus-core/untyped-plutus-core/test/Analysis/Spec.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{-# LANGUAGE OverloadedLists #-}
12
{-# LANGUAGE OverloadedStrings #-}
3+
{-# LANGUAGE TypeApplications #-}
24

35
module Analysis.Spec where
46

@@ -20,15 +22,15 @@ goldenEvalOrder name tm =
2022

2123
-- Should hit Unknown before trying to process the undefined. Shows
2224
-- that the computation is lazy
23-
-- [ [ n m ] (constr 1 [undefined]) ]
25+
-- [ [ n m ] [undefined] ]
2426
dangerTerm :: Term Name PLC.DefaultUni PLC.DefaultFun ()
2527
dangerTerm = runQuote $ do
2628
n <- freshName "n"
2729
m <- freshName "m"
2830
-- The UPLC term type is strict, so it's hard to hide an undefined in there
29-
-- Take advantage of the fact that it's still using lazy lists for constr
31+
-- Take advantage of the fact that it's still using lazy lists as constant
3032
-- arguments for now.
31-
pure $ Apply () (Apply () (Var () n) (Var () m)) (Constr () 1 [undefined])
33+
pure $ Apply () (Apply () (Var () n) (Var () m)) (mkConstant @[Integer] () [undefined])
3234

3335
letFun :: Term Name PLC.DefaultUni PLC.DefaultFun ()
3436
letFun = runQuote $ do

plutus-core/untyped-plutus-core/test/Generators.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Control.Lens (view)
2929
import Data.Text (Text)
3030
import Data.Text qualified as T
3131
import Data.Vector qualified as V
32+
import GHC.IsList qualified as GHC
3233

3334
import Hedgehog (annotate, annotateShow, failure, property, tripping, (===))
3435
import Hedgehog.Gen qualified as Gen
@@ -60,7 +61,7 @@ compareTerm (Force _ t ) (Force _ t') = compareTerm t t'
6061
compareTerm (Delay _ t ) (Delay _ t') = compareTerm t t'
6162
compareTerm (Constant _ x) (Constant _ y) = x == y
6263
compareTerm (Builtin _ bi) (Builtin _ bi') = bi == bi'
63-
compareTerm (Constr _ i es) (Constr _ i' es') = i == i' && maybe False (all (uncurry compareTerm)) (zipExact es es')
64+
compareTerm (Constr _ i es) (Constr _ i' es') = i == i' && maybe False (all (uncurry compareTerm)) (zipExact (GHC.toList es) (GHC.toList es'))
6465
compareTerm (Case _ arg cs) (Case _ arg' cs') = compareTerm arg arg' && maybe False (all (uncurry compareTerm)) (zipExact (V.toList cs) (V.toList cs'))
6566
compareTerm (Error _ ) (Error _ ) = True
6667
compareTerm _ _ = False

plutus-core/untyped-plutus-core/test/Transform/CaseOfCase/Test.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE BlockArguments #-}
2+
{-# LANGUAGE OverloadedLists #-}
23
{-# LANGUAGE OverloadedStrings #-}
34
{-# LANGUAGE TypeApplications #-}
45

plutus-core/untyped-plutus-core/test/Transform/Simplify.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedLists #-}
12
{-# LANGUAGE OverloadedStrings #-}
23
{-# LANGUAGE TypeApplications #-}
34

@@ -449,7 +450,7 @@ cseExpensive = plus arg arg'
449450
where
450451
plus a b = mkIterApp (Builtin () PLC.AddInteger) [((), a), ((), b)]
451452
con = mkConstant @Integer ()
452-
mkArg = foldl1 plus . fmap (\i -> plus (con (2 * i)) (con (2 * i + 1)))
453+
mkArg = foldl1 plus . map (\i -> plus (con (2 * i)) (con (2 * i + 1)))
453454
arg = mkArg [0 .. 200]
454455
arg' = mkArg [0 .. 200]
455456

plutus-metatheory/src/Untyped.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Data.ByteString as BS hiding (map)
1111
import Data.Text as T hiding (map)
1212
import Data.Word (Word64)
1313
import GHC.Exts (IsList (..))
14+
import GHC.IsList qualified as GHC
1415
import Universe
1516

1617
-- Untyped (Raw) syntax
@@ -42,7 +43,7 @@ conv (Constant _ c) = UCon c
4243
conv (Error _) = UError
4344
conv (Delay _ t) = UDelay (conv t)
4445
conv (Force _ t) = UForce (conv t)
45-
conv (Constr _ i es) = UConstr (toInteger i) (toList (fmap conv es))
46+
conv (Constr _ i es) = UConstr (toInteger i) (map conv $ GHC.toList es)
4647
conv (Case _ arg cs) = UCase (conv arg) (toList (fmap conv cs))
4748

4849
tmnames = ['a' .. 'z']
@@ -63,6 +64,6 @@ uconv i UError = Error ()
6364
uconv i (UBuiltin b) = Builtin () b
6465
uconv i (UDelay t) = Delay () (uconv i t)
6566
uconv i (UForce t) = Force () (uconv i t)
66-
uconv i (UConstr j xs) = Constr () (fromInteger j) (fmap (uconv i) xs)
67+
uconv i (UConstr j xs) = Constr () (fromInteger j) (GHC.fromList $ map (uconv i) xs)
6768
uconv i (UCase t xs) = Case () (uconv i t) (fromList (fmap (uconv i) xs))
6869

0 commit comments

Comments
 (0)