@@ -26,6 +26,7 @@ import Data.List (nub, intersect)
2626import Data.Maybe (isJust, mapMaybe)
2727import Data.Monoid ((<>))
2828import Control.Applicative ((<$>), (<*>), pure)
29+import Control.Monad ((<=<))
2930
3031import qualified Data.Set as S
3132
@@ -48,18 +49,14 @@ collapseBindingGroupsModule :: [Module] -> [Module]
4849collapseBindingGroupsModule = map $ \(Module name ds exps) -> Module name (collapseBindingGroups ds) exps
4950
5051createBindingGroups :: ModuleName -> [Declaration] -> Either ErrorStack [Declaration]
51−createBindingGroups moduleName decls = do
52− (Let result _) <- createBindingGroupsForValue (Let decls (StringLiteral (error "Placeholder string literal was used in createBindingGroups.")))
53− return result
52+createBindingGroups moduleName = mapM f <=< handleDecls
5453
5554 where
56− createBindingGroupsForValue :: Expr -> Either ErrorStack Expr
57− createBindingGroupsForValue =
58− let (_, f, _) = everywhereOnValuesTopDownM return go return
59− in f
60− where
61− go (Let ds val) = flip Let val <$> handleDecls ds
62− go other = return other
55+ (f, _, _) = everywhereOnValuesTopDownM return handleExprs return
56+
57+ handleExprs :: Expr -> Either ErrorStack Expr
58+ handleExprs (Let ds val) = flip Let val <$> handleDecls ds
59+ handleExprs other = return other
6360
6461 -- |
6562 -- Replace all sets of mutually-recursive declarations with binding groups