Coder Social home page Coder Social logo

angara.flow's People

Contributors

microsoft-github-policy-service[bot] avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angara.flow's Issues

Support for importing artefacts from another flow expression using "import" and "take" operations

let ``Extend and continue work using computation expression``() =
    let w1 = work {
        let! x = makeValue 1 |> name "one"
        let! y = inc x
        let! z = inc x 
        let! w = add(x,y) |> name "sum"
        ()
    }
    let eng,names,annotations,_ = startFrom_x w1 (createDefaultSuffix)
    let wrk = Execution.EngineAPI.AwaitCompletion eng |> Async.RunSynchronously
    eng.Dispose()

    Trace.WriteLine("\n\n\nContinues...")
    let snapshot = wrk, names, annotations
    let w2 = work {
        let! y = snapshot |> take<int> "out one"
        let! w = snapshot |> take<int> "out sum"
        let! z = inc y
        return z
    }

    let (g,_,_) = build w2 
    Assert.AreEqual(4, g.Structure.Vertices.Count)

    match eval w2 |> Async.RunSynchronously with
    | EvaluationResult.Failed _ -> failwith "Work failed"
    | EvaluationResult.Success z -> 
        z =? 3

Support for resumable iterative function in MethodDecl

let ``Use resumable iterative method in a 'work' monad``() =
        let g = work {
            let! func    = makeValue (fun (x:float) -> x*x - 4.*x + 2.)
            let! settings= makeValue (3.0, 0.1, 0.001)
            let! root    = root (func, settings)
            return! incf root
        } 
        match eval(g) |> Async.RunSynchronously with
        | EvaluationResult.Failed  _ -> Assert.Fail("Failed to execute a work")
        | EvaluationResult.Success(v) -> Assert.AreEqual(1. + (2. + sqrt(2.)), v, 0.01, "Incorrect root")

Support for compound methods when building flow expression

let ``Building compound method with 2 outputs from work expression``() =
    let incsum (x: ArtefactExpression<int>) (y: ArtefactExpression<int>) : FlowExpression<ArtefactExpression<int>*ArtefactExpression<int>> =
        flow {
            let! a = inc x
            let! b = sum (collect[| a; y |])
            return a,b 
        }

    let makeIncsum = decl incsum "incsum values" |> carg "x" |>carg "y" |> cresult ["a";"b"]
    let contract = Angara.Contracts.getContract makeIncsum

    let w = work{
        let! a,b = makeIncsum (value 2) (value 5)
        return a,b
    }

    match eval2 w |> Async.RunSynchronously with
    | EvaluationResult.Success (a,b) -> 
        (3,8) =? (a,b)
    | EvaluationResult.Failed _ -> Assert.Fail("Work failed")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.