This file contains 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 Base = struct | |
type _ Effect.t += | |
| IsOdd: int -> bool Effect.t | |
| IsEven: int -> bool Effect.t | |
end | |
module Odd = struct | |
let is_odd n = | |
if n=0 then false | |
else Effect.perform (Base.IsEven (n-1)) |
This file contains 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 D = Effect.Deep | |
type 'a expr = .. | |
type _ Effect.t += | |
| Extension : 'a expr -> 'a Effect.t | |
| Evaluate : 'a expr -> 'a Effect.t | |
let eval_effect e = Effect.perform (Evaluate e) | |
(* Extension 1 *) |
This file contains 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 D = Effect.Deep | |
type 'a expr = .. | |
type _ Effect.t += | |
| Extension : 'a expr -> 'a Effect.t | |
| Evaluate : 'a expr -> 'a Effect.t | |
let eval_effect e = Effect.perform (Evaluate e) | |
(* Extension 1 *) |
This file contains 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 D = Effect.Deep | |
type 'a expr = .. | |
type _ Effect.t += Extension : 'a expr -> 'a Effect.t | |
(* Base interpreter *) | |
let eval_base e = Effect.perform (Extension e) | |
(* Extension 1 *) | |
type 'a expr += |
This file contains 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 D = Effect.Deep | |
type 'a expr = .. | |
type _ Effect.t += Extension : 'a expr -> 'a Effect.t | |
(* Base Interpreter *) | |
type 'a expr += | |
| Int : int -> int expr | |
| Add : int expr * int expr -> int expr | |
| Sub : int expr * int expr -> int expr |
This file contains 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 ty = | |
| TVar of tvar ref | |
| TArrow of ty * ty | |
| TUnit | |
| TBool | |
| TInt | |
| TTuple of ty list | |
| TRecord of (string * ty) list | |
| TVariant of (string * ty) list | |
| TRef of ty |
This file contains 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 ty = | |
| TVar of tvar ref | |
| TArrow of ty * ty | |
| TUnit | |
| TBool | |
| TInt | |
| TTuple of ty list | |
| TRecord of (string * ty) list | |
| TVariant of (string * ty) list | |
| TRef of ty |
This file contains 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 ty = | |
| TVar of tvar ref | |
| TArrow of ty * ty | |
| TUnit | |
| TBool | |
| TInt | |
| TTuple of ty list | |
| TRecord of (string * ty) list | |
| TVariant of (string * ty) list | |
| TRef of ty |
This file contains 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 ty = | |
| TVar of tvar ref | |
| TArrow of ty * ty | |
| TUnit | |
| TBool | |
| TInt | |
| TTuple of ty list | |
| TRecord of (string * ty) list | |
| TVariant of (string * ty) list | |
| TRef of ty |
This file contains 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 ty = | |
| TVar of tvar ref | |
| TArrow of ty * ty | |
| TUnit | |
| TBool | |
| TInt | |
| TTuple of ty list | |
| TRecord of (string * ty) list | |
| TVariant of (string * ty) list | |
| TRef of ty |
NewerOlder