Skip to content
  • Ryan Scott's avatar
    Use a ReaderT in TcDeriv to avoid some tedious plumbing · ed7a830d
    Ryan Scott authored
    Addresses point (2) of https://phabricator.haskell.org/D3337#107865.
    
    Before, several functions in `TcDeriv` and `TcDerivInfer` which compute
    an `EarlyDerivSpec` were manually threading through about 10 different
    arguments, which contribute to quite a lot of clutter whenever they need
    to be updated. To minimize this plumbing, and to make it clearer which
    of these 10 values are being used where, I refactored the code in
    `TcDeriv` and `TcDerivInfer` to use a new `DerivM` type:
    
    ```lang=haskell
    type DerivM = ReaderT DerivEnv TcRn
    ```
    
    where `DerivEnv` contains the 10 aforementioned values. In addition to
    cleaning up the code, this should make some subsequent changes planned
    for later less noisy.
    
    Test Plan: ./validate
    
    Reviewers: austin, bgamari
    
    Subscribers: rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3846
    ed7a830d