adamc@26: (* Copyright (c) 2008, Adam Chlipala adamc@26: * All rights reserved. adamc@26: * adamc@26: * Redistribution and use in source and binary forms, with or without adamc@26: * modification, are permitted provided that the following conditions are met: adamc@26: * adamc@26: * - Redistributions of source code must retain the above copyright notice, adamc@26: * this list of conditions and the following disclaimer. adamc@26: * - Redistributions in binary form must reproduce the above copyright notice, adamc@26: * this list of conditions and the following disclaimer in the documentation adamc@26: * and/or other materials provided with the distribution. adamc@26: * - The names of contributors may not be used to endorse or promote products adamc@26: * derived from this software without specific prior written permission. adamc@26: * adamc@26: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" adamc@26: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE adamc@26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE adamc@26: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE adamc@26: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR adamc@26: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF adamc@26: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS adamc@26: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN adamc@26: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) adamc@26: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE adamc@26: * POSSIBILITY OF SUCH DAMAGE. adamc@26: *) adamc@26: adamc@26: signature MONO_UTIL = sig adamc@26: adamc@26: structure Typ : sig adamc@26: val mapfold : (Mono.typ', 'state, 'abort) Search.mapfolder adamc@26: -> (Mono.typ, 'state, 'abort) Search.mapfolder adamc@26: adamc@26: val map : (Mono.typ' -> Mono.typ') adamc@26: -> Mono.typ -> Mono.typ adamc@26: adamc@26: val fold : (Mono.typ' * 'state -> 'state) adamc@26: -> 'state -> Mono.typ -> 'state adamc@26: adamc@26: val exists : (Mono.typ' -> bool) -> Mono.typ -> bool adamc@26: end adamc@26: adamc@26: structure Exp : sig adamc@26: datatype binder = adamc@26: NamedT of string * int * Mono.typ option adamc@26: | RelE of string * Mono.typ adamc@26: | NamedE of string * int * Mono.typ * Mono.exp option adamc@26: adamc@26: val mapfoldB : {typ : (Mono.typ', 'state, 'abort) Search.mapfolder, adamc@26: exp : ('typtext, Mono.exp', 'state, 'abort) Search.mapfolderB, adamc@26: bind : 'typtext * binder -> 'typtext} adamc@26: -> ('typtext, Mono.exp, 'state, 'abort) Search.mapfolderB adamc@26: val mapfold : {typ : (Mono.typ', 'state, 'abort) Search.mapfolder, adamc@26: exp : (Mono.exp', 'state, 'abort) Search.mapfolder} adamc@26: -> (Mono.exp, 'state, 'abort) Search.mapfolder adamc@26: adamc@26: val map : {typ : Mono.typ' -> Mono.typ', adamc@26: exp : Mono.exp' -> Mono.exp'} adamc@26: -> Mono.exp -> Mono.exp adamc@26: val mapB : {typ : Mono.typ' -> Mono.typ', adamc@26: exp : 'typtext -> Mono.exp' -> Mono.exp', adamc@26: bind : 'typtext * binder -> 'typtext} adamc@26: -> 'typtext -> (Mono.exp -> Mono.exp) adamc@26: adamc@26: val fold : {typ : Mono.typ' * 'state -> 'state, adamc@26: exp : Mono.exp' * 'state -> 'state} adamc@26: -> 'state -> Mono.exp -> 'state adamc@26: adamc@26: val exists : {typ : Mono.typ' -> bool, adamc@26: exp : Mono.exp' -> bool} -> Mono.exp -> bool adamc@26: end adamc@26: adamc@26: structure Decl : sig adamc@26: datatype binder = datatype Exp.binder adamc@26: adamc@26: val mapfoldB : {typ : (Mono.typ', 'state, 'abort) Search.mapfolder, adamc@26: exp : ('typtext, Mono.exp', 'state, 'abort) Search.mapfolderB, adamc@26: decl : ('typtext, Mono.decl', 'state, 'abort) Search.mapfolderB, adamc@26: bind : 'typtext * binder -> 'typtext} adamc@26: -> ('typtext, Mono.decl, 'state, 'abort) Search.mapfolderB adamc@26: val mapfold : {typ : (Mono.typ', 'state, 'abort) Search.mapfolder, adamc@26: exp : (Mono.exp', 'state, 'abort) Search.mapfolder, adamc@26: decl : (Mono.decl', 'state, 'abort) Search.mapfolder} adamc@26: -> (Mono.decl, 'state, 'abort) Search.mapfolder adamc@26: adamc@26: val fold : {typ : Mono.typ' * 'state -> 'state, adamc@26: exp : Mono.exp' * 'state -> 'state, adamc@26: decl : Mono.decl' * 'state -> 'state} adamc@26: -> 'state -> Mono.decl -> 'state adamc@26: end adamc@26: adamc@26: structure File : sig adamc@26: datatype binder = datatype Exp.binder adamc@26: adamc@26: val mapfoldB : {typ : (Mono.typ', 'state, 'abort) Search.mapfolder, adamc@26: exp : ('typtext, Mono.exp', 'state, 'abort) Search.mapfolderB, adamc@26: decl : ('typtext, Mono.decl', 'state, 'abort) Search.mapfolderB, adamc@26: bind : 'typtext * binder -> 'typtext} adamc@26: -> ('typtext, Mono.file, 'state, 'abort) Search.mapfolderB adamc@26: adamc@26: val mapfold : {typ : (Mono.typ', 'state, 'abort) Search.mapfolder, adamc@26: exp : (Mono.exp', 'state, 'abort) Search.mapfolder, adamc@26: decl : (Mono.decl', 'state, 'abort) Search.mapfolder} adamc@26: -> (Mono.file, 'state, 'abort) Search.mapfolder adamc@26: adamc@26: val mapB : {typ : Mono.typ' -> Mono.typ', adamc@26: exp : 'typtext -> Mono.exp' -> Mono.exp', adamc@26: decl : 'typtext -> Mono.decl' -> Mono.decl', adamc@26: bind : 'typtext * binder -> 'typtext} adamc@26: -> 'typtext -> Mono.file -> Mono.file adamc@26: adamc@96: val map : {typ : Mono.typ' -> Mono.typ', adamc@96: exp : Mono.exp' -> Mono.exp', adamc@96: decl : Mono.decl' -> Mono.decl'} adamc@96: -> Mono.file -> Mono.file adamc@96: adamc@26: val fold : {typ : Mono.typ' * 'state -> 'state, adamc@26: exp : Mono.exp' * 'state -> 'state, adamc@26: decl : Mono.decl' * 'state -> 'state} adamc@26: -> 'state -> Mono.file -> 'state adamc@26: end adamc@26: adamc@26: end