Skip to content

Instantly share code, notes, and snippets.

Avatar

David Siegel dvdsgl

View GitHub Profile
@dvdsgl
dvdsgl / Handler.purs
Created Mar 3, 2015
Error in declaration monadEffHandlerM
View Handler.purs
type ExpressM a = forall e. Eff (express :: Express | e) a
data HandlerM a = HandlerM (Request -> Response -> ExpressM Unit -> ExpressM a)
instance monadEffHandlerM :: MonadEff eff HandlerM where
liftEff act = HandlerM \_ _ _ -> unsafeInterleaveEff act
View Trello.purs
module Trello
( BoardId()
, Credentials()
, Trello()
, runTrello
, Board()
, getBoard
) where
import Data.Maybe
@dvdsgl
dvdsgl / Writer.fs
Last active Aug 29, 2015
Implement Writer monad with custom keyword.
View Writer.fs
type Writer<'Result, 'Output> =
| W of 'Result * seq<'Output>
type WriterBuilder() =
member this.Zero() = W ((), Seq.empty)
member this.Yield(x) = W (x, Seq.empty)
member this.Return(x) = this.Yield(x)
member this.Bind(W (a, xs), k) =
let (W (b, ys)) = k a
W (b, Seq.append xs ys)
View OnPlatform.fs
Device.OnPlatform <| function
| iOS, Tablet ->
this.Padding <- Thickness(0, 0, 0, 0)
| _ -> ()
@dvdsgl
dvdsgl / PhotoViewController.fs
Created Jun 10, 2014
Cirrious.FluentLayout makes iOS Auto Layout... fun! Especially in F#.
View PhotoViewController.fs
open System
open MonoTouch.UIKit
open Cirrious.FluentLayouts.Touch
type PhotoViewController() =
inherit UIViewController()
let imageViewSize = 200.0f
let imageView =
let view = UIImageView(
View HexagonApp.cs
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace HexagonApp {
[Register ("AppDelegate")]
class AppDelegate : UIApplicationDelegate {
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options) {
View WhatsForLunch.fs
module MonkeyBot.Plugins.WhatsForLunch
open System
open DDay.iCal
open MonkeyBot
let ZeroCaterId = "..."
type LunchResponse =
| Lunch of string
View trace.fs
let trace format = flip Printf.ksprintf format <| fun line ->
if Environment.GetEnvironmentVariable "DEBUG" = "true" then
Console.WriteLine line
@dvdsgl
dvdsgl / LoremIpsum.cs
Last active Dec 22, 2015
Need some placeholder text in your Xamarin app?
View LoremIpsum.cs
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Gibberish
{
public static class LoremIpsum
{
const string Corpus = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ornare id erat a pellentesque. Integer tincidunt velit odio, molestie varius lorem volutpat at. Sed ultricies ligula orci, congue condimentum libero sollicitudin non. Morbi eget nisl facilisis, semper enim in, lacinia ligula. Etiam felis leo, malesuada non consequat ut, dignissim vitae arcu. Quisque a turpis sodales, dignissim nunc posuere, ornare risus. Nunc vitae ligula porttitor, consectetur odio ut, condimentum ipsum.
View delegate.cs
using System;
namespace Foo
{
class MainClass
{
static void Go (Action<int> act)
{
act (1);
}