Skip to content
  • Simon Marlow's avatar
    Change the block representation (version bumped to 3.9.0.0) · c6c6e93e
    Simon Marlow authored
    This patch implements the change to the block representation as agreed
    with Norman.  I also took the liberty of doing a lot of refactoring
    and rearrangement to make the code organisation more logical.  A
    summary of the API changes is below.
    
    Summary of refactorings:
    
     - Compiler.Hoopl.Block contains the Block datatype and all the
       operations on Blocks.  It seemed like a good idea to collect all
       this stuff together in one place.
    
     - Compiler.Hoopl.Graph now has the operations on Graphs.
    
     - Compiler.Hoopl.Util and Compiler.Hoopl.GraphUtil are no more; their
       contents have been moved to other homes.  (and a bit of duplicated
       functionality has been removed).
    
     - I removed the newtypes around Unique and Label, these are now just
       type synonyms.  The newtype wrappers were costing some performance in
       GHC, because in cases like mapToList the newtype isn't optimised away.
    
       This change might be controversial.  Feel free to complain.
    
    Other changes:
    
     - Optimisations to the Dataflow algorithms.  I'm not actually using
       this implementation of Dataflow in GHC any more, instead I have a
       local copy specialised to our monad, for speed.  Nevertheless I've
       put some of the optimisations I'm using in the GHC version into the
       generic library version too.
    
    Summary of API changes:
    
    ADDED
    
     - IsMap(mapInsertWith, mapFromListWith)
    
     - mapGraphBlocks
       (was previously called graphMapBlocks, and not exported)
    
     - mapBlock'
       (strict version of mapBlock)
    
     - New API for working with Blocks:
    
        -- ** Predicates on Blocks
      , isEmptyBlock
    
        -- ** Constructing blocks
      , emptyBlock, blockCons, blockSnoc
      , blockJoinHead, blockJoinTail, blockJoin, blockJoinAny
      , blockAppend
    
        -- ** Deconstructing blocks
      , firstNode, lastNode, endNodes
      , blockSplitHead, blockSplitTail, blockSplit, blockSplitAny
    
        -- ** Modifying blocks
      , replaceFirstNode, replaceLastNode
    
        -- ** Converting to and from lists
      , blockToList, blockFromList
    
        -- ** Maps and folds
      , mapBlock, mapBlock', mapBlock3'
      , foldBlockNodesF, foldBlockNodesF3
      , foldBlockNodesB, foldBlockNodesB3
    
    REMOVED
    
     - mapMaybeO, mapMaybeC
       (no need: we have Functor instances)
    
     - Block constructors are no longer exported
       (use the block API instead)
    
     - blockToNodeList, blockToNodeList', blockToNodeList'', blockToNodeList'''
       (use the block API instead)
    
     - tfFoldBlock, ScottBlock, scottFoldBlock, fbnf3,
       BlockResult(..), lookupBlock,
       (I don't know what any of these are for, if they're still important
       we could reinstate)
    
    CHANGED
    
     - Compiler.Hoopl.GHC is now Compiler.Hoopl.Internals and exports some
       more stuff.
    
     - Label is not a newtype; type Label = Unique
     - Unique is not a newtype: type Unique = Int
       (these newtypes were adding overhead)
    
     - blockMapNodes3 is now mapBlock3'
    
     - Lots of internal refactoring and tidying up
    c6c6e93e
This project is licensed under the BSD 3-Clause "New" or "Revised" License. Learn more