Strafunski-StrategyLib-5.0.0.3: Library for strategic programming

Portabilityportable
Stabilityexperimental
MaintainerRalf Laemmel, Joost Visser
Safe HaskellNone

Data.Generics.Strafunski.StrategyLib.ChaseImports

Contents

Description

This module is part of StrategyLib, a library of functional strategy combinators, including combinators for generic traversal. This module defines a generic algorithm for import chasing. This algorithm is not strategic in nature itself, but usually it will be instantiated with strategic functions for a particular object language.

Synopsis

Type synonym

type ChaseName = StringSource

The type of names of chaseable things. Synonym of String.

Generic import chasing

chaseWithSource

Arguments

:: [FilePath]

path (list of directories to search)

-> [ChaseName]

todo (list of modules still to find)

-> [ChaseName]

done (list of modules already found)

-> accu

initial (start value of accumulator)

-> ([FilePath] -> ChaseName -> IO (Either cu String))

parse (function that attempt to find and parse a module)

-> (cu -> [ChaseName])

imports (function that extracts imports from a parse result)

-> (ChaseName -> [ChaseName] -> cu -> accu -> IO accu)

on module (function that computes a new accumulator from a parse result)

-> (ChaseName -> accu -> IO accu)

on missing (function that computes a new accumulator value when parsing failed)

-> IO accu

result (accumulated value)

A generic import chasing function. The type of the final result is a parameter, which will usually be instantiated to a list of parsed modules.

chaseFileSource

Arguments

:: [FilePath]

path (directories to search)

-> String

base name

-> [String]

possible extensions

-> IO String

contents of file

Read a file from a number of possible directories, given a base name and a list of possible extensions. Returns the content of the file it found.

findFileSource

Arguments

:: [FilePath]

path (directories to search)

-> String

base name

-> [String]

possible extensions

-> IO FilePath

contents of file

Find a file in a number of possible directories, given a base name and a list of possible extensions. Returns the full name of the file it found.