{-# LANGUAGE FlexibleInstances #-}-- | A module for data types that have an output file(s) target and/or can reference a target. e.g. The @Javac@ data type might have an output target given by the @-d@ option and references a target by the @-classpath@ option.moduleLastik.Output(Output(..),OutputReference(..),(<=+=>),(<=++=>),(>===>),(>=>=>),outref,(<==>),(<===>))whereimportControl.MonadimportControl.Monad.InstancesimportData.MaybeimportSystem.DirectoryimportLastik.Find-- | A class of data types that have a potential output target.classOutputowhereoutput::o->MaybeFilePathinstanceOutput(MaybeFilePath)whereoutput=idinstanceOutput[FilePath]whereoutput=listToMaybe-- | A class of data types that can reference an output target.classOutputReferencerwherereference::[FilePath]->r->rreference'::r->[FilePath]-- | Adds the given file path to the reference target of the given value.(<=+=>)::(OutputReferencer)=>FilePath-- ^ The file path to add.->r-- ^ The value to add the given file path to.->r-- ^ The value with the given file path added.v<=+=>k=reference(v:reference'k)k-- | Adds the given file paths to the reference target of the given value.(<=++=>)::(OutputReferencer)=>[FilePath]-- ^ The file paths to add.->r-- ^ The value to add the given file paths to.->r-- ^ The value with the given file paths added.v<=++=>k=reference(v++reference'k)k-- | Adds the (potential) output target of the given value to the output target of the given value.(>===>)::(Outputo,OutputReferencer)=>o-- ^ The value with an output target value to add.->r-- ^ The value to add the output target to.->r-- ^ The value after the output target has been added.v>===>w=caseoutputvofNothing->wJusty->y<=+=>w-- | Adds the (potential) output target and output references of the given value to the output target of the given value.(>=>=>)::(Outputo,OutputReferenceo,OutputReferencer)=>o-- ^ The value with an output target and output references to add.->r-- ^ The value to add the output target and output references to.->r-- ^ The value after the output target has been added.v>=>=>w=v>===>(reference'v<=++=>w)-- | Adds the output target to the output reference of the given value.outref::(Outputo,OutputReferenceo)=>o-- ^ The value to add the output target to its output reference.->ooutref=join(>===>)-- | Returns all existing files of the second argument that have a later last-modification time than the latest of all existing files in the first argument.(<==>)::[FilePath]-- ^ The set of file paths to compute the latest modification time.->[FilePath]-- ^ The set of file paths to filter and keep those that have a later modification time.->IO[FilePath]-- ^ The file paths with a later last-modification time than the latest in the first argument.d<==>s=doe<-filterM(\k->liftM2(||)(doesFileExistk)(doesDirectoryExistk))difnullethenreturnselsedofilterM(\z->liftM2(>)(getModificationTimez)(fmapmaximum$mapMgetModificationTimee))s-- | Returns all existing files of the second argument that have a later last-modification time than all files (recursively) in the output target of the the first argument.(<===>)::(Outputo)=>o-- ^ The value to compute the output target and recursively search for the latest last-modification time.->[FilePath]-- ^ The set of file paths to filter and keep those that have a later modification time.->IO[FilePath]-- ^ The file paths with a later last-modification time than the latest in the output target of the first argument.d<===>s=caseoutputdofNothing->returnsJustk->doe<-doesDirectoryExistkifethenfindalwaysalways'k>>=(\t->t<==>s)elsereturns