Skip to content

Instantly share code, notes, and snippets.

View dvdsgl's full-sized avatar
🦋
Gliding

David Siegel dvdsgl

🦋
Gliding
View GitHub Profile
@dvdsgl
dvdsgl / Handler.purs
Created March 3, 2015 21:56
Error in declaration monadEffHandlerM
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
module Trello
( BoardId()
, Credentials()
, Trello()
, runTrello
, Board()
, getBoard
) where
import Data.Maybe
@dvdsgl
dvdsgl / Writer.fs
Last active August 29, 2015 14:04
Implement Writer monad with custom keyword.
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)
Device.OnPlatform <| function
| iOS, Tablet ->
this.Padding <- Thickness(0, 0, 0, 0)
| _ -> ()
@dvdsgl
dvdsgl / PhotoViewController.fs
Created June 10, 2014 16:51
Cirrious.FluentLayout makes iOS Auto Layout... fun! Especially in F#.
open System
open MonoTouch.UIKit
open Cirrious.FluentLayouts.Touch
type PhotoViewController() =
inherit UIViewController()
let imageViewSize = 200.0f
let imageView =
let view = UIImageView(
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) {
module MonkeyBot.Plugins.WhatsForLunch
open System
open DDay.iCal
open MonkeyBot
let ZeroCaterId = "..."
type LunchResponse =
| Lunch of string
let trace format = flip Printf.ksprintf format <| fun line ->
if Environment.GetEnvironmentVariable "DEBUG" = "true" then
Console.WriteLine line
@dvdsgl
dvdsgl / LoremIpsum.cs
Last active December 22, 2015 13:08
Need some placeholder text in your Xamarin app?
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.
using System;
namespace Foo
{
class MainClass
{
static void Go (Action<int> act)
{
act (1);
}