+
+type FlattenState = State.State ([App], [CondDef], Int)
+
+-- | Flatten a haskell function
+flattenFunction ::
+ HsFunction -- ^ The function to flatten
+ -> CoreBind -- ^ The function value
+ -> FlatFunction -- ^ The resulting flat function
+
+flattenFunction _ (Rec _) = error "Recursive binders not supported"
+flattenFunction hsfunc bind@(NonRec var expr) =
+ FlatFunction args res apps conds
+ where
+ init_state = ([], [], 0)
+ (fres, end_state) = State.runState (flattenExpr expr) init_state
+ (args, res) = fres
+ (apps, conds, _) = end_state
+
+flattenExpr ::
+ CoreExpr
+ -> FlattenState ([SignalDefMap], SignalUseMap)
+
+flattenExpr _ = do
+ return ([], Tuple [])
+
+
+
+