You have some WASM code in fact.wat that you want to test.
You have installed the WebAssembly reference
interpreter,
and can call it as wasm (or <some_path>/wasm).
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Playing with Llamafile</title> | |
| <style type="text/css"> | |
| body { | |
| padding: 20px; | |
| font: 1.5em PT Sans, sans-serif; |
| // Working with various monads in F# | |
| type OptionBuilder() = | |
| member _.Bind(a, f) = Option.bind f a | |
| member _.Return a = Some a | |
| member _.ReturnFrom a = a | |
| member _.Zero () = None | |
| member _.Combine (a, b) = Option.orElseWith b a | |
| member _.Delay f = f |
You have some WASM code in fact.wat that you want to test.
You have installed the WebAssembly reference
interpreter,
and can call it as wasm (or <some_path>/wasm).
| (module | |
| (import "shared" "memory" (memory 1)) | |
| (import "shared" "table" (table 1 anyfunc)) | |
| (elem (i32.const 0) $read1) ;; set table[0] to read1 for indirect calling | |
| (func $read1 (result i32) | |
| i32.const 4 | |
| i32.load) | |
| (func $read0 (result i32) |
| {-# LANGUAGE GADTs, ScopedTypeVariables #-} | |
| {-# LANGUAGE PolyKinds, KindSignatures #-} | |
| {-# LANGUAGE DataKinds, TypeFamilies, TypeOperators #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| data Nat = Z | S Nat | |
| type family (n :: Nat) :+ (m :: Nat) :: Nat | |
| type instance Z :+ m = m | |
| type instance (S n) :+ m = S (n :+ m) |
| (module | |
| (export "fact" (func $fact)) | |
| (func $fact (param $n i32) (result i32) | |
| (local $result i32) | |
| (set_local $result (i32.const 1)) | |
| (if (get_local $n) | |
| (loop $start | |
| (set_local $result (i32.mul (get_local $n) (get_local $result))) | |
| (tee_local $n (i32.sub (get_local $n) (i32.const 1))) |
| (module $simpleallocate | |
| (global $ALIGN_MASK i32 (i32.const 7)) | |
| (global $MAX_SIZE_32 i32 (i32.const 1073741824)) | |
| (global $PAGE_SIZE i32 (i32.const 65536)) | |
| (global $next_free (mut i32) (i32.const 0)) | |
| (func $bytes_to_pages (param $n i32) (result i32) | |
| (i32.add (i32.div_u (local.get $n) | |
| (global.get $PAGE_SIZE)) | |
| (i32.const 1))) |
| (module $evenodd | |
| (export "even" (func $even)) | |
| (export "odd" (func $odd)) | |
| (func $even (param $n i32) (result i32) | |
| get_local $n | |
| i32.const 0 | |
| i32.eq | |
| if (result i32) | |
| i32.const 1 | |
| else |
| data Expr : Type -> Type where | |
| Con : Int -> Expr Int | |
| Add : Expr Int -> Expr Int -> Expr Int | |
| Mult : Expr Int -> Expr Int -> Expr Int | |
| IsZ : Expr Int -> Expr Bool | |
| If : Expr Bool -> Expr t -> Expr t -> Expr t | |
| And : Expr Bool -> Expr Bool -> Expr Bool | |
| Or : Expr Bool -> Expr Bool -> Expr Bool | |
| Tuple : Expr t -> Expr s -> Expr (t,s) | |
| Fst : Expr(t,s) -> Expr t |
I hereby claim:
To claim this, I am signing this object: