1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950(*
* Generic transformers: plugins.
* Copyright (C) 2016-2022
* Dmitrii Kosarev aka Kakadu
* St.Petersburg State University, JetBrains Research
*)(** {i Foldr} plugin: fold all values in a type.
Essentially is a stub that chains inherited attribute thorough all values
in the value
For type declaration [type ('a,'b,...) typ = ...] it will create a transformation
function with type
[('s -> 'a -> 's) ->
('s -> 'b -> 's) ->
... ->
's -> ('a,'b,...) typ -> 's ]
*)openPpxlibopenGTCommonlettrait_name="foldr"moduleMake(AstHelpers:GTHELPERS_sig.S)=structopenAstHelpersmoduleFoldl=Foldl.Make(AstHelpers)lettrait_name=trait_nameclassginitial_argstdecls=object(self:'self)inheritFoldl.ginitial_argstdeclsmethodtrait_name=trait_namemethodjoin_args~locdo_typ~init(xs:(string*core_type)list)=ListLabels.fold_left~f:(funacc(name,typ)->Exp.app_list~loc(do_typtyp)[acc;Exp.sprintf~loc"%s"name])~init(List.revxs)endletcreate=(newg:>Foldl.P.plugin_constructor)endletregister()=Expander.register_plugintrait_name(moduleMake:Plugin_intf.MAKE)let()=register()