Skip to content
  • Facundo Domínguez's avatar
    Overload the static form to reduce verbosity. · c1efdcc4
    Facundo Domínguez authored and Ben Gamari's avatar Ben Gamari committed
    Static pointers are rarely used naked: most often they are defined at
    the base of a Closure, as defined in e.g. the distributed-closure and
    distributed-static packages. So a typical usage pattern is:
    
        distributeMap (closure (static (\x -> x * 2)))
    
    which is more verbose than it needs to be. Ideally we'd just have to
    write
    
        distributeMap (static (\x -> x * 2))
    
    and let the static pointer be lifted to a Closure implicitly. i.e.
    what we want is to overload static literals, just like we already
    overload list literals and string literals.
    
    This is achieved by introducing the IsStatic type class and changing
    the typing rule for static forms slightly:
    
        static (e :: t) :: IsStatic p => p t
    
    Test Plan: ./validate
    
    Reviewers: austin, hvr, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: simonpj, mboes, thomie
    
    Differential Revision: https://phabricator.haskell.org/D1923
    
    GHC Trac Issues: #11585
    c1efdcc4