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
| {-# LANGUAGE Rank2Types #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE DefaultSignatures #-} | |
| {-# LANGUAGE DeriveDataTypeable #-} | |
| {-# LANGUAGE StandaloneDeriving #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| module Main where |
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
| (** Either *) | |
| module Either : sig | |
| type ('a, 'b) t = Left of 'a | Right of 'b | |
| val left : 'a -> ('a, 'b) t | |
| val right : 'b -> ('a, 'b) t | |
| val either : ('a -> 'c) -> ('b -> 'c) -> ('a, 'b) t -> 'c |
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 x = { xi : int; xv : int } | |
| type y = { yi : int; yv : int } | |
| type var = X of x | Y of y | |
| type equation = { x : int; y : int; c : int } | |
| module VarSet = Set.Make(struct | |
| type t = var | |
| let compare = compare | |
| end) |
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
| open Lwt | |
| module Key = struct | |
| type t = string | |
| end | |
| module Value = struct | |
| type t = string | |
| end |
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
| import json | |
| id = lambda a: a | |
| flatten_list = lambda f: lambda l: map(f, l) | |
| def flatten_object(l): | |
| sentinel = object() | |
| def f(obj): |
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
| {-# LANGUAGE BangPatterns #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where | |
| import Control.Monad (unless) | |
| import Data.ByteString (ByteString) | |
| import qualified Data.ByteString as BS (null, splitAt) | |
| import qualified Data.ByteString.Unsafe as BS (unsafeUseAsCString) |
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
| module type Monad = sig | |
| type 'a t | |
| val return : 'a -> 'a t | |
| val bind : 'a t -> ('a -> 'b t) -> 'b t | |
| end | |
| module Client : sig | |
| type key = string | |
| type value = string |
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
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| module Main (insert, delete, lookup, runTrackedMap, main) where | |
| import Prelude hiding (lookup) | |
| import Control.Applicative (Applicative) | |
| import Data.Set (Set) |
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
| (* This works *) | |
| module W = struct | |
| type a | |
| type b | |
| type (_, _) t = | |
| | AA : (a, a) t | |
| | AB : (a, b) t | |
| | BB : (b, b) t |
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
| (* Module overview: | |
| * | |
| * Transition : contains a witness of valid transitions | |
| * State : wrapper for states, and handler for events given some state | |
| * Event : incoming events | |
| * Effect : resulting effects | |
| * Follower / Candidate / Leader : states | |
| * | |
| * Every module of Follower, Candidate and Leader have a state type, t, and an | |
| * 'event_witness' type which defines the events their respective handler |