Changeset 12044 for src/Pugs/Val

Show
Ignore:
Timestamp:
08/09/06 19:09:40 (2 years ago)
Author:
audreyt
Message:

* Implicit coercion to int and to bool for PureStr? VV.

Location:
src/Pugs/Val
Files:
3 modified

Legend:

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

    r12008 r12044  
    66instance ((:>:) PureInt) Integer where cast = MkInt 
    77instance ((:<:) PureInt) Integer where castBack (MkInt i) = i 
     8 
     9instance ((:>:) PureInt) Int where cast = MkInt . toInteger 
    810 
    911newtype PureInt = MkInt Integer 
  • src/Pugs/Val/Num.hs

    r12043 r12044  
    66instance ((:>:) PureNum) Double where cast = MkNum 
    77instance ((:<:) PureNum) Double where castBack (MkNum i) = i 
     8 
     9instance ((:>:) PureNum) Int where cast = MkNum . fromIntegral 
    810 
    911newtype PureNum = MkNum Double 
  • src/Pugs/Val/Str.hs

    r12041 r12044  
    1515-} 
    1616 
    17 parseNum :: PureStr -> Double 
    18 parseNum (MkStr s) = fromIntegral i 
    19     where (i, _) = maybe (0, undefined) id $ Char8.readInt s 
     17parseInt :: PureStr -> Int 
     18parseInt (MkStr s) = maybe 0 fst (Char8.readInt s)