Changeset 12072 for src/Pugs/Val
- Timestamp:
- 08/10/06 14:50:18 (2 years ago)
- Location:
- src/Pugs/Val
- Files:
-
- 1 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Val/Int.hs
r12044 r12072 4 4 import qualified Data.ByteString.Char8 as Char8 5 5 6 instance ((:>:) PureInt) Integer where cast = MkInt 7 instance ((:<:) PureInt) Integer where castBack (MkInt i) = i 6 instance ((:>:) PureInt) Integer where cast = IFinite 7 instance ((:<:) PureInt) Integer where 8 castBack (IFinite i) = i 9 castBack INotANumber = error "NaN" 10 castBack (IInfinite SPositive) = error "+Infinity" 11 castBack (IInfinite SNegative) = error "-Infinity" 8 12 9 instance ((:>:) PureInt) Int where cast = MkInt . toInteger 13 -- ugh, duplicate from above? lose, lose. 14 instance ((:>:) PureInt) Int where cast = IFinite . toInteger 15 instance ((:<:) PureInt) Int where 16 castBack (IFinite i) = fromInteger i 17 castBack INotANumber = error "NaN" 18 castBack (IInfinite SPositive) = error "+Infinity" 19 castBack (IInfinite SNegative) = error "-Infinity" 10 20 11 newtype PureInt = MkInt Integer 12 deriving (Typeable, Show, Eq, Ord, Data, (:>:) Integer, (:<:) Integer) 21 data Sign 22 = SPositive 23 | SNegative 24 deriving (Show, Eq, Ord, Data, Typeable) 25 26 data PureInt 27 = IFinite !Integer 28 | IInfinite !Sign 29 | INotANumber 30 deriving (Typeable, Show, Eq, Ord, Data) 31 32 instance (:>:) Integer PureInt where 33 instance (:<:) Integer PureInt where 34 13 35 14 36 {- regretfully, I couldn't find a way to put this here w/o circularity. -
src/Pugs/Val/Str.hs
r12044 r12072 3 3 import Pugs.Internals 4 4 import qualified Data.ByteString.Char8 as Char8 5 6 --import {-# SOURCE #-} Pugs.Val 5 7 6 8 instance ((:>:) String) ByteString where cast = Char8.unpack … … 10 12 deriving (Typeable, Show, Eq, Ord, Data, (:>:) String, (:<:) String, (:>:) ByteString, (:<:) ByteString) 11 13 12 {- regretfully, I couldn't find a way to put this here w/o circularity. 14 {- regretfully, I couldn't find a way to put this here w/o circularity. - } 13 15 instance ICoercible P PureStr where 14 16 asStr = cast 15 -}17 { - -} 16 18 17 19 parseInt :: PureStr -> Int
