This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* An OCaml implementation of final tagless, inspired from this article by Oleksandr Manzyuk: | |
* https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-object-algebras-to-finally-tagless-interpreters-2/ | |
*) | |
module FinalTagless = struct | |
type eval = { eval : int } | |
type view = { view : string } | |
module type ExpT = sig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Purely functional I/O in Ocaml via the Free monad. | |
* by Ricky Elrod <[email protected]>. | |
* | |
* This is free and unencumbered software released into the public domain. | |
* | |
* Anyone is free to copy, modify, publish, use, compile, sell, or | |
* distribute this software, either in source code form or as a compiled | |
* binary, for any purpose, commercial or non-commercial, and by any | |
* means. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ReasonML equivalent to OCaml's GADTs: | |
type 'a t = | |
| Array : 'a array -> 'a t | |
| Bytes : bytes -> char t | |
let length (type el) (t:el t) = match t with | |
| Bytes b -> Bytes.length b | |
| Array a -> Array.length a | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bitset | |
import "fmt" | |
const ( | |
chunkSize uint = 8 | |
allSet uint64 = 1<<8 - 1 | |
allReset uint64 = 0 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
*Compile with: | |
*ocamlfind ocamlc -o test_async -thread -linkpkg -package core,async test_async.ml | |
*Run with: | |
*./test_async | |
*) | |
open Async.Std | |
open Core.Std | |
open Async.Std.Deferred.Infix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
*Compile with: | |
*ocamlfind ocamlc -o test_lwt -thread -linkpkg -package core,lwt,lwt.unix test_lwt.ml | |
*Run with: | |
*./test_lwt | |
*) | |
open Lwt.Infix | |
open Core.Std | |
let rec read_data ic = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type 'a tree = | |
| Leaf of 'a | |
| Node of 'a * 'a tree * 'a tree;; | |
let t = Node (6, (Node (7, (Leaf 1), (Leaf 2))), (Node (8, (Leaf 3), (Leaf 4))));; | |
let rec parse t = | |
let rec parse_trees trees acc = match trees with | |
| [] -> acc | |
| (Leaf i) :: tl -> parse_trees tl (i + acc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#require "ppx_sexp_conv";; | |
let l = [(1, "one"); (2, "two")];; | |
List.iter l ~f:(fun x -> | |
[%sexp_of: int * string] x | |
|> Sexp.to_string | |
|> print_endline);; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aaaa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.test.uml | |
case class Object(name: String) { | |
def --(message: String) = (this, message) | |
def <--(message: String) = (this, message) | |
} | |
sealed trait Action | |
sealed case class Call(source: Object, verb: String, destination: Object) extends Action | |
sealed case class Async(source: Object, verb: String, destination: Object) extends Action |
NewerOlder