X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=FlattenTypes.hs;h=e7d21d605c5fec8901e9ad104cb4f92f8f3c3849;hb=e73057cb92295256ab62810771da8e723f4a8223;hp=5c95632859d22fc30a8752a28661ad6083eaf224;hpb=72a84356f5507b73d4d5f84844aac9334ee17795;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/FlattenTypes.hs b/FlattenTypes.hs index 5c95632..e7d21d6 100644 --- a/FlattenTypes.hs +++ b/FlattenTypes.hs @@ -1,6 +1,7 @@ module FlattenTypes where import Data.Traversable +import qualified Data.Foldable as Foldable import qualified Control.Monad.State as State import CoreSyn @@ -28,6 +29,11 @@ data HsValueUse = } deriving (Show, Eq, Ord) +-- | Is this HsValueUse a state use? +isStateUse :: HsValueUse -> Bool +isStateUse (State _) = True +isStateUse _ = False + -- | A map from a Haskell value to the use of each single value type HsUseMap = HsValueMap HsValueUse @@ -60,6 +66,11 @@ data HsFunction = HsFunction { hsFuncRes :: HsUseMap } deriving (Show, Eq, Ord) +hasState :: HsFunction -> Bool +hasState hsfunc = + any (Foldable.any isStateUse) (hsFuncArgs hsfunc) + || Foldable.any isStateUse (hsFuncRes hsfunc) + -- | A flattened function application data FApp sigid = FApp { appFunc :: HsFunction,