123456789101112131415161718192021222324252627282930313233343536373839404142434445(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openCAsttype('a,_)thunk=|Value:'a->('a,'b)thunk|Thunk:'aLazy.t->('a,[`thunk])thunktype('a,'b)t=('a,'b)thunkCAst.tletmap_thunk(types)f:(_,s)thunk->(_,s)thunk=function|Valuex->Value(fx)|Thunkk->Thunk(lazy(f(Lazy.forcek)))letget_thunk(types):('a,s)thunk->'a=function|Valuex->x|Thunkk->Lazy.forcekletgetx=get_thunkx.vletmake?locv=CAst.make?loc(Valuev)letdelay?locv=CAst.make?loc(Thunk(Lazy.from_funv))letforcex=CAst.make?loc:x.CAst.loc(Value(get_thunkx.v))letmapfn=CAst.map(funx->map_thunkfx)nletmap_with_locfn=CAst.map_with_loc(fun?locx->map_thunk(funx->f?locx)x)nletmap_from_locf(loc,x)=make?loc(f?locx)letwith_valfn=f(getn)letwith_loc_valfn=f?loc:n.CAst.loc(getn)