Skip to content

Commit

Permalink
generated names now are hashed
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjoosten committed May 1, 2023
1 parent ae78b67 commit cce152a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Ampersand/ADL1/P2A_Converters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ pCtx2aCtx
bindedRel = EDcD rel
mkRule command fExpr =
Rule
{ rrnm = mkName RelationName (toNamePartUnsafe ("Compute" <> tshow (hash lbl')) NE.:| []),
{ rrnm = mkName RuleName (toNamePartUnsafe ("Compute" <> (tshow . abs . hash $ lbl')) NE.:| []),
rrlbl = Just (Label lbl'),
formalExpression = fExpr,
rrfps = pos',
Expand Down
6 changes: 3 additions & 3 deletions src/Ampersand/ADL1/Rule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ where

import Ampersand.Basics
import Ampersand.Core.AbstractSyntaxTree
import Data.Hashable
import qualified RIO.NonEmpty as NE

hasantecedent :: Rule -> Bool
Expand Down Expand Up @@ -45,9 +46,8 @@ rulefromProp prp rel =
{ rrnm =
withNameSpace
(nameSpaceOf rel)
. mkName
RuleName
$ (toNamePartUnsafe (tshow prp <> "_" <> tshow rel) NE.:| []),
. mkName RuleName
$ (toNamePartUnsafe (tshow prp <> "_" <> (tshow . abs . hash . tshow $ rel)) NE.:| []),
rrlbl = Just . Label $ tshow prp <> " rule for relation " <> tshow rel,
formalExpression = rExpr,
rrfps = PropertyRule relIdentifier (origin rel),
Expand Down
6 changes: 3 additions & 3 deletions src/Ampersand/Classes/ViewPoint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Ampersand.Classes.ViewPoint (Language (..), ruleFromIdentity) where
import Ampersand.ADL1
import Ampersand.Basics hiding (Identity, Ord (..))
import Ampersand.Classes.Relational (HasProps (properties))
import Data.Hashable
import qualified RIO.List as L
import qualified RIO.NonEmpty as NE
import qualified RIO.Set as Set
Expand Down Expand Up @@ -77,9 +78,8 @@ ruleFromIdentity identity =
{ rrnm =
withNameSpace
(nameSpaceOf identity)
. mkName
RuleName
$ (toNamePartUnsafe ("identity_" <> tshow identity) NE.:| []),
. mkName RuleName
$ (toNamePartUnsafe ("identity_" <> (tshow . abs . hash . tshow $ identity)) NE.:| []),
rrlbl = Just . Label $ "Identity rule for " <> tshow identity,
formalExpression = term,
rrfps = origin identity, -- position in source file
Expand Down
2 changes: 1 addition & 1 deletion src/Ampersand/Core/A2P_Converters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ aRule2pRule :: Rule -> P_Rule TermPrim
aRule2pRule rul =
P_Rule
{ pos = rrfps rul,
rr_nm = rrnm rul,
rr_nm = name rul,
rr_lbl = rrlbl rul,
rr_exp = aExpression2pTermPrim (formalExpression rul),
rr_mean = map aMeaning2pMeaning (rrmean rul),
Expand Down
2 changes: 1 addition & 1 deletion src/Ampersand/Core/AbstractSyntaxTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ instance Unique Rule where
showUnique = tName

instance Ord Rule where
compare = compare `on` rrnm -- Origin should not be here: A check that they all have unique names is done before typechecking.
compare = compare `on` name -- Origin should not be here: A check that they all have unique names is done before typechecking.

instance Show Rule where
show x =
Expand Down
2 changes: 1 addition & 1 deletion src/Ampersand/FSpec/ShowHS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ instance ShowHS Rule where
showHS env indent r =
T.intercalate
indent
[ "Ru{ rrnm = " <> tshow (rrnm r),
[ "Ru{ rrnm = " <> tshow (name r),
" , formalExpression = -- " <> showA (formalExpression r) <> indent <> " " <> showHS env (indent <> " ") (formalExpression r),
" , rrfps = " <> showHS env "" (rrfps r),
" , rrmean = " <> showHS env (indent <> " ") (rrmean r),
Expand Down

0 comments on commit cce152a

Please sign in to comment.