<div dir="auto"><div dir="auto">Great idea!</div><div dir="auto"><br></div><div>We already have syntax for package imports:<div dir="auto">```</div><div dir="auto">import "bytestring" Data.ByteString</div><div dir="auto">```</div><div dir="auto"><br></div><div dir="auto">Source plugin could probably pull and build package by CAS:</div><div dir="auto">```</div><div dir="auto"><span style="font-family:sans-serif">import "CAS_6ffeacff768590" Data.ByteString</span></div><div dir="auto">```</div><div dir="auto"><br></div>That would reuse existing syntax without confusion. And without inconvenience of having to import expressions one by one.</div><div dir="auto">Or declaring their types.</div><div dir="auto">One could even add CAS hashes to Hackage db.</div><div dir="auto"><br></div><div dir="auto">Wonder if source plugin can add `-package` parameters?</div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, Mar 18, 2020, 13:01  <<a href="mailto:haskell-cafe-request@haskell.org" rel="noreferrer noreferrer" target="_blank">haskell-cafe-request@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Haskell-Cafe mailing list submissions to<br>
        <a href="mailto:haskell-cafe@haskell.org" rel="noreferrer noreferrer noreferrer" target="_blank">haskell-cafe@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:haskell-cafe-request@haskell.org" rel="noreferrer noreferrer noreferrer" target="_blank">haskell-cafe-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:haskell-cafe-owner@haskell.org" rel="noreferrer noreferrer noreferrer" target="_blank">haskell-cafe-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Haskell-Cafe digest..."<br>
Today's Topics:<br>
<br>
   1. Re: Help with async library and killing child processes (YueCompl)<br>
   2. Adding Content-Addressable Storage to GHC (Chris Done)<br>
