Skip to content

Source organisation

sandersn edited this page Nov 8, 2010 · 5 revisions

Caveat: although I am fairly happy with module organisation, all modules expose far too many of their internal details. That’s largely because it’s not a problem yet, and because I haven’t figured out a way to test private functions.

  • Fing/ contains the code.
  • FingTest/ contains the tests.
    • FingTest/Tester.fs contains all of the tests so far. So far each module has a type dedicated to testing it, but all the types are in the same file. This should change some time in the future.
    • FingTest/Script.fsx contains a script that loads Fing for interactive use. This should move somewhere more prominent, probably the root.
  • fparsec/ contains a compatible version of FParsec (0.8 currently).
  • Fing/ contains the code:
    • Types.fs contains the basic types, plus output and canonicalisation (via a process similar to de Bruijn indexing)
      • First is an embarrassing list of hard-coded type aliases for the standard .NET types, eg obj => System.Object.
      • Typar represents type variables: 'a, ^a, _ and ('a or 'b or 'c).
      • Property represents the with get,set syntax available for structural typing of properties.
      • Typ represents types: arrows, tuples, type variables, identifiers, etc.
      • When represnts type constraints: nullable, value type, reference type, structural typing, etc.
      • fold folds a Typ to some other type.
      • map maps a Typ to some other Typ of a similar shape.
      • format returns an F#-syntax string for Typ objects.
      • index renames type variables in a Typ such that variables start from 'a, 'b, 'c ....
    • ParsedTypes.fs contains functions that manipulate Typ objects obtained from user input.
      • dealias converts F# abbreviations like int and obj to their standard .NET types. Using a hard-coded map, which is Fairly Stupid.
    • FSharpTypes.fs contains functions that manipulate Typ objects obtained from FSharp.PowerPack.Metadata.
      • debinarize flattens binary-nested arrows to flat, n-ary ones. Internally, the Metadata powerpack represents arrows as ('a -> ('b -> ('c -> 'd))) even though this is equivalent to ('a -> 'b -> 'c -> 'd). In order to search for incorrect argument orders, I standardised on n-ary arrows rather than binary nested ones.
      • cvt (and supporting functions isArray, dimensions, tryFindConstraint and optionsum) converts FSharp.Powerpack.Metadata.FSharpType objects to Typ objects. This code works for types without constraints, but the constraint conversion code (in convertParam and whenify) is not finished.
    • CSharpTypes.fs contains functions that manipulate Typ objects obtained from System.Reflection.
      • CSharpTypes.fs is empty! It will contain code in the future.
    • Search.cs contains the search code.
      • variants generates all variants of a Typ. For example, tuples and arrows (up to length 5) will search all orders of their arguments.
      • matches determines whether two @Typ@s match.
    • Fing.fs contains the public interface.
      • Result is a search result, with the Typ as well as the matching Metadata FSharpMemberOrVal and its containing FSharpEntity.
      • formatResult formats a Result for console-based output.
      • assemblies is a Set of assemblies to search.
      • types is the list of all types that can be searched for.
      • addReferences adds assembly references to assemblies and calls updateReferences.
      • updateReferences throws away the existing types and refreshes it, including new assembly references.
      • typeFind filters types that match the type passed as a string.
      • nameFind filters types whose DisplayName equals the passed string.
      • search calls typeFind if the passed string contains "->", otherwise nameFind.
      • textSearch formats the sequence returned by search and prints it to standard output.
    • Opt.cs parses command line options.
      • There is, apparently, no standard library for this in .NET?
      • parse parses command line options.
    • Program.cs contains the command line interface code.
    • main is the entry point.
Clone this wiki locally