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