@@ -56,12 +56,14 @@ instance Scrapeable a => Scrapeable [a] where
56
56
obj <- peek addr
57
57
case obj of
58
58
Closure { closureEnv = e
59
- , closureCode = LambdaForm {lamBody = (App (Con TagCons ) xs)}
60
- } -> do
61
- let (h :< (t :< _)) = asSeq $ values (e, ms) $ nativeToValue <$> xs
62
- h' <- scrape ms h :: IO (Maybe a )
63
- t' <- scrape ms t :: IO (Maybe [a ])
64
- return $ (:) <$> h' <*> t'
59
+ , closureCode = LambdaForm {lamBody = expr@ (App (Con TagCons ) xs)}
60
+ } ->
61
+ case asSeq $ values (e, ms) $ nativeToValue <$> xs of
62
+ (h :< (t :< _)) -> do
63
+ h' <- scrape ms h :: IO (Maybe a )
64
+ t' <- scrape ms t :: IO (Maybe [a ])
65
+ return $ (:) <$> h' <*> t'
66
+ _ -> throwIn ms $ IntrinsicExpectedEvaluatedList expr
65
67
Closure {closureCode = LambdaForm {lamBody = (App (Con TagNil ) _)}} ->
66
68
return $ Just []
67
69
Closure {closureCode = lf} ->
@@ -76,14 +78,16 @@ instance (Scrapeable k, Scrapeable v) => Scrapeable (k, v) where
76
78
obj <- peek addr
77
79
case obj of
78
80
Closure { closureEnv = e
79
- , closureCode = LambdaForm {lamBody = (App (Con TagCons ) xs)}
80
- } -> do
81
- let (h :< (t :< _)) = asSeq $ values (e, ms) $ nativeToValue <$> xs
82
- k <- scrape ms h :: IO (Maybe k )
83
- t' <- scrape ms t :: IO (Maybe [v ])
84
- case t' of
85
- (Just (v: _)) -> return $ (,) <$> k <*> Just v
86
- _ -> throwIn ms IntrinsicBadPair
81
+ , closureCode = LambdaForm {lamBody = expr@ (App (Con TagCons ) xs)}
82
+ } ->
83
+ case asSeq $ values (e, ms) $ nativeToValue <$> xs of
84
+ (h :< (t :< _)) -> do
85
+ k <- scrape ms h :: IO (Maybe k )
86
+ t' <- scrape ms t :: IO (Maybe [v ])
87
+ case t' of
88
+ (Just (v: _)) -> return $ (,) <$> k <*> Just v
89
+ _ -> throwIn ms IntrinsicBadPair
90
+ _ -> throwIn ms $ IntrinsicExpectedEvaluatedList expr
87
91
Closure {closureCode = lf} ->
88
92
throwIn ms $ IntrinsicExpectedEvaluatedList (lamBody lf)
89
93
BlackHole -> throwIn ms IntrinsicExpectedListFoundBlackHole
@@ -105,11 +109,13 @@ instance Scrapeable k => Scrapeable (BareCons k) where
105
109
obj <- peek addr
106
110
case obj of
107
111
Closure { closureEnv = e
108
- , closureCode = LambdaForm {lamBody = (App (Con TagCons ) xs)}
109
- } -> do
110
- let (h :< (t :< _)) = asSeq $ values (e, ms) $ nativeToValue <$> xs
111
- k <- scrape ms h
112
- return $ BareCons <$> k <*> pure t
112
+ , closureCode = LambdaForm {lamBody = expr@ (App (Con TagCons ) xs)}
113
+ } ->
114
+ case asSeq $ values (e, ms) $ nativeToValue <$> xs of
115
+ (h :< (t :< _)) -> do
116
+ k <- scrape ms h
117
+ return $ BareCons <$> k <*> pure t
118
+ _ -> throwIn ms $ IntrinsicExpectedEvaluatedList expr
113
119
Closure {closureCode = lf} ->
114
120
throwIn ms $ IntrinsicExpectedEvaluatedList (lamBody lf)
115
121
BlackHole -> throwIn ms IntrinsicExpectedListFoundBlackHole
0 commit comments