darcsden :: Mindos -> atomo -> patch

atomo programming language (fork of alex's atomo) http://atomo-lang.org/

patch

changes

  • prelude/core.atomo :: line 5

      `Match new: (ts contents map: { `(~p -> ~e) | (p, e expand) })
    
      `Match new: (ts contents map: { `(~p -> ~e) | (p, e) })
    
  • src/Atomo/Environment.hs :: line 157

        unquote n m@(EMatch { eTarget = t, eBranches = bs }) = do
            nt <- unquote n t
            nbs <- forM bs $ \(p, e) -> do
                ne <- unquote n e
                return (p, ne)
            return m { eTarget = nt, eBranches = nbs }
    
  • src/Atomo/Environment.hs :: line 203

    eval (EMatch { eTarget = t, eBranches = bs }) = do
        v <- eval t
        ids <- gets primitives
        matchBranches ids bs v
    
    matchBranches :: IDs -> [(Pattern, Expr)] -> Value -> VM Value
    matchBranches _ [] v = raise ["no-match-for"] [v]
    matchBranches ids ((p, e):ps) v = do
        p' <- matchable' p
        if match ids Nothing p' v
            then newScope $ set p' v >> eval e
            else matchBranches ids ps v
    
  • src/Atomo/Kernel/Expression.hs :: line 5

    import Text.PrettyPrint (Doc)
    
  • src/Atomo/Kernel/Expression.hs :: line 10

    import Atomo.Pattern (match)
    
  • src/Atomo/Kernel/Expression.hs :: line 38

            Expression value <- here "value" >>= findExpression
    
    
  • src/Atomo/Kernel/Expression.hs :: line 39

            ids <- gets primitives
            return . Expression . EVM Nothing (Just $ prettyMatch value (zip pats exprs)) $
                eval value >>= matchBranches ids (zip ps exprs)
    
            Expression value <- here "value" >>= findExpression
            return (Expression (EMatch Nothing value (zip ps exprs)))
    
  • src/Atomo/Kernel/Expression.hs :: line 152

                EMatch {} -> return (particle "match")
    
  • src/Atomo/Kernel/Expression.hs :: line 160

                EMatch { eTarget = t } ->
                    return (Expression t)
    
  • src/Atomo/Kernel/Expression.hs :: line 241

                EMatch { eBranches = bs } ->
                    liftM list (mapM toValue bs)
    
  • src/Atomo/Kernel/Expression.hs :: line 307

    
    matchBranches :: IDs -> [(Pattern, Expr)] -> Value -> VM Value
    matchBranches _ [] v = raise ["no-match-for"] [v]
    matchBranches ids ((p, e):ps) v = do
        p' <- matchable' p
        if match ids Nothing p' v
            then newScope $ set p' v >> eval e
            else matchBranches ids ps v
    
    prettyMatch :: Expr -> [(Expr, Expr)] -> Doc
    prettyMatch t bs =
        pretty . EDispatch Nothing $
            keyword ["match"] [t, EBlock Nothing [] branches]
      where
        branches = flip map bs $ \(p, e) ->
            EDispatch Nothing $ keyword ["->"] [p, e]
    
    
  • src/Atomo/Parser/Expand.hs :: line 53

    doPragmas (EMatch { eTarget = e, eBranches = bs }) = do
        doPragmas e
        forM_ bs (doPragmas . snd)
    
  • src/Atomo/Parser/Expand.hs :: line 194

    macroExpand m@(EMatch { eTarget = t, eBranches = bs }) = do
        nt <- macroExpand t
        nbs <- forM bs $ \(p, e) -> do
            ne <- macroExpand e
            return (p, ne)
        return m { eTarget = nt, eBranches = nbs }
    
  • src/Atomo/Parser/Expand.hs :: line 282

    throughQuotes n f m@(EMatch { eTarget = t, eBranches = bs }) = do
        nt <- throughQuotes n f t
        nbs <- mapM (\(p, b) -> f n b >>= \nb -> return (p, nb)) bs
        f n m { eTarget = nt, eBranches = nbs }
    
  • src/Atomo/Pattern.hs :: line 311

    toMacroRole (EDispatch _ (Single { mName = "Match" })) = Just PEMatch
    
  • src/Atomo/Pretty.hs :: line 158

        prettyFrom _ PEMatch = text "Match"
    
  • src/Atomo/Pretty.hs :: line 204

        prettyFrom _ (EMatch _ t bs) =
            prettyFrom CKeyword t <+> text "match:" <+> branches
          where
            branches = braces . sep . punctuate (text ";") $
                flip map bs $ \(p, e) ->
                    pretty p <+> text "->" <+> pretty e
    
  • src/Atomo/Types.hs :: line 252

    
        -- | Matches any @EMatch@ expression.
        | PEMatch
    
  • src/Atomo/Types.hs :: line 350

        | EMatch
            { eLocation :: Maybe SourcePos
            , eTarget :: Expr
            , eBranches :: [(Pattern, Expr)]
            }
    
  • src/Atomo/Types.hs :: line 526

        (==) PEForMacro PEForMacro = True --
    
        (==) PEForMacro PEForMacro = True
    
  • src/Atomo/Types.hs :: line 531

        (==) PEMacroQuote PEMacroQuote = True --
    
        (==) PEMacroQuote PEMacroQuote = True
        (==) PEMatch PEMatch = True
    
  • src/Atomo/Types.hs :: line 562

        (==) (EMatch _ at avs) (EMatch _ bt bvs) =
            at == bt && avs == bvs
    
  • src/Atomo/Types.hs :: line 646

        lift (EMatch _ t bs) = [| EMatch Nothing t bs |]
    
  • src/Atomo/Types.hs :: line 696

        lift PEMatch = [| PEMatch |]
    
  • src/Atomo/Valuable.hs :: line 67

    instance Valuable Pattern where
        toValue = return . Pattern
        fromValue (Pattern x) = return x
        fromValue v = raise ["wrong-value", "needed"] [v, string "Pattern"]
    
    instance Valuable Expr where
        toValue = return . Expression
        fromValue (Expression x) = return x
        fromValue v = raise ["wrong-value", "needed"] [v, string "Expression"]