1 (* Copyright (C) 2015 Matthew Fluet.
2 * Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
10 functor GenericScheme (S: GENERIC_SCHEME_STRUCTS): GENERIC_SCHEME =
18 datatype t = T of {tyvars: tyvar vector,
22 fun make f (T r) = f r
27 fun layout (T {tyvars, ty}) =
29 val ty = Type.layout ty
31 if Vector.isEmpty tyvars
34 align [seq [str "Forall ",
35 Vector.layout Tyvar.layout tyvars,
40 fun apply (T {tyvars, ty}, args) =
41 if Vector.isEmpty tyvars andalso Vector.isEmpty args
42 then ty (* Must special case this, since don't want to substitute
45 else Type.substitute (ty, Vector.zip (tyvars, args))
48 Trace.trace ("GenericScheme.apply", Layout.tuple2 (layout, Vector.layout Type.layout), Type.layout)