Skip to content

Instantly share code, notes, and snippets.

@caiorss
caiorss / ConstrainedTypesExamples.fsx
Created June 9, 2017 21:54 — forked from swlaschin/ConstrainedTypesExamples.fsx
Examples of creating constrained types in F#
module ConstrainedTypes =
open System
// General hints on defining types with constraints or invariants
//
// Just as in C#, use a private constructor
// and expose "factory" methods that enforce the constraints
//
// In F#, only classes can have private constructors with public members.
//
@caiorss
caiorss / Demonstrations.ml
Last active June 7, 2018 08:53 — forked from rizo/pipes.ml
Quick self-contained demonstration of coroutine pipes in OCaml. - Talk given by Rizo Isrof
(**
Talk given by Rizo Isrof
- https://pusher.com/sessions/meetup/the-realtime-guild/realtime-stream-processing-with-coroutines
- https://www.reddit.com/r/ocaml/comments/66pe0s/stream_processing_with_coroutines_from_c_to_ocaml/
*)
# empty ;;
- : ('a, 'b, unit) pipe = Ready ()
#
@caiorss
caiorss / Free.fsx
Created March 15, 2017 18:21
Free monad interpreter in F# (based on: http://programmers.stackexchange.com/a/242803/145941)
type DSL<'next> =
| Get of string * (string -> 'next)
| Set of string * string * 'next
| End
with static member fmap f = function
| Get (k, c) -> Get (k, f << c)
| Set (k, v, c) -> Set (k, v, f c)
| End -> End
type FreeDSL<'a> =
@caiorss
caiorss / lorenz.py
Created March 10, 2017 18:09 — forked from NT7S/lorenz.py
Draw the Lorenz system in Python/GTK
# lorenz.py
# 5 March 2016
#
# Copyright 2016 Jason Milldrum
#
# Draw the Lorenz system in a GTK window
# See https://en.wikipedia.org/wiki/Lorenz_system
import math
import gi
@caiorss
caiorss / Monaso.cs
Created March 10, 2017 17:45 — forked from HiroNakamura/Monaso.cs
Ejemplos en C#
/*
Ejemplos de código en C#
*/
//32 for
using System;
public class Monaso{
using System;
using Gtk;
using WebKit;
namespace monobrowser {
class coolbrowser {
public static void Main () {
Application.Init ();
Window window = new Window ("a browser in 13 lines...");
@caiorss
caiorss / 01_MainWindow.cs
Created March 10, 2017 17:31
Monoのサンプルコード
using System;
using Gtk;
public partial class MainWindow: Gtk.Window
{
public MainWindow () : base (Gtk.WindowType.Toplevel)
{
Window myWin = new Window ("My first GTK# Application!");
myWin.Resize (200, 200);
//
// AndroidDesignerView.cs
//
// Author:
// Lluis Sanchez <[email protected]>
//
// Copyright (c) 2011 Xamarin Inc
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@caiorss
caiorss / Main.cs
Created March 10, 2017 17:28 — forked from carlosmn/Main.cs
Gtk#-3 with GtkBuilder
using System;
using Gtk;
namespace builder
{
class MainWin
{
[Gtk.Builder.Object("window1")] Window window1;
public void OnToggled(object sender, EventArgs args)
{
@caiorss
caiorss / Reader.scala
Created March 10, 2017 17:26 — forked from kafecho/Reader.scala
Example of using the Reader Monad.
package org.kafecho.learning.monad
import java.util.UUID
/** My attempt at implementing the Reader Monad concept.
* The Reader Monad encapsulates a computation which:
* - requires a dependency of type D
* - produces values of type A.
*/
case class Reader[D, A](computation: D => A) {