{- CAO Compiler Copyright (C) 2014 Cryptography and Information Security Group, HASLab - INESC TEC and Universidade do Minho This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -} {- | Module : $Header$ Description : Integer operations semantics. Copyright : (C) 2014 Cryptography and Information Security Group, HASLab - INESC TEC and Universidade do Minho License : GPL Maintainer : Paulo Silva Stability : experimental Portability : non-portable Integer operations semantics. -} module Language.CAO.Semantics.Integer ( integerPlus , integerMinus , integerTimes , integerPower , integerDiv , integerMod , integerEqual , integerNotEqual , integerLessThan , integerEqualsLessThan , integerGreaterThan , integerEqualsGreaterThan , integerSymmetric , integerToBits ) where integerPlus, integerMinus, integerTimes, integerPower, integerDiv, integerMod :: Integer -> Integer -> Integer integerPlus = (+) integerMinus = (-) integerTimes = (*) integerPower = (^) integerDiv = div integerMod = mod integerEqual,integerNotEqual :: Integer -> Integer -> Bool integerEqual = (==) integerNotEqual = (/=) integerLessThan, integerEqualsLessThan, integerGreaterThan, integerEqualsGreaterThan :: Integer -> Integer -> Bool integerLessThan = (<) integerEqualsLessThan = (<=) integerGreaterThan = (>) integerEqualsGreaterThan = (>=) integerSymmetric :: Integer -> Integer integerSymmetric = negate integerToBits :: Integer -> [Bool] integerToBits 0 = repeat False integerToBits i | i < 0 = map not $ integerToBits (-i - 1) | otherwise = (i `mod` 2 /= 0) : integerToBits (i `div` 2)