[GHC] #14770: Allow static pointer expressions to have static pointer free variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[GHC] #14770: Allow static pointer expressions to have static pointer free variables

GHC - devs mailing list
#14770: Allow static pointer expressions to have static pointer free variables
-------------------------------------+-------------------------------------
           Reporter:  TheKing01      |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.2
           Keywords:                 |  Operating System:  Unknown/Multiple
  StaticPointers                     |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Static pointer expressions can not have free variables. For example:

 {{{#!hs
 addPointers :: StaticPtr Int -> StaticPtr Int -> StaticPtr Int
 addPointers x y = static (deRefStaticPtr x + deRefStaticPtr y)
 }}}

 would be invalid, since `x` and `y` are free variables. My proposal would
 be to make this code sample valid. In particular, my proposal is to allow
 free variables in `static` expressions if the free variables of the type
 `StaticPtr a` for some type `a`.

 Let's say that `m` `n` are Static pointers to integers. The serialized
 form would of `addPointers m n` would be:

 A pointer to the code `deRefStaticPtr x + deRefStaticPtr y`

 The serialized form of `m`, associated with `x`.

 The serialized form of `n`, associated with `y`.

 When this is sent over the wire and dereferenced, the other machine would

 Find `m` and `n`'s pointers

 Find the code `deRefStaticPtr x + deRefStaticPtr y`

 Evaluate `deRefStaticPtr x + deRefStaticPtr y`, substituting `m`'s value
 for `x`, and `n`'s value for y.

 The reason this feature would be useful is would let the user modify and
 combine static pointers.

 You might ask "why not let the user create a GADT to do that (like in
 https://hackage.haskell.org/package/distributed-static-0.3.8/docs/Control-
 Distributed-Static.html#t:Static)?" The reason is that then it won't fuse
 (with recreating every fusion rule for that GADT). For example, if `m` is
 `static 7` and `n` is `static 3`, then `addPointers m n` can fuse to
 `static 11`.

 This is more important then it seems. For example, say you have
 `composePointers :: StaticPtr (a -> b) -> StaticPtr (b -> c) -> StaticPtr
 (a -> c)`, and you compose a bunch of pointers. With the GADTS, every
 `composePointers` would be its own node, but with GHC support, it would
 probably fuse.

 In general, dealing with a GADT requires a lot of "glue code" that can be
 eliminated with GHC support. I'm not sure if this proposal makes a
 performance difference (it probably makes it more efficient), but it would
 make code more elegant, cutting out all the glue code.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14770>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14770: Allow static pointer expressions to have static pointer free variables

GHC - devs mailing list
#14770: Allow static pointer expressions to have static pointer free variables
-------------------------------------+-------------------------------------
        Reporter:  TheKing01         |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
                                     |  StaticPointers
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by facundo.dominguez):

 I don't understand how this works yet.

 Static pointers are put in the static pointer table (SPT) before the
 program executes. What is put in the SPT if the static form is allowed to
 have free variables?

 Before executing the program, the values of the free variables might be
 still unknown.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14770#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14770: Allow static pointer expressions to have static pointer free variables

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14770: Allow static pointer expressions to have static pointer free variables
-------------------------------------+-------------------------------------
        Reporter:  TheKing01         |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
                                     |  StaticPointers
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by TheKing01):

 The code surrounding the free variables is put in the SPT. A static
 pointer then points to that code, as well as separate static pointers for
 the free variables. This makes static pointers a recursive data type.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14770#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14770: Allow static pointer expressions to have static pointer free variables

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14770: Allow static pointer expressions to have static pointer free variables
-------------------------------------+-------------------------------------
        Reporter:  TheKing01         |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
                                     |  StaticPointers
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by gershomb):

 * cc: gershomb (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14770#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets