Changeset 12008 for src/Pugs/Val

Show
Ignore:
Timestamp:
08/08/06 18:35:12 (2 years ago)
Author:
gaal
Message:

* Add VV support for PureInt?. The verification is awkward to make with

the hack, so it's commented out.

* Belay the attempts at -boot files since they don't seem to allow

ICoercible. The cost is that instances for that class must be defined
in Pugs.Val.

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

Legend:

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

    r12004 r12008  
    22module Pugs.Val.Str where 
    33import Pugs.Internals 
    4 import {-# SOURCE #-} Pugs.Val 
    54import qualified Data.ByteString.Char8 as Char8 
    65 
     
    1110    deriving (Typeable, Show, Eq, Ord, Data, (:>:) String, (:<:) String, (:>:) ByteString, (:<:) ByteString) 
    1211 
     12{- regretfully, I couldn't find a way to put this here w/o circularity. 
    1313instance ICoercible P PureStr where 
    1414    asStr  = cast 
    15  
    16 class (Monad m, Functor m, Eq a, Data a, Typeable a) => ICoercible m a | a -> m where 
    17     asBit    :: a -> m PureBit 
    18     asBit _ = return True 
    19     asInt    :: a -> m PureInt 
    20     asInt x = fail $ "coerce fail: " ++ (show $ typeOf x) ++ " to PureInt" 
    21     asNum    :: a -> m PureNum 
    22     asNum x = fail $ "coerce fail: " ++ (show $ typeOf x) ++ " to PureNum" 
    23     asStr    :: a -> m PureStr 
    24     asStr x = return (cast "<opaque>") -- XXX wrong 
    25     -- "$item = VAL" 
    26     asItem   :: a -> Maybe (m Val) 
    27     asItem _ = Nothing -- default = do nothing (for Scalar this would return its content) 
    28     -- "@list = VAL" 
    29     asList   :: a -> Maybe (m PureList) 
    30     asList _ = Nothing -- default = do nothing (for Scalar this would return its content wrapped in a 1-seq) 
    31     asNative :: a -> m ValNative 
    32     asNative = fmap (NBuf . cast) . asStr 
    33  
     15-}