@@ -150,7 +150,7 @@ toTuple _ = internalError "Not a value declaration"
150150makeCaseDeclaration :: forall m. (Functor m, Applicative m, MonadSupply m, MonadError MultipleErrors m) => Ident -> [([Binder], Either [(Guard, Expr)] Expr)] -> m Declaration
151151makeCaseDeclaration ident alternatives = do
152152 let namedArgs = map findName . fst <$> alternatives
153− argNames = map join $ foldl1 resolveNames namedArgs
153+ argNames = foldl1 resolveNames namedArgs
154154 args <- if allUnique (catMaybes argNames)
155155 then mapM argName argNames
156156 else replicateM (length argNames) freshIdent'
@@ -160,14 +160,11 @@ makeCaseDeclaration ident alternatives = do
160160 return $ ValueDeclaration ident Public [] (Right value)
161161 where
162162 -- We will construct a table of potential names.
163− -- VarBinders will become Just (Just _) which is a potential name.
164− -- NullBinder will become Just Nothing, which indicates that we may
163+ -- VarBinders will become Just _ which is a potential name.
164+ -- Everything else becomes Nothing, which indicates that we
165165 -- have to generate a name.
166− -- Everything else becomes Nothing, which indicates that we definitely
167− -- have to generate a name.
168− findName :: Binder -> Maybe (Maybe Ident)
169− findName NullBinder = Just Nothing
170− findName (VarBinder name) = Just (Just name)
166+ findName :: Binder -> Maybe Ident
167+ findName (VarBinder name) = Just name
171168 findName (PositionedBinder _ _ binder) = findName binder
172169 findName _ = Nothing
173170
@@ -182,19 +179,13 @@ makeCaseDeclaration ident alternatives = do
182179
183180 -- Combine two lists of potential names from two case alternatives
184181 -- by zipping correspoding columns.
185− resolveNames :: [Maybe (Maybe Ident)] ->
186− [Maybe (Maybe Ident)] ->
187− [Maybe (Maybe Ident)]
182+ resolveNames :: [Maybe Ident] -> [Maybe Ident] -> [Maybe Ident]
188183 resolveNames = zipWith resolveName
189184
190185 -- Resolve a pair of names. VarBinder beats NullBinder, and everything
191186 -- else results in Nothing.
192− resolveName :: Maybe (Maybe Ident) ->
193− Maybe (Maybe Ident) ->
194− Maybe (Maybe Ident)
195− resolveName (Just (Just a)) (Just (Just b))
196− | a == b = Just (Just a)
187+ resolveName :: Maybe Ident -> Maybe Ident -> Maybe Ident
188+ resolveName (Just a) (Just b)
189+ | a == b = Just a
197190 | otherwise = Nothing
198− resolveName (Just Nothing) a = a
199− resolveName a (Just Nothing) = a
200191 resolveName _ _ = Nothing