Changeset 13488 for src/Pugs/Val

Show
Ignore:
Timestamp:
09/20/06 11:54:32 (2 years ago)
Author:
audreyt
Message:

* Pugs.Val: asStr instance for PureInt?.
* Also make Feed a Monoid.

Location:
src/Pugs/Val
Files:
2 modified

Legend:

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

    r13280 r13488  
    7575instance ICoercible P PureInt where 
    7676    asInt = return . cast 
     77    asStr INotANumber           = cast "NaN" 
     78    asStr (IInfinite SPositive) = cast "Inf" 
     79    asStr (IInfinite SNegative) = cast "-Inf" 
     80    asStr (IFinite n)           = cast (show n) 
    7781    asNum INotANumber           = return $ cast ( (0/0) :: Double) 
    7882    asNum (IInfinite SPositive) = return $ cast ( (1/0) :: Double) 
  • src/Pugs/Val/Code.hs

    r13464 r13488  
    207207    deriving (Show, Eq, Ord, Typeable) {-!derive: YAML_Pos, Perl6Class, MooseClass!-} 
    208208 
     209instance Monoid (Feed a) where 
     210    mempty = MkFeed mempty mempty 
     211    mappend (MkFeed x1 x2) (MkFeed y1 y2) = MkFeed (mappend x1 y1) (mappend x2 y2) 
     212    mconcat xs = MkFeed (mconcat (map f_positionals xs)) (mconcat (map f_nameds xs)) 
     213 
    209214emptyFeed :: Feed a 
    210215emptyFeed = MkFeed [] Map.empty