@@ -48,7 +48,7 @@ simplify tl (DV (Loc i)) = return (SV (Loc i))
4848simplify tl (DV (Glob x))
4949 = do ctxt <- ldefs
5050 case lookupCtxtExact x ctxt of
51− [DConstructor _ t 0] -> return $ SCon t x []
51+ Just (DConstructor _ t 0) -> return $ SCon t x []
5252 _ -> return $ SV (Glob x)
5353simplify tl (DApp tc n args) = do args' <- mapM sVar args
5454 mkapp (SApp (tl || tc) n) args'
@@ -90,7 +90,7 @@ simplify tl (DError str) = return $ SError str
9090sVar (DV (Glob x))
9191 = do ctxt <- ldefs
9292 case lookupCtxtExact x ctxt of
93− [DConstructor _ t 0] -> sVar (DC t x [])
93+ Just (DConstructor _ t 0) -> sVar (DC t x [])
9494 _ -> return (Glob x, Nothing)
9595sVar (DV x) = return (x, Nothing)
9696sVar e = do e' <- simplify False e
@@ -138,23 +138,23 @@ scopecheck ctxt envTop tm = sc envTop tm where
138138 case lookup n (reverse env) of -- most recent first
139139 Just i -> do lvar i; return (SV (Loc i))
140140 Nothing -> case lookupCtxtExact n ctxt of
141− [DConstructor _ i ar] ->
141+ Just (DConstructor _ i ar) ->
142142 if True -- ar == 0
143143 then return (SCon i n [])
144144 else fail $ "Codegen error: Constructor " ++ show n ++
145145 " has arity " ++ show ar
146− [_] -> return (SV (Glob n))
147− [] -> fail $ "Codegen error: No such variable " ++ show n
146+ Just _ -> return (SV (Glob n))
147+ Nothing -> fail $ "Codegen error: No such variable " ++ show n
148148 sc env (SApp tc f args)
149149 = do args' <- mapM (scVar env) args
150150 case lookupCtxtExact f ctxt of
151− [DConstructor n tag ar] ->
151+ Just (DConstructor n tag ar) ->
152152 if True -- (ar == length args)
153153 then return $ SCon tag n args'
154154 else fail $ "Codegen error: Constructor " ++ show f ++
155155 " has arity " ++ show ar
156− [_] -> return $ SApp tc f args'
157− [] -> fail $ "Codegen error: No such variable " ++ show f
156+ Just _ -> return $ SApp tc f args'
157+ Nothing -> fail $ "Codegen error: No such variable " ++ show f
158158 sc env (SForeign l ty f args)
159159 = do args' <- mapM (\ (t, a) -> do a' <- scVar env a
160160 return (t, a')) args
@@ -162,7 +162,7 @@ scopecheck ctxt envTop tm = sc envTop tm where
162162 sc env (SCon tag f args)
163163 = do args' <- mapM (scVar env) args
164164 case lookupCtxtExact f ctxt of
165− [DConstructor n tag ar] ->
165+ Just (DConstructor n tag ar) ->
166166 if True -- (ar == length args)
167167 then return $ SCon tag n args'
168168 else fail $ "Codegen error: Constructor " ++ show f ++
@@ -199,17 +199,17 @@ scopecheck ctxt envTop tm = sc envTop tm where
199199 case lookup n (reverse env) of -- most recent first
200200 Just i -> do lvar i; return (Loc i)
201201 Nothing -> case lookupCtxtExact n ctxt of
202− [DConstructor _ i ar] ->
202+ Just (DConstructor _ i ar) ->
203203 fail $ "Codegen error : can't pass constructor here"
204− [_] -> return (Glob n)
205− [] -> fail $ "Codegen error: No such variable " ++ show n ++
206− " in " ++ show tm ++ " " ++ show envTop
204+ Just _ -> return (Glob n)
205+ Nothing -> fail $ "Codegen error: No such variable " ++ show n ++
206+ " in " ++ show tm ++ " " ++ show envTop
207207 scVar _ x = return x
208208
209209 scalt env (SConCase _ i n args e)
210210 = do let env' = env ++ zip args [length env..]
211211 tag <- case lookupCtxtExact n ctxt of
212− [DConstructor _ i ar] ->
212+ Just (DConstructor _ i ar) ->
213213 if True -- (length args == ar)
214214 then return i
215215 else fail $ "Codegen error: Constructor " ++ show n ++