module Descript.Build.Read.Read ( Dep , DepResult , DepResultT , DirtyDep , DirtyDepT , Depd , DirtyDepd , DepResolver , DFile , readSrc , readInputValIn , readOutputValIn ) where import Descript.Build.Read.Parse import qualified Descript.BasicInj.Data.Value.In as BasicInj.In import qualified Descript.BasicInj.Data.Value.Out as BasicInj.Out import qualified Descript.BasicInj as BasicInj import qualified Descript.Sugar as Sugar import Descript.Misc import Core.Control.Monad.Trans import Control.Monad.Trans.Class -- Note: If there are multiple dependency requiring values, replace with -- custom @Gen...@ instances which contain all those values as -- dependencies. Create a wrapper for 'BasicInj.validate' which takes -- all the dependencies dirty, passes the 'BasicInj' dependencies to -- 'BasicInj.validate', and returns the (ok) result with all of the -- dependencies but removes the dirty wrapper (probably reimplement -- 'BasicInj.validate's control structure and call 'BasicInj.validate'' -- directly). type Dep = BasicInj.Dep type DepResult = BasicInj.DepResult type DepResultT u = BasicInj.DepResultT u type DirtyDep an = BasicInj.DirtyDep an type DirtyDepT an u = BasicInj.DirtyDepT an u type Depd a an = BasicInj.Depd a an type DirtyDepd a an = BasicInj.DirtyDepd a an type DepResolver u = BasicInj.DepResolver u type DFile u = BasicInj.DFile u -- | Parses source, resolves its dependencies, and refines it. readSrc :: (Monad u) => DFile u -> ParseResultT u (DirtyDepd BasicInj.Source SrcAnn) readSrc (DFile rsvr sfile') = refineR =<< resolveR rsvr =<< parseR sfile' where refineR = pure . Sugar.refineDDepd resolveR rsvr' = lift . Sugar.resolve rsvr' parseR = hoist . parse readInputValIn :: AbsScope -> BasicInj.RecordCtx () -> SFile -> ParseResult (BasicInj.In.Value SrcAnn) readInputValIn scope ctx = fmap (Sugar.refineInputValIn scope ctx) . parseInputVal readOutputValIn :: AbsScope -> BasicInj.RecordCtx () -> BasicInj.In.Value () -> SFile -> ParseResult (BasicInj.Out.Value SrcAnn) readOutputValIn scope ctx in' = fmap (Sugar.refineOutputValIn scope ctx in') . parseOutputVal