Skip to content
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

Change ReversedTransformer, GCNF2MaxSATInfo, PBAsQUBOInfo, QUBO2IsingInfo, Ising2QUBOInfo from data to newtype #134

Merged
merged 1 commit into from
Dec 14, 2024
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
2 changes: 1 addition & 1 deletion src/ToySolver/Converter/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ instance J.FromJSON (IdentityTransformer a) where
parseJSON = withTypedObject "IdentityTransformer" $ \_ -> pure IdentityTransformer


data ReversedTransformer t = ReversedTransformer t
newtype ReversedTransformer t = ReversedTransformer t
deriving (Eq, Show, Read)

instance Transformer t => Transformer (ReversedTransformer t) where
Expand Down
2 changes: 1 addition & 1 deletion src/ToySolver/Converter/GCNF2MaxSAT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import qualified ToySolver.FileFormat.CNF as CNF
import ToySolver.Internal.JSON
import qualified ToySolver.SAT.Types as SAT

data GCNF2MaxSATInfo = GCNF2MaxSATInfo !Int
newtype GCNF2MaxSATInfo = GCNF2MaxSATInfo Int
deriving (Eq, Show, Read)

instance Transformer GCNF2MaxSATInfo where
Expand Down
6 changes: 3 additions & 3 deletions src/ToySolver/Converter/QUBO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pbAsQUBO formula = do
]
}

data PBAsQUBOInfo a = PBAsQUBOInfo !Integer
newtype PBAsQUBOInfo a = PBAsQUBOInfo Integer
deriving (Eq, Show, Read)

instance Transformer (PBAsQUBOInfo a) where
Expand Down Expand Up @@ -231,7 +231,7 @@ qubo2ising QUBO.Problem{ QUBO.quboNumVars = n, QUBO.quboMatrix = qq } =
, c1+c2
)

data QUBO2IsingInfo a = QUBO2IsingInfo a
newtype QUBO2IsingInfo a = QUBO2IsingInfo a
deriving (Eq, Show, Read)

instance (Eq a, Show a) => Transformer (QUBO2IsingInfo a) where
Expand Down Expand Up @@ -303,7 +303,7 @@ ising2qubo QUBO.IsingModel{ QUBO.isingNumVars = n, QUBO.isingInteraction = jj, Q
sum [jj_ij | row <- IntMap.elems jj, jj_ij <- IntMap.elems row]
- sum (IntMap.elems h)

data Ising2QUBOInfo a = Ising2QUBOInfo a
newtype Ising2QUBOInfo a = Ising2QUBOInfo a
deriving (Eq, Show, Read)

instance (Eq a, Show a) => Transformer (Ising2QUBOInfo a) where
Expand Down
Loading