Last active
February 2, 2021 03:18
-
-
Save Swoorup/3d75a8cd5479270fae96aa4ce33f0fde to your computer and use it in GitHub Desktop.
Testing Anonymous typed-tagged unions.
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 System;; | |
let random = new Random(); | |
let _rollTheDice (): (int|string) = | |
let number = random.Next(1, 6) | |
if (number >= 2) then number else "Winner" | |
let cls () = System.Console.Clear();; | |
type A = (int|string|int64) | |
let sth(): A = 1 | |
let consumeSubset(b: (int64|string)) = .. | |
let consume() = | |
match sth() with | |
| :? int as i -> .. | |
| lOrStr -> /// inferred as (int64|string) | |
consumeSubset(lOrStr) | |
type Operand = byte[] | |
type Ref = byte[] | |
type AddInst = AddInst of Operand * Operand | |
type MulInst = MulInst of Operand * Operand | |
type SubInst = SubInst of Operand * Operand | |
type LoadInst = LoadInst of Ref * Ref | |
type SaveInst = SaveInst of Ref * Ref | |
type Noop = Noop of unit | |
type ArithInst = (AddInst | MulInst | SubInst) | |
type MemOps = (LoadInst | SaveInst) | |
type ArithmeticProcessor = ArithOps -> unit | |
type MemoryProcessor = MemOps -> unit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment