-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mass commit in case my laptop bricks again...
- Loading branch information
Showing
15 changed files
with
203 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
library (0.1.0) | ||
signature LIST | ||
structure List | ||
is | ||
$/basis.cm | ||
|
||
src/list.sig | ||
src/list.sml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
signature LIST = | ||
sig | ||
include LIST | ||
|
||
val countWhere : ('a -> bool) -> 'a list -> int | ||
|
||
val foldl : 'a list -> { seed : 'b, step : 'a * 'b -> 'b } -> 'b | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
structure List : LIST = | ||
struct | ||
open LIST | ||
|
||
fun foldl list { seed, step } = List.foldl step seed list | ||
fun foldr list { seed, step } = List.foldr step seed list | ||
|
||
fun takeWhile _ [] = [] | ||
| takeWhile p (x :: xs) = if p x then x :: takeWhile p xs else [] | ||
|
||
fun takeUntil p = takeWhile (not o p) | ||
|
||
fun countWhere predicate list = | ||
raise Fail "not implemented" | ||
|
||
fun bound xs ys a b = | ||
case (xs, ys) of | ||
(x, []) => a | ||
| ([], y) => b | ||
| (_ :: xs, _ :: ys) => recur xs ys a b | ||
|
||
(** | ||
* Returns the list with more elements. | ||
*) | ||
fun max a b = bound a b a b | ||
|
||
(** | ||
* Returns the list with fewer elements. | ||
*) | ||
fun min a b = bound a b b a | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
signature FOLDABLE = | ||
sig | ||
type 'a t | ||
type ('a, 'b) arrow = 'a -> 'b | ||
type 'a monoid = { | ||
zero : 'a, | ||
plus : 'a * 'a -> 'a | ||
} | ||
|
||
val foldMap : 'm monoid -> ('a -> 'm) -> 'a t -> 'm | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(* Reader Monad *) | ||
signature CONFIGURABLE = | ||
sig | ||
type 'a t | ||
type config | ||
|
||
val from : (config -> 'a) -> 'a t | ||
|
||
val get : key -> | ||
|
||
val run : config -> 'a t -> 'a | ||
end | ||
|
||
structure Configurable = | ||
struct | ||
type 'computation t = int | ||
|
||
fun from f = | ||
raise Fail "not implemented" | ||
|
||
fun run config = | ||
end | ||
|
||
Configurable.from (fn config => | ||
|
||
) | ||
|
||
signature COMPILABLE = | ||
sig | ||
type t | ||
|
||
val compile : ConstPool.t -> t -> (Word8Vector.vector, ConstPool.t) Configurable.t | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
structure Index = | ||
struct | ||
type t = int | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
signature INDEXED_INSTR = | ||
sig | ||
type t | ||
|
||
val index : t -> Index.t | ||
val instr : t -> Instr.t | ||
end | ||
|
||
|
||
structure IndexedInstr : INDEXED_INSTR = | ||
struct | ||
type t = (Index.t, Instr.t) | ||
|
||
val fromPair = Fn.id | ||
|
||
fun index (i, _) => i | ||
fun instr (_, i) => i | ||
end |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
signature VERIFIER = | ||
sig | ||
val verify : Instr.t list -> StackLang.t list list | ||
val verify : ('offset * Instr.t) list -> { offset : 'offset, instrs : StackLang.t list } list | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(* | ||
* Write it using the final tagless approach? Is it worth it? | ||
*) | ||
(* structure StackLang = | ||
struct | ||
type t = int | ||
end *) | ||
|
||
|
||
|
||
structure Verifier2 : | ||
sig | ||
val verify : Instr.t list -> StackMap.frame list | ||
end | ||
= | ||
struct | ||
fun verify instrs = | ||
let | ||
fun fold (instr, state) = | ||
raise Fail "not implemented" | ||
|
||
val seed = [] | ||
|
||
val r = List.foldl fold seed instrs | ||
in | ||
raise Fail "not implemented" | ||
end | ||
end |