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: 6 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: 5 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: 5 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: 5 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: 5 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

    3 people like this

    Posted: 5 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.

    15 people like this

    Posted: 5 years ago by Zach Bray

  • Monadic Trampoline

    A monadic trampoline for stack-overflow free programming.

    4 people like this

    Posted: 4 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: 3 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

    1 people like this

    Posted: 1 years ago by Tomas Petricek

  • Disposable computation builder

    Computation builder that provides easy way of constructing IDisposable objects. It supports elegant composition of disposable objects using 'do!' which can be used for example when working with 'IObservable' type.

    42 people like this

    Posted: 6 years ago by Tomas Petricek

  • Tiny IO Monad

    Haskell-style IO in F#.

    12 people like this

    Posted: 5 years ago by igeta

  • Delimited Continuation Monad

    Oleg's delimited continuation monad [1] and creating an external iterator from an internal iterator using it. [1] http://okmij.org/ftp/continuations/implementations.html#genuine-shift

    6 people like this

    Posted: 5 years ago by einblicker

  • Non-deterministic computation builder

    Computation builder for writing non-deterministic computations.

    8 people like this

    Posted: 5 years ago by Tomas Petricek

  • Polymorphic Maybe monad with default value.

    Polymorphic (via generics) Maybe monad/computational expression with default value + Zipper

    5 people like this

    Posted: 5 years ago by Daniil

  • Simple builder example: Nullable

    Simple Computational expressions / monad / builder -example, using .NET Nullable as demo.

    3 people like this

    Posted: 5 years ago by Tuomas Hietanen

  • Monadic state lifting combinators

    The generic model for stateful computation (S -> S x R) provides a convenient mechanism of threading stateful computation results since the functor λR . S -> S x R is monadic. But what happens if we want to thread state itself? Well, the mapping λS. S -> S x R is not even functorial! But it turns out it can become so with a bit of trickery. This snippet demonstrates a way to lift, project or inject stateful computations into ambient state monads.

    8 people like this

    Posted: 4 years ago by Eirik Tsarpalis

  • Monad Bind 1 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.

    3 people like this

    Posted: 3 years ago by Robert Nielsen

  • Monad Bind 3 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: 3 years ago by Robert Nielsen

  • An approach to MonadFix in ML?

    A colleague recently mentioned the problem of not having MonadFix in a strict language. Here is my 2 hour potential approach to implementing it in ML. Let me know if I got something totally wrong!

    2 people like this

    Posted: 1 years ago by Vesa Karvonen