Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
deemp committed Feb 14, 2024
1 parent c9e9775 commit 1fa2d31
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
98 changes: 49 additions & 49 deletions eo-phi-normalizer/src/Language/EO/Phi/Metrics/Collect.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,68 +16,68 @@ import Language.EO.Phi.Rules.Common ()
import Language.EO.Phi.Syntax.Abs

data Metrics = Metrics
{ dataless :: Int
, applications :: Int
, formations :: Int
, dispatches :: Int
}
deriving (Generic, Show, FromJSON, Eq)
{ dataless :: Int
, applications :: Int
, formations :: Int
, dispatches :: Int
}
deriving (Generic, Show, FromJSON, Eq)

defaultMetrics :: Metrics
defaultMetrics =
Metrics
{ dataless = 0
, applications = 0
, formations = 0
, dispatches = 0
}
Metrics
{ dataless = 0
, applications = 0
, formations = 0
, dispatches = 0
}

collectMetrics :: (Inspectable a) => a -> Metrics
collectMetrics a = execState (inspect a) defaultMetrics

class Inspectable a where
inspect :: a -> State Metrics ()
inspect :: a -> State Metrics ()

instance Inspectable Program where
inspect (Program binding) = forM_ binding inspect
inspect (Program binding) = forM_ binding inspect

instance Inspectable Binding where
inspect = \case
AlphaBinding attr obj -> do
inspect attr
inspect obj
EmptyBinding attr -> do
#dataless += 1
inspect attr
DeltaBinding _ -> pure ()
LambdaBinding _ -> #dataless += 1
MetaBindings _ -> pure ()
inspect = \case
AlphaBinding attr obj -> do
inspect attr
inspect obj
EmptyBinding attr -> do
#dataless += 1
inspect attr
DeltaBinding _ -> pure ()
LambdaBinding _ -> #dataless += 1
MetaBindings _ -> pure ()

instance Inspectable Attribute where
inspect = \case
Phi -> pure ()
Rho -> pure ()
Sigma -> pure ()
VTX -> pure ()
Label _ -> pure ()
Alpha _ -> pure ()
MetaAttr _ -> pure ()
inspect = \case
Phi -> pure ()
Rho -> pure ()
Sigma -> pure ()
VTX -> pure ()
Label _ -> pure ()
Alpha _ -> pure ()
MetaAttr _ -> pure ()

instance Inspectable Object where
inspect = \case
Formation bindings -> do
#formations += 1
forM_ bindings inspect
Application obj bindings -> do
#applications += 1
inspect obj
forM_ bindings inspect
ObjectDispatch obj attr -> do
#dispatches += 1
inspect obj
inspect attr
GlobalObject -> pure ()
ThisObject -> pure ()
Termination -> pure ()
MetaObject _ -> pure ()
MetaFunction _ _ -> pure ()
inspect = \case
Formation bindings -> do
#formations += 1
forM_ bindings inspect
Application obj bindings -> do
#applications += 1
inspect obj
forM_ bindings inspect
ObjectDispatch obj attr -> do
#dispatches += 1
inspect obj
inspect attr
GlobalObject -> pure ()
ThisObject -> pure ()
Termination -> pure ()
MetaObject _ -> pure ()
MetaFunction _ _ -> pure ()
18 changes: 9 additions & 9 deletions eo-phi-normalizer/test/Test/Metrics/Phi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import GHC.Generics (Generic)
import Language.EO.Phi.Metrics.Collect (Metrics)

data MetricsTestSet = MetricsTestSet
{ title :: String
, tests :: [MetricsTest]
}
deriving (Generic, FromJSON)
{ title :: String
, tests :: [MetricsTest]
}
deriving (Generic, FromJSON)

data MetricsTest = MetricsTest
{ title :: String
, phi :: String
, metrics :: Metrics
}
deriving (Generic, FromJSON)
{ title :: String
, phi :: String
, metrics :: Metrics
}
deriving (Generic, FromJSON)

0 comments on commit 1fa2d31

Please sign in to comment.