Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💥 Changed BVSignConversion to SignConversion, add instances to it.
- Loading branch information
Showing
17 changed files
with
245 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{-# LANGUAGE FunctionalDependencies #-} | ||
|
||
module Grisette.Core.Data.Class.SignConversion | ||
( SignConversion (..), | ||
) | ||
where | ||
|
||
import Data.Int (Int16, Int32, Int64, Int8) | ||
import Data.Word (Word16, Word32, Word64, Word8) | ||
|
||
-- | Convert values between signed and unsigned. | ||
class SignConversion ubv sbv | ubv -> sbv, sbv -> ubv where | ||
-- | Convert unsigned value to the corresponding signed value. | ||
toSigned :: ubv -> sbv | ||
|
||
-- | Convert signed value to the corresponding unsigned value. | ||
toUnsigned :: sbv -> ubv | ||
|
||
instance SignConversion Word8 Int8 where | ||
toSigned = fromIntegral | ||
toUnsigned = fromIntegral | ||
|
||
instance SignConversion Word16 Int16 where | ||
toSigned = fromIntegral | ||
toUnsigned = fromIntegral | ||
|
||
instance SignConversion Word32 Int32 where | ||
toSigned = fromIntegral | ||
toUnsigned = fromIntegral | ||
|
||
instance SignConversion Word64 Int64 where | ||
toSigned = fromIntegral | ||
toUnsigned = fromIntegral | ||
|
||
instance SignConversion Word Int where | ||
toSigned = fromIntegral | ||
toUnsigned = fromIntegral | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.