Snippets tagged monad

  • Uri Parser

    A Uri parser using the Cashel library [1]. This implementation is using ArraySegment as the underlying state, as I'm using it within a server, but it would be trivial to switch it to using a list. Also, note that I am not parsing the Uri into any specific structure, though that, too, would be trivial. For my current purposes, I just needed to validate the Uri. [1] https://github.com/panesofglass/cashel

    26 people like this

    Posted: 13 years ago by Ryan Riley

  • LazyBuilder

    I made LazyBuilder. The synthesis of the lazy function is troublesome. When the call of the Force() method increases, it is ugly. This solves the problem.

    11 people like this

    Posted: 13 years ago by zecl

  • Continuation Monad with Call/CC

    This is an implementation of the Continuation monad using a type, taking an exception handler, and allowing for Call/CC. This specific implementation is mostly Matt Podwysocki's. I have a similar implementation using a purely functional, exception-handler-less version in FSharp.Monad. Until now, I haven't been able to resolve the callCC operator.

    4 people like this

    Posted: 13 years ago by Ryan Riley

  • Monadic Retry

    A Monad for composing computations with retry logic. (Useful when we work with Cloud Services)

    6 people like this

    Posted: 13 years ago by Nick Palladinos

  • Simple typeclass implementation

    I learned how to implement this by reading this great good project http://code.google.com/p/fsharp-typeclasses/ But I can't understand why the project needs ternary operator. I used binary operator and seems it's okay.

    6 people like this

    Posted: 12 years ago by nagat01

  • Exception Retry Computation Expression

    Retry monad: chaining functions together, retrying each one if exceptions are thrown, until the first time a function can no longer be retried

    5 people like this

    Posted: 12 years ago by Boris Kogan

  • Traits, Mixins and Aspect-Oriented Programming in F#

    A compositional type system built using generics and monads in F#. It is only a very limited, _toy_ project exploring traits, mixins and aspect-oriented programming.

    17 people like this

    Posted: 12 years ago by Zach Bray

  • Monadic Trampoline

    A monadic trampoline for stack-overflow free programming.

    6 people like this

    Posted: 12 years ago by Nick Palladinos

  • Monad Bind 2 of 3

    After watching this clip (http://www.youtube.com/watch?v=ZhuHCtR3xq8) on Youtube featuring Brian Beckman I wanted to try to sketch Brian's main argument that Monads' main purpose is function composition. I will post my sketch to http://rodhern.wordpress.com/2014/02/ . These snippets are the companion examples to the blog post.

    1 people like this

    Posted: 10 years ago by Robert Nielsen

  • Flappy bird with the flappy monad

    This is a crazy solution to the flappy bird dojo by Phil Trelford. It defines a custom computation builder to eliminate all mutation of the flappy bird. The script uses WPF and is playable on Windows in F# interactive, just copy the raw version, and for cross-platform implementations download: http://trelford.com/prognet15.zip

    3 people like this

    Posted: 9 years ago by Tomas Petricek

  • Where does the Celsius come from?

    An exploration of the power of Computation Expressions, Type Extensions, Extension Methods, and Method Overloading. May or may not be a monad or a monoid - we're not sure, nor do we care to check.

    7 people like this

    Posted: 6 years ago by Tomas Petricek, Krzysztof Cieślak, John Azariah, Phillip Carter

  • Disposable Scopes provided by scope {...} computational workflow.

    This snippet provides a builder for scope {...} computational workflow that returns a Scope object implementing System.IDisposable interface. All "use" bindings inside scope {...} workflow are kept from being disposed immediately when computation leaves scope. Instead, they are disposed only when resulting Scope object is disposed. This makes possible to access disposable outside the scope while it remains usable. This can be achieved by via return statement of workflow that can return, for example, a closure that encapsulates disposable. scope {...} return value is available through Value property of Scope object. Scopes may be nested through let! binding that means that nested scope will be disposed when the resulting scope is disposed.

    3 people like this

    Posted: 2 years ago by Crazy Monk