--- | Translates signal id's to SignalInfo for any signals used as state.
-findState ::
- [(UnnamedSignal, SignalInfo)] -- | A map of id to info
- -> UnnamedSignal -- | The signal id to look at
- -> HsValueUse -- | How is this signal used?
- -> Maybe (Int, SignalInfo) -- | The state num and SignalInfo, if appropriate
-
-findState sigs id (State num) =
- Just (num, Maybe.fromJust $ lookup id sigs)
-findState _ _ _ = Nothing
-
-
+-- | Filters non-state signals and returns the state number and signal id for
+-- state values.
+filterState ::
+ SignalId -- | The signal id to look at
+ -> HsValueUse -- | How is this signal used?
+ -> Maybe (StateId, SignalId ) -- | The state num and signal id, if this
+ -- signal was used as state
+
+filterState id (State num) =
+ Just (num, id)
+filterState _ _ = Nothing
+
+-- | Returns a list of the state number and signal id of all used-as-state
+-- signals in the given maps.
+stateList ::
+ HsUseMap
+ -> (SignalMap)
+ -> [(StateId, SignalId)]
+
+stateList uses signals =
+ Maybe.catMaybes $ Foldable.toList $ zipValueMapsWith filterState signals uses
+