Skip to main contentdfsdf

doxyer Liu's List: F# Computation Expression

      • While for repetition.
      •  
      • TryWith and TryFinally for handling exceptions.
      •  
      • Use for managing disposables
    • all the methods discussed here rely on delays being used.

    6 more annotations...

    • What happens if we want to delay the whole workflow itself until needed
    • If we analyze this using the terminology of the earlier post, we can see that the types used are

    13 more annotations...

    • Ultimately, this detour will lead to a dead end, but I hope the journey might provide some more insight into good practices for designing your own computation expressions
    • But as a consequence of the generics, the Return method can't be overloaded any more!
    • the extra features needed to make the workflow more efficient, by controlling when expressions get evaluated
    • return and yield do not generate an early return from a computation expression. The entire computation expression, all the way to the last curly brace, is always evaluated and results in a single value.

    6 more annotations...

    • returning multiple values from a computation expression using the Combine method
    • In other words, we now have two values in our computation expression. And then the obvious question is, how should these two values be combined to give a single result for the computation expression as a whole?

    14 more annotations...

    • we'll work from the bottom up, starting with a simple workflow and adding methods only as needed to solve a problem or an error.
    • the MSDN documentation for computation expressions is meagre at best, and although not inaccurate, can be misleading

    15 more annotations...

    • Any type with a generic parameter can be used as a wrapper type
    • This rule and the next are about not losing information as you wrap and unwrap the values

    10 more annotations...

    • The let! has "unwrapped" the option before binding it to the value
    • the return has "wrapped" the raw value back into an option.

    11 more annotations...

    • computation expressions are just a way to create nice syntax for something that we could do ourselves.
    • In fact, you can turn it into an infix operation like this

    2 more annotations...

    • the called function always decides what to do
    • A continuation is simply a function that you pass into another function to tell it what to do next

    7 more annotations...

    • I will try to avoid using the forbidden m-word
    • Once you are on the other side, it is all obvious, but to someone on this side, it is baffling.

    7 more annotations...

    • Once you are on the other side, it is all obvious, but to someone on this side, it is baffling
1 - 12 of 12
20 items/page
List Comments (0)