Changeset 12072 for src/Pugs/Val

Show
Ignore:
Timestamp:
08/10/06 14:50:18 (2 years ago)
Author:
gaal
Message:

* New vv prim to convert oldvals to VV form
* A little documentation in Pugs.Val
* PureBit?
* PureInt? to Infinity and beyond

Location:
src/Pugs/Val
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Val/Int.hs

    r12044 r12072  
    44import qualified Data.ByteString.Char8 as Char8 
    55 
    6 instance ((:>:) PureInt) Integer where cast = MkInt 
    7 instance ((:<:) PureInt) Integer where castBack (MkInt i) = i 
     6instance ((:>:) PureInt) Integer where cast = IFinite 
     7instance ((:<:) 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" 
    812 
    9 instance ((:>:) PureInt) Int where cast = MkInt . toInteger 
     13-- ugh, duplicate from above? lose, lose. 
     14instance ((:>:) PureInt) Int where cast = IFinite . toInteger  
     15instance ((:<:) 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" 
    1020 
    11 newtype PureInt = MkInt Integer 
    12     deriving (Typeable, Show, Eq, Ord, Data, (:>:) Integer, (:<:) Integer) 
     21data Sign 
     22    = SPositive 
     23    | SNegative 
     24    deriving (Show, Eq, Ord, Data, Typeable) 
     25 
     26data PureInt 
     27    = IFinite      !Integer 
     28    | IInfinite    !Sign 
     29    | INotANumber 
     30    deriving (Typeable, Show, Eq, Ord, Data) 
     31 
     32instance (:>:) Integer PureInt where 
     33instance (:<:) Integer PureInt where 
     34 
    1335 
    1436{- regretfully, I couldn't find a way to put this here w/o circularity. 
  • src/Pugs/Val/Str.hs

    r12044 r12072  
    33import Pugs.Internals 
    44import qualified Data.ByteString.Char8 as Char8 
     5 
     6--import {-# SOURCE #-} Pugs.Val 
    57 
    68instance ((:>:) String) ByteString where cast = Char8.unpack 
     
    1012    deriving (Typeable, Show, Eq, Ord, Data, (:>:) String, (:<:) String, (:>:) ByteString, (:<:) ByteString) 
    1113 
    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. - } 
    1315instance ICoercible P PureStr where 
    1416    asStr  = cast 
    15 -} 
     17{ - -} 
    1618 
    1719parseInt :: PureStr -> Int