Changeset 15412 for src/Pugs/Val

Show
Ignore:
Timestamp:
03/03/07 14:47:06 (21 months ago)
Author:
audreyt
Message:

* Refactor Feed and Capture out to Pugs.Val.Capture

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

Legend:

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

    r15395 r15412  
    44import Pugs.Types 
    55import Pugs.Val.Base 
     6import Pugs.Val.Capture 
    67import Data.Monoid 
    78import qualified Data.Map as Map 
     
    201202-} 
    202203 
    203 -- | a Capture is a frozen version of the arguments to an application. 
    204 data Capt a 
    205     = CaptMeth 
    206         { c_invocant :: a 
    207         , c_feeds    :: [Feed a] 
    208         } 
    209     | CaptSub 
    210         { c_feeds    :: [Feed a] 
    211         } 
    212     deriving (Show, Eq, Ord, Typeable) {-!derive: YAML_Pos, Perl6Class, MooseClass!-} 
    213  
    214 -- | non-invocant arguments. 
    215 data Feed a = MkFeed 
    216     { f_positionals :: [a] 
    217     , f_nameds      :: Map.Map ID [a]   -- ^ maps to [a] and not a since if the Sig stipulates 
    218                                     --   @x, "x => 1, x => 2" constructs @x = (1, 2). 
    219     } 
    220     deriving (Show, Eq, Ord, Typeable) {-!derive: YAML_Pos, Perl6Class, MooseClass!-} 
    221  
    222 instance Monoid (Feed a) where 
    223     mempty = MkFeed mempty mempty 
    224     mappend (MkFeed x1 x2) (MkFeed y1 y2) = MkFeed (mappend x1 y1) (mappend x2 y2) 
    225     mconcat xs = MkFeed (mconcat (map f_positionals xs)) (mconcat (map f_nameds xs)) 
    226  
    227 emptyFeed :: Feed a 
    228 emptyFeed = MkFeed [] Map.empty 
    229  
    230204-- | Runtime Capture with dynamic Exp for leaves 
    231205--type ExpCapt = Capt Exp