Skip to content

Commit

Permalink
Switching out Vector.toList (Vector.keepAllMap (...)) with calls to V…
Browse files Browse the repository at this point in the history
…ector.toListKeepAllMap.
  • Loading branch information
huntercaskey committed Jun 7, 2018
1 parent 3b20239 commit d0e2dcc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
7 changes: 3 additions & 4 deletions mlton/atoms/int-size.fun
Expand Up @@ -23,12 +23,11 @@ fun isValidSize (i: int) =
(1 <= i andalso i <= 32) orelse i = 64

val sizes: Bits.t list =
Vector.toList
(Vector.keepAllMap
(Vector.tabulate (65, fn i => if isValidSize i
Vector.toListKeepAllMap (Vector.tabulate (65, fn i =>
if isValidSize i
then SOME (Bits.fromInt i)
else NONE),
fn i => i))
fn i => i)

fun make i = T {bits = i}

Expand Down
2 changes: 1 addition & 1 deletion mlton/atoms/word-size.fun
Expand Up @@ -52,7 +52,7 @@ val allVector = Vector.tabulate (65, fn i =>
then SOME (fromBits (Bits.fromInt i))
else NONE)

val all: t list = Vector.toList (Vector.keepAllMap (allVector, fn so => so))
val all: t list = Vector.toListKeepAllMap (allVector, fn so => so)

val prims = List.map ([8, 16, 32, 64], fromBits o Bits.fromInt)

Expand Down
6 changes: 3 additions & 3 deletions mlton/backend/rssa.fun
Expand Up @@ -1078,15 +1078,15 @@ structure Program =
| Const c => SOME (ApplyArg.Const c)
| Var x => SOME (ApplyArg.Var x)
| _ => NONE
val applyArgs = Vector.keepAllMap (args, getArg)
val applyArgs = Vector.toListKeepAllMap (args, getArg)
datatype z = datatype ApplyResult.t
in
if Vector.length args <> Vector.length applyArgs
if Vector.length args <> List.length applyArgs
then keep ()
else
case (tracePrimApply
Prim.apply
(prim, Vector.toList applyArgs,
(prim, applyArgs,
fn ({var = x, ...}, {var = y, ...}) =>
Var.equals (x, y))) of
Apply (prim, args) =>
Expand Down
39 changes: 19 additions & 20 deletions mlton/elaborate/elaborate-env.fun
Expand Up @@ -456,26 +456,25 @@ structure TypeStr =
let
val extra = ref false
val cons =
Vector.toList
(Vector.keepAllMap
(Cons.dest cons, fn {name, scheme, ...} =>
let
val (tyvars, ty) = Scheme.dest scheme
in
case Type.deArrowOpt ty of
NONE => (extra := true; NONE)
| SOME (arg, _) =>
let
val argScheme =
Scheme.make {canGeneralize = true,
ty = arg,
tyvars = tyvars}
in
case Scheme.checkEquality (argScheme, {layoutPrettyTycon = layoutPrettyTycon}) of
NONE => (extra := true; NONE)
| SOME l => SOME (seq [Ast.Con.layout name, str " of ", l])
end
end))
Vector.toListKeepAllMap (Cons.dest cons, fn {name, scheme, ...} =>
let
val (tyvars, ty) = Scheme.dest scheme
in
case Type.deArrowOpt ty of
NONE => (extra := true; NONE)
| SOME (arg, _) =>
let
val argScheme =
Scheme.make {canGeneralize = true,
ty = arg,
tyvars = tyvars}
in
case Scheme.checkEquality (argScheme, {layoutPrettyTycon = layoutPrettyTycon}) of
NONE => (extra := true; NONE)
| SOME l => SOME (seq [Ast.Con.layout name, str " of ", l])
end
end)

val cons =
if !extra
then List.snoc (cons, str "...")
Expand Down

0 comments on commit d0e2dcc

Please sign in to comment.