<br><br><br>---------- Forwarded message ----------<br>From: YueCompl <<a href="mailto:compl.yue@icloud.com" rel="noreferrer noreferrer noreferrer" target="_blank">compl.yue@icloud.com</a>><br>To: Branimir Maksimovic <<a href="mailto:branimir.maksimovic@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">branimir.maksimovic@gmail.com</a>><br>Cc: <a href="mailto:haskell-cafe@haskell.org" rel="noreferrer noreferrer noreferrer" target="_blank">haskell-cafe@haskell.org</a><br>Bcc: <br>Date: Wed, 18 Mar 2020 18:42:56 +0800<br>Subject: Re: [Haskell-cafe] Help with async library and killing child processes<br><div style="word-wrap:break-word;line-break:after-white-space">Um, event processing applications by procedural programmers (part data analyst personnels for some) is a thing in my org, so I'm baking an DSL doing it.<br><div><br><blockquote type="cite"><div>On 2020-03-18, at 18:18, Branimir Maksimovic <<a href="mailto:branimir.maksimovic@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">branimir.maksimovic@gmail.com</a>> wrote:</div><br><div>
  
    
  
  <div><p>That's just library, not built into language. You can do it with
      forkIO as I do it per specifics</p><p>of application.</p><p>Greets,<br>
      Branimir.<br>
    </p>
    <div>On 3/18/20 11:06 AM, YueCompl wrote:<br>
    </div>
    <blockquote type="cite">
      
      No, not to cancel a thread, but the business task on that thread's
      way ahead.  That's what Go's Context is designed for.
      <div>
        <div><br>
          <div>
            <ul>
              <li style="box-sizing:border-box">About <span style="box-sizing:border-box;font-weight:600">Go</span> context from: <a href="https://blog.golang.org/context" rel="nofollow noreferrer noreferrer noreferrer" style="box-sizing:border-box;background-color:initial;color:rgb(3,102,214);text-decoration:none" target="_blank">https://blog.golang.org/context</a></li>
            </ul>
            <blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;color:rgb(106,115,125);border-left-width:0.25em;border-left-style:solid;border-left-color:rgb(223,226,229);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:16px;font-variant-ligatures:normal;background-color:rgb(255,255,255)"><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">At Google, we require
                that Go programmers pass a Context parameter as the
                first argument to every function on the call path
                between incoming and outgoing requests. This allows Go
                code developed by many different teams to interoperate
                well. It provides simple control over timeouts and
                cancelation and ensures that critical values like
                security credentials transit Go programs properly.</p>
              <div style="box-sizing:border-box;margin-top:0px;margin-bottom:0px">Server frameworks that
                want to build on Context should provide implementations
                of Context to bridge between their packages and those
                that expect a Context parameter. Their client libraries
                would then accept a Context from the calling code. By
                establishing a common interface for request-scoped data
                and cancelation, Context makes it easier for package
                developers to share code for creating scalable services.</div>
            </blockquote>
            <div>I (and seems Windows api too) strongly agree that
              cancelling a thread is problematic:</div>
            <div><br>
            </div>
            <div><a href="https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread" rel="noreferrer noreferrer noreferrer" target="_blank">https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread</a></div>
            <div><p style="box-sizing:inherit;margin:1rem 0px 0px;padding:0px;color:rgb(227,227,227);font-family:"Segoe UI",SegoeUI,"Segoe WP","Helvetica Neue",Helvetica,Tahoma,Arial,sans-serif;font-size:16px;font-variant-ligatures:normal;background-color:rgb(23,23,23)"><span style="box-sizing:inherit">TerminateThread</span> is
                a dangerous function that should only be used in the
                most extreme cases. You should call <span style="box-sizing:inherit">TerminateThread</span> only
                if you know exactly what the target thread is doing, and
                you control all of the code that the target thread could
                possibly be running at the time of the termination. For
                example, <span style="box-sizing:inherit">TerminateThread</span> can
                result in the following problems:</p>
              <ul style="box-sizing:inherit;margin:16px 0px 16px 38px;padding:0px;list-style:none;color:rgb(227,227,227);font-family:"Segoe UI",SegoeUI,"Segoe WP","Helvetica Neue",Helvetica,Tahoma,Arial,sans-serif;font-size:16px;font-variant-ligatures:normal;background-color:rgb(23,23,23)">
                <li style="box-sizing:inherit;margin:0px;padding:0px;outline:0px;list-style:outside none disc">If the target thread owns a critical section,
                  the critical section will not be released.</li>
                <li style="box-sizing:inherit;margin:0px;padding:0px;outline:0px;list-style:outside none disc">If the target thread is allocating memory
                  from the heap, the heap lock will not be released.</li>
                <li style="box-sizing:inherit;margin:0px;padding:0px;outline:0px;list-style:outside none disc">If the target thread is executing certain
                  kernel32 calls when it is terminated, the kernel32
                  state for the thread's process could be inconsistent.</li>
                <li style="box-sizing:inherit;margin:0px;padding:0px;outline:0px;list-style:outside none disc">If the target thread is manipulating the
                  global state of a shared DLL, the state of the DLL
                  could be destroyed, affecting other users of the DLL.</li>
              </ul>
              <div><br>
              </div>
            </div>
            <div>
              <blockquote type="cite">
                <div>On 2020-03-18, at 17:16, Branimir
                  Maksimovic <<a href="mailto:branimir.maksimovic@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">branimir.maksimovic@gmail.com</a>>
                  wrote:</div>
                <br>
                <div>
                  
                  <div><p>I'm pretty sure you can't cancel
                      goroutine. Actually I have <br>
                    </p><p>very bad experience with thread
                      cancelation. Therefore flags</p><p>passed via channels/mvars or shared
                      flags are used to stop</p><p>threads. <br>
                    </p><p>Greets,<br>
                      Branimir.<br>
                    </p>
                    <div>On 3/18/20 10:10 AM,
                      YueCompl wrote:<br>
                    </div>
                    <blockquote type="cite">
                      
                      Idiomatic resource leakage prevention in short.
                      <div><br>
                        <div>An app wants to be as responsive
                          to its users as practically feasible, it would
                          try multiple paths to load-balanced resources,
                          and use the first response that come back,
                          then cancel other paths. Cancellation can help
                          reducing vain computation in such
                          architectures, sometimes largely enough.<br>
                          <div><br>
                            <blockquote type="cite">
                              <div>On 2020-03-18, at 16:58,
                                Branimir Maksimovic <<a href="mailto:branimir.maksimovic@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">branimir.maksimovic@gmail.com</a>>
                                wrote:</div>
                              <br>
                              <div>
                                
                                <div><p>What's wrong with forkIO?</p><p>Greets,<br>
                                    Branimir.<br>
                                  </p>
                                  <div>On
                                    3/18/20 9:37 AM, YueCompl via
                                    Haskell-Cafe wrote:<br>
                                  </div>
                                  <blockquote type="cite">
                                    
                                    If not for tight loops or other CPU
                                    intensive tasks, you may be
                                    interested in Edh, which introduces
                                    Go's goroutine to GHC runtime. But
                                    Edh threads add much higher overhead
                                    on top of GHC threads, so there's a
                                    price to pay for simplicity of end
                                    programmer's job.
                                    <div><br>
                                    </div>
                                    <div>It's briefly described
                                      at <a href="https://github.com/e-wrks/edh/tree/master/Tour#program--threading-model" rel="noreferrer noreferrer noreferrer" target="_blank">https://github.com/e-wrks/edh/tree/master/Tour#program--threading-model</a> .
                                      This is very new and I'm right now
                                      actively working on it for PoC of
                                      an STM powered in-memory graph
                                      database implementation.</div>
                                    <div><br>
                                    </div>
                                    <div>Best regards,</div>
                                    <div>Compl<br>
                                      <div><br>
                                        <blockquote type="cite">
                                          <div>On 2020-03-18,
                                            at 11:15, Niklas Hambüchen
                                            <<a href="mailto:mail@nh2.me" rel="noreferrer noreferrer noreferrer" target="_blank">mail@nh2.me</a>>
                                            wrote:</div>
                                          <br>
                                          <div>
                                            <div>I've you're
                                              new to async, also check
                                              out my recent rework of
                                              the docs that talk about
                                              this topic specifically:<br>
                                              <br>
                                              <a href="https://github.com/simonmar/async/pull/105/files" rel="noreferrer noreferrer noreferrer" target="_blank">https://github.com/simonmar/async/pull/105/files</a><br>
                                              <br>
                                              (To be available in the
                                              next release of async.)<br>
