Changeset 11993 for src/Pugs/Val

Show
Ignore:
Timestamp:
08/08/06 15:08:42 (2 years ago)
Author:
audreyt
Message:

* unbreak the build by supplying an instance for new val

Files:
1 modified

Legend:

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

    r11977 r11993  
    22module Pugs.Val.Str where 
    33import Pugs.Internals 
     4import {-# SOURCE #-} Pugs.Val 
    45import qualified Data.ByteString.Char8 as Char8 
    56 
     
    1011    deriving (Typeable, Show, Eq, Ord, Data, (:>:) String, (:<:) String, (:>:) ByteString, (:<:) ByteString) 
    1112 
     13instance Coercible P PureStr where 
     14    asStr  = return . cast 
     15 
     16class (Monad m, Functor m, Eq a, Data a, Typeable a) => Coercible 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    asList   :: a -> Maybe (m PureList) 
     26    asList _ = Nothing -- default = do not flatten 
     27    asNative :: a -> m ValNative 
     28    asNative = fmap (NBuf . cast) . asStr 
     29