Changeset 12104 for src/Pugs/Val
- Timestamp:
- 08/11/06 09:11:00 (2 years ago)
- Location:
- src/Pugs/Val
- Files:
-
- 1 added
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Val/Num.hs
r12044 r12104 4 4 import qualified Data.ByteString.Char8 as Char8 5 5 6 instance ((:>:) PureNum) Double where cast = MkNum 7 instance ((:<:) PureNum) Double where castBack (MkNum i) = i 6 instance ((:>:) PureNum) Double where cast = NDouble 7 instance ((:<:) PureNum) Double where 8 castBack (NDouble x) = x 9 castBack (NRational x) = fromRational x 8 10 9 instance ((:>:) PureNum) Int where cast = MkNum . fromIntegral 11 instance ((:>:) PureNum) Rational where cast = NRational 12 instance ((:<:) PureNum) Rational where 13 castBack (NDouble x) = toRational x 14 castBack (NRational x) = x 10 15 11 newtype PureNum = MkNum Double 12 deriving (Typeable, Show, Eq, Ord, Data, (:>:) Double, (:<:) Double) 16 instance ((:>:) PureNum) Int where cast = NRational . fromIntegral 17 18 data PureNum 19 = NDouble !Double -- change to "!NativeDouble" 20 | NRational !Rational 21 deriving (Typeable, Show, Eq, Ord, Data) 13 22 14 23 {- regretfully, I couldn't find a way to put this here w/o circularity.