_______________________________________________<br>
                                              Haskell-Cafe mailing list<br>
                                              To (un)subscribe, modify
                                              options or view archives
                                              go to:<br>
                                              <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
                                              Only members subscribed
                                              via the mailman list are
                                              allowed to post.</div>
                                          </div>
                                        </blockquote>
                                      </div>
                                      <br>
                                    </div>
                                    <br>
                                    <fieldset></fieldset>
                                    <pre>_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
                                  </blockquote>
                                </div>
_______________________________________________<br>
                                Haskell-Cafe mailing list<br>
                                To (un)subscribe, modify options or view
                                archives go to:<br>
                                <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
                                Only members subscribed via the mailman
                                list are allowed to post.</div>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                </div>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
    </blockquote>
  </div>

</div></blockquote></div><br></div><br><br><br>---------- Forwarded message ----------<br>From: Chris Done <<a href="mailto:haskell-cafe@chrisdone.com" rel="noreferrer noreferrer noreferrer" target="_blank">haskell-cafe@chrisdone.com</a>><br>To: <a href="mailto:haskell-cafe@haskell.org" rel="noreferrer noreferrer noreferrer" target="_blank">haskell-cafe@haskell.org</a><br>Cc: <br>Bcc: <br>Date: Wed, 18 Mar 2020 11:21:29 +0000<br>Subject: [Haskell-cafe] Adding Content-Addressable Storage to GHC<br><u></u><div><div>Hi all,<br></div><div><div><br></div><div>Is there any effort or designs ongoing to add CAS (content-addressable storage) to GHC, as in Unison? <<br></div><div><a href="https://www.unisonweb.org/docs/tour/" rel="noreferrer noreferrer noreferrer" target="_blank">https://www.unisonweb.org/docs/tour/</a>><br></div><div><br></div><div>== The idea ==</div><div><br></div><div>The summary of the idea is simply that top-level declarations can be addressed by a hash of their contents. Recursive definitions are transformed into the worker/wrapper to eliminate the self-referencing issue of hashing.<br></div><div><br></div><div>== Why I want this ==</div><div><br></div><div>There are lots of advantages to this, but the one that excites me the most is that we can move to running tests, especially property tests, at compile-time.<br></div><div><br></div><div>The main downside to running tests at compile-time, as seen done with template-haskell is that you will re-run tests every time the module is recompiled, making your dev cycle slower. However, if your tests are keyed upon CAS hashes, then those hashes are only invalidated when individual declarations actually change. This means the re-running of tests becomes granular at the declaration-level.  When a single test completes, either successfully or not, you can cache the result and lookup the result next time, using e.g. the SHA512 of the expression evaluated.<br></div><div><div><br></div></div><div>Therefore you could change a single function in a library and it would only re-run the tests that are actually affected, rather than running all the tests in the whole module, and rather than the more typical approach which is running ALL tests in a test suite just because one thing changed.<br></div><div><br></div><div>If you can couple tests with code then you can avoid the decoupling of code from the tests.<br></div><div><br></div><div>== Implementation approaches ==<br></div><div><br></div><div>There are various ways to implement this with varying degrees of satisfaction:<br></div><div><br></div><div>1. Use TH: reify declarations, inspect the AST, and produce a SHA512. Use ambient values such as the GHC version, instances in scope, extensions, ghc options, etc. With TH, I'm confident that you can only achieve an imperfect hash because I doubt that all information is available to TH.<br></div><div><br></div><div>Names that come from external packages could be treated as CAS'd at the scope of the package's installed hash. Ideally, you could have granularity into other packages. But it's not a necessity if you just want caching for your current development package.</div><div><br></div><div>2. Use a source plugin. A source plugin is already capable of accessing all GHC context information, so this might lead to more of a perfect hash.<br></div><div><br></div><div>3. Add it to GHC directly. Exposing a `expressionSHA512 :: Exp -> ByteString` could be one imaginary way to access this information. With such a function you could implement caching of fine-grained tests.<br></div><div><br></div><div>A related discussion is the deterministic builds: <a href="https://gitlab.haskell.org/ghc/ghc/wikis/deterministic-builds" rel="noreferrer noreferrer noreferrer" target="_blank">https://gitlab.haskell.org/ghc/ghc/wikis/deterministic-builds</a><br></div><div><br></div><div>Anyone else exploring this?</div><div><br></div><div>Cheers,<br></div><div><br></div><div>Chris</div><div><br></div><div><br></div><div><br></div></div><div><br></div></div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" rel="noreferrer noreferrer noreferrer" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div></div></div>