Skip to content

Fix Strict performance #2447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions kore/src/Kore/Attribute/Pattern/Simplified.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ License : NCSA

-}

{-# LANGUAGE Strict #-}
{-# LANGUAGE NoStrict #-}

module Kore.Attribute.Pattern.Simplified
( Simplified (..)
Expand Down Expand Up @@ -100,7 +100,7 @@ data Condition
= Any
-- ^ The term and all its subterms are simplified the same regardless
-- of the side condition.
| Condition !SideCondition.Representation
| Condition SideCondition.Representation
-- ^ The term is in its current simplified state only when using the
-- given side condition. When the side condition changes, e.g. by
-- adding extra conditions, then we may be able to further simplify the
Expand Down Expand Up @@ -134,8 +134,8 @@ instance Monoid Condition where

data SimplifiedData =
SimplifiedData
{ sType :: !Type
, condition :: !Condition
{ sType :: Type
, condition :: Condition
}
deriving (Eq, Ord, Show)
deriving (GHC.Generic)
Expand All @@ -156,7 +156,7 @@ Most patterns are assumed un-simplified until marked otherwise, so the
simplified status is reset by any substitution under the pattern.
-}
data Simplified
= Simplified !SimplifiedData
= Simplified SimplifiedData
| NotSimplified
deriving (Eq, Ord, Show)
deriving (GHC.Generic)
Expand Down
20 changes: 18 additions & 2 deletions kore/src/Kore/Internal/Predicate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,24 @@ mapVariables
=> AdjSomeVariableName (variable1 -> variable2)
-> Predicate variable1
-> Predicate variable2
mapVariables adj =
either undefined id . makePredicate . TermLike.mapVariables adj . fromPredicate_
mapVariables adj predicate =
let termPredicate =
TermLike.mapVariables adj
. fromPredicate_
$ predicate
in
either
errorMappingVariables
id
(makePredicate termPredicate)
where
errorMappingVariables termPredicate =
error . show . Pretty.vsep $
[ "Error when mapping the variables of predicate:"
, Pretty.pretty predicate
, "The resulting term is not a predicate:"
, Pretty.pretty termPredicate
]

-- |Is the predicate free of the given variables?
isFreeOf
Expand Down
6 changes: 5 additions & 1 deletion kore/src/Kore/Internal/SideCondition/SideCondition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Copyright : (c) Runtime Verification, 2020
License : NCSA
-}

{-# LANGUAGE NoStrict #-}

module Kore.Internal.SideCondition.SideCondition
( Representation
, mkRepresentation
Expand Down Expand Up @@ -34,7 +36,9 @@ import Type.Reflection
)

data Representation where
Representation :: (Ord a, Pretty a) => !(TypeRep a) -> !(Hashed a) -> Representation
Representation
:: (Ord a, Pretty a)
=> !(TypeRep a) -> Hashed a -> Representation

instance Eq Representation where
(==) (Representation typeRep1 hashed1) (Representation typeRep2 hashed2) =
Expand Down
4 changes: 2 additions & 2 deletions kore/src/Kore/Internal/TermLike/TermLike.hs
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,8 @@ traverseVariables adj termLike =
(RenamingT variable1 variable2 m (TermLike variable2))
-> RenamingT variable1 variable2 m (TermLike variable2)
worker (attrs :< termLikeF) = do
attrs' <- Attribute.traverseVariables askSomeVariableName attrs
let avoiding = freeVariables attrs'
~attrs' <- Attribute.traverseVariables askSomeVariableName attrs
let ~avoiding = freeVariables attrs'
termLikeF' <- case termLikeF of
VariableF (Const unifiedVariable) -> do
unifiedVariable' <- askSomeVariable unifiedVariable
Expand Down