<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Summer of Haskell News</title>
        <link>http://summer.haskell.org</link>
        <description><![CDATA[Newest Summest of Haskell posts]]></description>
        <atom:link href="http://summer.haskell.org/news.xml" rel="self"
                   type="application/rss+xml" />
        <lastBuildDate>Sun, 08 Dec 2024 00:00:00 UT</lastBuildDate>
        <item>
    <title>Summer of Haskell 2024 Results</title>
    <link>http://summer.haskell.org/news/2024-12-08-summer-of-haskell-2024-results.html</link>
    <description><![CDATA[<p>Another Google Summer of Code has come and gone and we were thrilled to take part!</p>
<p><a href="https://blog.haskell.org/gsoc-2024/">Please see our post on blog.haskell.org for a summary of the results.</a></p>]]></description>
    <pubDate>Sun, 08 Dec 2024 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2024-12-08-summer-of-haskell-2024-results.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Summer of Haskell 2023 Results</title>
    <link>http://summer.haskell.org/news/2024-01-20-summer-of-haskell-2023-results.html</link>
    <description><![CDATA[<p>On behalf of the Haskell.org committee, I’m pleased to announce the results of
the Summer of Haskell 2023. Many impressive and valuable contributions were
made to the Haskell ecosystem which I’m excited to share with you in this post.
I’d like to extend a big thank you to the sponsors that made this program
possible: <a href="https://haskell.foundation/">The Haskell Foundation</a>,
<a href="https://www.kadena.io/">Kadena</a>, <a href="https://www.janestreet.com/">Jane Street</a>,
<a href="https://www.holmusk.com/">Holmusk</a>, <a href="https://mlabs.city/">MLabs</a>,
<a href="https://flipstone.com/">Flipstone</a>, Gershom Bazerman, and Edward Kmett.
Gratitude is also due to the wonderful mentors who kindly donated their time to
helping bring these projects to fruition and fostering the next generation of
Haskellers.</p>
<p>I also want to mention that <a href="https://summer.haskell.org/ideas.html">we are currently in need of idea
submissions</a> for the upcoming Google
Summer of Code 2024! This program depends on having a quality list of ideas, so
please consider submitting any you might have (ideally before Feb. 4th).</p>
<p>Without further ado, what follows is a summary of the work that was completed
under the Summer of Haskell 2023.</p>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
Support for Resolve Functionality in HLS
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Nathan Maxson
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Michael Peyton Jones
</td>
</tr>
</table>
<p>Nathan Maxson contributed support for <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction_resolve">resolve
functionality</a>
to <a href="https://haskell-language-server.readthedocs.io/en/latest/#">HLS</a>. He has
also updated a number of HLS plugins to utilize this functionality, thus
reducing CPU and memory usage and improving speed. The plugins that have been
updated in this way are <code>overloaded-record-dot</code>, <code>hlint-plugin</code>,
<code>explicit-imports</code>, <code>refine-imports</code>, <code>type-lenses</code>, <code>explicit-records</code>, and
<code>class-plugin</code>.</p>
<p><b>Relevant code contributions</b></p>
<ul>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3621" class="uri">https://github.com/haskell/haskell-language-server/pull/3621</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3678" class="uri">https://github.com/haskell/haskell-language-server/pull/3678</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3688" class="uri">https://github.com/haskell/haskell-language-server/pull/3688</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3658" class="uri">https://github.com/haskell/haskell-language-server/pull/3658</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3679" class="uri">https://github.com/haskell/haskell-language-server/pull/3679</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3682" class="uri">https://github.com/haskell/haskell-language-server/pull/3682</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3729" class="uri">https://github.com/haskell/haskell-language-server/pull/3729</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3743" class="uri">https://github.com/haskell/haskell-language-server/pull/3743</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3750" class="uri">https://github.com/haskell/haskell-language-server/pull/3750</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3769" class="uri">https://github.com/haskell/haskell-language-server/pull/3769</a></li>
</ul>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
Cabal File Support for HLS
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Jana Chadt
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Fendor
</td>
</tr>
</table>
<p>Jana Chadt worked on improving support for Cabal files in HLS. The work has
been summarized in <a href="https://gist.github.com/VeryMilkyJoe/268448ff8daea9f467930c771e60b9c8">this
gist</a>,
which includes links to relevant PRs and issues. There is also <a href="https://discourse.haskell.org/t/hsoc-hls-cabal-file-support/7331">a blog
post</a>
detailing the new HLS functionality.</p>
<p><b>Relevant code contributions</b></p>
<ul>
<li><a href="https://github.com/haskell/vscode-haskell/pull/618" class="uri">https://github.com/haskell/vscode-haskell/pull/618</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3268" class="uri">https://github.com/haskell/haskell-language-server/pull/3268</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3766" class="uri">https://github.com/haskell/haskell-language-server/pull/3766</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3761" class="uri">https://github.com/haskell/haskell-language-server/pull/3761</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3778" class="uri">https://github.com/haskell/haskell-language-server/pull/3778</a></li>
</ul>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
HLS: Goto 3rd Party Definition
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Elodie Lander
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Zubin Duggal
</td>
</tr>
</table>
<p>Elodie Lander worked on allowing the HLS goto definition functionality to work
with definitions from outside of the current project. Although primarily
focused on HLS, this work involves contributions to other key Haskell
infrastructure: GHC, Cabal, HieDb, and haskell/actions.</p>
<p><b>Relevant code contributions</b></p>
<ul>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3676" class="uri">https://github.com/haskell/haskell-language-server/pull/3676</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3725" class="uri">https://github.com/haskell/haskell-language-server/pull/3725</a></li>
<li><a href="https://github.com/haskell/haskell-language-server/pull/3749" class="uri">https://github.com/haskell/haskell-language-server/pull/3749</a></li>
<li><a href="https://github.com/wz1000/HieDb/pull/57" class="uri">https://github.com/wz1000/HieDb/pull/57</a></li>
<li><a href="https://github.com/wz1000/HieDb/pull/56" class="uri">https://github.com/wz1000/HieDb/pull/56</a></li>
<li><a href="https://github.com/wz1000/HieDb/pull/55" class="uri">https://github.com/wz1000/HieDb/pull/55</a></li>
<li><a href="https://github.com/wz1000/HieDb/pull/60" class="uri">https://github.com/wz1000/HieDb/pull/60</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9019" class="uri">https://github.com/haskell/cabal/pull/9019</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9244" class="uri">https://github.com/haskell/cabal/pull/9244</a></li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11083" class="uri">https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11083</a></li>
<li><a href="https://github.com/haskell/actions/pull/290" class="uri">https://github.com/haskell/actions/pull/290</a></li>
</ul>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
Standardize GHC’s Error Dump in JSON Format
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Ben Bellick
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Aaron Allen
</td>
</tr>
</table>
<p>Ben Bellick contributed a new <a href="https://github.com/benbellick/tech-proposals/blob/specify-json-dump/proposals/0000-specify-dump-json.md">well-defined JSON interface for GHC diagnostic
emissions</a>,
which will be available via a new <code>-fdiagnostics-as-json</code> flag. The existing
under-specified <code>-ddump-json</code> flag has been deprecated in favor of this new
interface. Additionally, Ben made valuable contributions to the effort of
converting GHC error messages to use the new structured representation.</p>
<p><b>Relevant code contributions</b></p>
<ul>
<li><a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11093" class="uri">https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11093</a></li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10574" class="uri">https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10574</a></li>
</ul>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
Teaching Weeder About Type Classes
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Vasily Sterekhov
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Oliver Charles
</td>
</tr>
</table>
<p>Vasily Sterekhov implemented support for detecting unused type class instances
in <a href="https://github.com/ocharles/weeder?tab=readme-ov-file#weeder">Weeder</a>,
along with several other significant improvements. See the <a href="https://discourse.haskell.org/t/weeder-2-7-released-with-type-class-instances-and-more/7356">Weeder 2.7 release
notes</a>
for details.</p>
<p><b>Relevant code contributions</b></p>
<ul>
<li><a href="https://github.com/ocharles/weeder/pull/126" class="uri">https://github.com/ocharles/weeder/pull/126</a></li>
<li><a href="https://github.com/ocharles/weeder/pull/133" class="uri">https://github.com/ocharles/weeder/pull/133</a></li>
<li><a href="https://github.com/ocharles/weeder/pull/136" class="uri">https://github.com/ocharles/weeder/pull/136</a></li>
<li><a href="https://github.com/ocharles/weeder/pull/132" class="uri">https://github.com/ocharles/weeder/pull/132</a></li>
<li><a href="https://github.com/ocharles/weeder/pull/137" class="uri">https://github.com/ocharles/weeder/pull/137</a></li>
<li><a href="https://github.com/ocharles/weeder/pull/134" class="uri">https://github.com/ocharles/weeder/pull/134</a></li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10701" class="uri">https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10701</a></li>
</ul>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
Structured Errors for cabal-install
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Suganya Arun
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Gershom Bazerman
</td>
</tr>
</table>
<p>Suganya Arun implemented structured errors for Cabal, including the assignment
of a unique code to each error which can be then be referenced on the <a href="https://errors.haskell.org/">Haskell
Error Index</a>. You can read more about the results
and challenges of the project in <a href="https://summerofhaskellstructerrors.blogspot.com/2023/10/soh2023-structured-errors-and-error.html">this blog
post</a>.</p>
<p><b>Relevant code contributions</b></p>
<ul>
<li><a href="https://github.com/haskell/cabal/pull/9018" class="uri">https://github.com/haskell/cabal/pull/9018</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9143" class="uri">https://github.com/haskell/cabal/pull/9143</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9162" class="uri">https://github.com/haskell/cabal/pull/9162</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9191" class="uri">https://github.com/haskell/cabal/pull/9191</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9219" class="uri">https://github.com/haskell/cabal/pull/9219</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9276" class="uri">https://github.com/haskell/cabal/pull/9276</a></li>
<li><a href="https://github.com/haskell/cabal/pull/9324" class="uri">https://github.com/haskell/cabal/pull/9324</a></li>
</ul>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
Maximally Decoupling Haddock and GHC
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Gregory Baimetov
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Laurent P. Rene de Cotret
</td>
</tr>
</table>
<p>Gregory Baimetov contributed to the effort towards <a href="https://github.com/haskellfoundation/tech-proposals/pull/44">decoupling GHC and
Haddocks</a>.
Although the original goal proved to be too ambitious, he has produced a
<a href="https://github.com/Greg8128/proto-docser-hs">prototype of a JSON serialization for the Haskell
AST</a> as well as a <a href="https://docs.google.com/document/d/1nykZgSi9k_jP1N4ZVZhSdce2jFpRdwNNT3X2YQLF9vo">document
explaining the difficulties
encountered</a>,
which should be of value to future work on this issue.</p>
<hr />
<table>
<tr>
<td>
<b>Project</b>
</td>
<td>
Representing Pattern
</td>
</tr>
<tr>
<td>
<b>Contributor </b>
</td>
<td>
Saachi Kaup
</td>
</tr>
<tr>
<td>
<b>Mentor</b>
</td>
<td>
Alex Mclean
</td>
</tr>
</table>
<p>Saachi Kaup worked with various libraries to explore pattern visualization,
drawing connections to the traditional mandalas common in Southeast Asian art.
She put together <a href="https://tidalcycles.org/blog/blog_topic_mandalas">a blog post on the Tidal
website</a> describing her
process and showcasing some of the images that were produced. You can also view
the <a href="https://gitlab.com/Saachi_Kaup/TurtlePatterns">code repository</a>.</p>]]></description>
    <pubDate>Sat, 20 Jan 2024 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2024-01-20-summer-of-haskell-2023-results.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Summer of Haskell 2023 Project Selections</title>
    <link>http://summer.haskell.org/news/2023-05-14-summer-of-haskell-2023-project-selections.html</link>
    <description><![CDATA[<p>Summer of Haskell 2023 is off to a great start and we have some exciting news
to share! We received many quality proposals from which to choose and our
mentors have made their selections. Thanks to our <a href="/index.html#sponsors">incredibly generous sponsors</a>,
we have secured funding for nine projects! Without further ado, here are the
accepted projects:</p>
<ul>
<li><a href="#cabal-file-support-for-hls">Cabal file support for HLS</a></li>
<li><a href="#implement-resolution-methods-in-hls">Implement Resolution Methods in HLS</a></li>
<li><a href="#goto-definition-for-third-party-libraries-in-hls">Goto Definition for Third-Party Libraries in HLS</a></li>
<li><a href="#teaching-weeder-about-type-class-instances">Teaching Weeder About Type Class Instances</a></li>
<li><a href="#standardize-ghcs-error-dump-in-json-format">Standardize GHC’s Error Dump in JSON Format</a></li>
<li><a href="#maximally-decoupling-haddock-and-ghc">Maximally Decoupling Haddock and GHC</a></li>
<li><a href="#representing-pattern">Representing Pattern</a></li>
<li><a href="#improving-calligraphy">Improving Calligraphy</a></li>
<li><a href="#structured-errors-and-error-codes-for-cabal-install">Structured Errors and Error Codes for cabal-install</a></li>
</ul>
<h2 id="cabal-file-support-for-hls">Cabal file support for HLS</h2>
<p>Contributor: Jana Chadt<br />
Mentor: Fendor<br />
Abstract:</p>
<blockquote>
<p>The goal of this proposal is to provide cabal file support for Haskell Language
Server. I have been working on the cabal plugin for Haskell Language server
during various Hackathons since 2021, implementing
<a href="https://github.com/haskell/haskell-language-server/pull/2047">formatting</a> and
<a href="https://github.com/haskell/haskell-language-server/pull/3268">code-completion</a>
of cabal files and I would like to be able to commit to working on the plugin
full time this summer.</p>
</blockquote>
<h2 id="implement-resolution-methods-in-hls">Implement Resolution Methods in HLS</h2>
<p>Contributor: Nathan Maxson<br />
Mentor: Michael Peyton Jones<br />
Abstract:</p>
<blockquote>
<p>With “codeAction/resolve” and “codeLens/reslove” the language server protocol
has added methods to allow language servers to delay some of the work it needs
to do for codeActions and codeLens until it is actually needed, allowing the
server significant savings in both memory and cpu usage. This proposal is to
add both of these methods to the haskell-language-server, allowing plugins to
call them at will. In addition I propose adding support for the resolve methods
to some haskell language server’s plugins.</p>
</blockquote>
<h2 id="goto-definition-for-third-party-libraries-in-hls">Goto Definition for Third-Party Libraries in HLS</h2>
<p>Contributor: Elodie Lander<br />
Mentor: Zubin Duggal<br />
Abstract:</p>
<blockquote>
<p>Making goto definition work for third party libraries is of interest to me as a
Haskell developer because it is a feature I would like to use in my Haskell
development. In fact, it is the feature that might finally motivate me to use
HLS in my own projects. My Haskell workflow has usually involved a lot of
switching back and forth between my editor and Hackage documentation in the
browser. I believe that being able to see third party library definitions in my
editor would reduce this back and forth significantly and help increase my
efficiency as a Haskell developer.</p>
</blockquote>
<h2 id="teaching-weeder-about-type-class-instances">Teaching Weeder About Type Class Instances</h2>
<p>Contributor: Vasily Sterekhov<br />
Mentor: Ollie Charles<br />
Abstract:</p>
<blockquote>
<p>A frequent complaint about Haskell is the lack of tooling. This proposal aims
to contribute to improving the situation by addressing a particular limitation
of Weeder, a tool for detecting dead code. In the process, this may involve
proposing minor additions to hie files to GHC, which may benefit other similar
projects working in the same area.</p>
</blockquote>
<h2 id="standardize-ghcs-error-dump-in-json-format">Standardize GHC’s Error Dump in JSON Format</h2>
<p>Contributor: Ben Bellick<br />
Mentor: Aaron Allen<br />
Abstract:</p>
<blockquote>
<p>GHC is currently undergoing a long scale project to move to a more structured
error representation by treating errors as values. An additional useful feature
that can be made available is to dump a JSON representation of warnings/errors.
An experimental implementation of this feature exists when GHC is invoked with
-ddump-json, although this is an unfinished command which suffers from the
following:</p>
<ul>
<li>it is non-standardized</li>
<li>it does not leverage new structured error representation</li>
<li>previous implementation issues led to a hard-coding of output to stdout</li>
</ul>
<p>There is an opportunity to benefit consumers of GHC output and to improve Haskell
tooling infrastructure. Some examples of possible use-cases for down stream
consumers can be found
<a href="https://gitlab.haskell.org/ghc/ghc/-/issues/19278">here</a>. Not all consumers of
Haskell’s error messages intend on doing so via the GHC API, and such a
standardized JSON output enables a larger set of developers to expand the error
tooling in the Haskell ecosystem. I am also personally excited to help with
this project because I love Haskell and want to make a contribution to one of
its crowning achievements–GHC. I am especially interested in any improvements
which enable outside consumers to better understand/process the internals of
the compiler.</p>
</blockquote>
<h2 id="maximally-decoupling-haddock-and-ghc">Maximally Decoupling Haddock and GHC</h2>
<p>Contributor: Gregory Baimetov<br />
Mentor: Laurent P. René de Cotret<br />
Abstract:</p>
<blockquote>
<p>In practice, development and usage of Haddock is strongly coupled to the
internals of the Glasgow Haskell Compiler (GHC). One concrete example of this
coupling is the fact that Haddock makes use of the GHC parser itself.
Therefore, if Haddock was compiled using GHC version X, it might not be able to
parse the source code of a Haskell program written for GHC version Y &gt; X.</p>
<p>This strong coupling between GHC and Haddock slows down Haddock development and
prevents Haddock from being better integrated in other tools, such as Hackage,
the Haskell Language Server, or Hoogle.</p>
</blockquote>
<h2 id="representing-pattern">Representing Pattern</h2>
<p>Contributor: Saachi Kaup<br />
Mentor: Alex McLean<br />
Abstract:</p>
<blockquote>
<p>Using Haskell’s advanced type system to map the structures in Tidal Cycles to
the underlying shapes of Mandala art and produce beautiful visualisations.</p>
</blockquote>
<h2 id="improving-calligraphy">Improving Calligraphy</h2>
<p>Contributor: Dominic Mills<br />
Mentor: Luis Morillo Najarro<br />
Abstract:</p>
<blockquote>
<p>Calligraphy, a tool for visualizing Haskell projects, faces the challenges of
developing and maintaining Haskell tooling due to the constantly evolving
nature of the language and its implementation in GHC.</p>
<p>In light of these challenges, the primary aim of this Summer of Haskell project
is to enhance the Calligraphy tool to provide visualizations that are both
simple and easy to use. This will be done by modularizing the Calligraphy tool
into its various parts such as the calligraphy-gui, calligraphy-graphviz,
calligraphy-cli, and calligraphy-fgl. In addition to keeping it up-to-date with
GHC releases.</p>
</blockquote>
<h2 id="structured-errors-and-error-codes-for-cabal-install">Structured Errors and Error Codes for cabal-install</h2>
<p>Contributor: Suganya Arun<br />
Mentor: Gershom Bazerman<br />
Abstract:</p>
<blockquote>
<p>The https://errors.haskell.org/ site provides an index that maps error codes in
haskell tooling to documentation. GHC, ghcup, and stack have all begin to
implement support for structured errors that have assigned codes. This project
is to refactor the cabal codebase to also provide structured errors rather than
mere strings, and also assign cabal errors corresponding codes that can be
added to the error index.</p>
</blockquote>]]></description>
    <pubDate>Sun, 14 May 2023 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2023-05-14-summer-of-haskell-2023-project-selections.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Google Summer of Code in 2022</title>
    <link>http://summer.haskell.org/news/2022-02-01-gsoc-changes-2022.html</link>
    <description><![CDATA[<p>Google Summer of Code (GSoC) is a global, online program focused on bringing new
contributors to open-source software development. GSoC Contributors work with an
open-source organization on a 12+ week programming project under the guidance of
mentors. As in previous years, Haskell.org will be applying to join this
program as open-source organization. However, some changes have been made!</p>
<figure>
<img src="/images/2022-02-01-gsoc.png" alt="GSoC Banner" />
<figcaption aria-hidden="true">GSoC Banner</figcaption>
</figure>
<h2 id="who-can-join">Who can join</h2>
<p>In 2022, the program will be addressed to all newcomers of open source that are
18 years and older. GSoC will no longer be solely focused on university students
or recent graduates - people that are at various stages of their career, recent
career changers, self-taught, those returning to the workforce, etc., are
welcome to join. Those changes should better fulfill the needs of open source
communities and provide more flexibility to both projects and contributors.</p>
<h2 id="time-frames">Time frames</h2>
<p>Organizers are aware that not everyone can devote an entire summer to
coding. Offered projects are available in multiple sizes: medium (~175 hours)
and large (~350 hours). There’s an availability to join a 12-week program or
extend the deadline - up to 22 weeks.</p>
<h2 id="projects-ideas-submissions">Projects ideas submissions</h2>
<p>Are you working on a Haskell project, and you could use the help of a student
during the summer? Consider contributing it as an idea here! Send a pull request
to our <a href="https://github.com/haskell-org/summer-of-haskell">github repository</a>
(<a href="https://github.com/haskell-org/summer-of-haskell/blob/ba41af89efe18a2383163e80156cc900e443e461/content/ideas/stylish-haskell-ghc-lib-parser.md">example from 2020</a>).
If you just want to discuss a possible idea, don’t hesitate to
<a href="/contact.html">get in touch with us</a>
or/and read through the
<a href="https://google.github.io/gsocguides/">student/contributor guide</a>.</p>
<h2 id="resources">Resources</h2>
<p>We encourage you to explore
<a href="https://summerofcode.withgoogle.com/">GSoC’s webpage</a>,
and you can learn more on the
<a href="https://developers.google.com/open-source/gsoc/faq">FAQ website</a>.
All the updates about this year’s GSoC edition can be found in
<a href="https://opensource.googleblog.com/2021/11/expanding-google-summer-of-code-in-2022.html">this blogpost</a>.</p>
<h2 id="tldr">TL;DR</h2>
<p>GSoC 2022: OSS projects, developed during Summer (from June to
September/November) for newcomers that are 18 years and older and want to spend
175 - 350 hours on coding activities, with a mentor’s support.</p>]]></description>
    <pubDate>Tue, 01 Feb 2022 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2022-02-01-gsoc-changes-2022.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Haskell.org GSoC results for 2021</title>
    <link>http://summer.haskell.org/news/2021-09-23-final-results.html</link>
    <description><![CDATA[<p><a href="https://summerofcode.withgoogle.com/">Google Summer of Code</a> made some changes this year: projects were effectively
part-time projects. This means that the projects had to be somewhat smaller in
scope. We only received 10 slots from Google this year; which is fewer than
last year.</p>
<p>Despite that, all our 10 slots were successful! This is the first that has
happened in the history of <a href="https://haskell.org">Haskell.org</a>’s participation in the program.
Some of these are high-profile and will benefit a lot of users in the ecosystem,
which is super exciting.</p>
<ol type="1">
<li><p><strong>Enhanced figure support in pandoc</strong><br />
Student: Aner Lucero<br />
Mentors: tarleb<br />
<a href="https://argent0.github.io/posts/2021/pandoc-gsoc.html">Student report</a></p>
<blockquote>
<p>Google summer of code was a great way to expand my involvement with the
haskell community and to test my knowledge working on one of haskell’s
most used apps.</p>
</blockquote></li>
<li><p><strong>Gradually Typed Hasktorch</strong><br />
Student: Julius Marozas<br />
Mentors: Torsten Scholak<br />
<a href="https://gist.github.com/jul1u5/7c5fadb51a9c5f8d7f2a722d6071c1da">Student report</a></p></li>
<li><p><strong>Dhall bindings to TOML configuration language</strong><br />
Student: Marcos Lerones<br />
Mentors: Gabriella Gonzalez, Simon Jakobi<br />
<a href="https://dev.to/marcosjlr/google-summer-of-code-summary-dhall-bindings-to-csv-4g0f">Student report</a></p></li>
<li><p><strong>Haskell in CodeMirror 6</strong><br />
Student: Olivian Cretu<br />
Mentors: Chris Smith<br />
<a href="https://github.com/odc19/haskell_code_mirror">Student repo</a></p></li>
<li><p><strong>Fixing ihaskell-widgets</strong><br />
Student: David Davó<br />
Mentors: James Brock, Vaibhav Sagar<br />
<a href="https://gsoc21.ddavo.me/">Student report</a></p>
<blockquote>
<p>Three years ago, I started learning Haskell and functional programming. As
I had recently started using Jupyter Notebooks in other projects, I wanted
to try using them with Haskell to take notes and do the course homework. A
few weeks in, I noticed I couldn’t use the widgets, but I didn’t give it
much thought. Three years later, this summer, I’ve had the opportunity to
fix it, while learning a lot in the process.</p>
<p>That’s what open source is about.</p>
</blockquote></li>
<li><p><strong>TidalCycles API and editor plugin</strong><br />
Student: Martin Gius<br />
Mentors: Alex McLean<br />
<a href="https://github.com/polymorphicengine/tidal-gui/blob/main/README.md">Student report</a></p></li>
<li><p><strong>Haskell Language Server: Symbol Renaming</strong><br />
Student: Oliver Madine<br />
Mentors: Pepeiborra<br />
<a href="https://gist.github.com/OliverMadine/96927f88b6e5e7890e5179559089166c">Student report</a></p>
<blockquote>
<p>Working on the Haskell Language Server (HLS) was my first time using
Haskell in production. While navigating through different areas of the
tooling infrastructure, the community was supportive in helping me develop
my understanding.</p>
<p>Specifically, my project involved exploring hie-bios and the GHC API to
create a symbol renaming plugin. Overall, the work was engaging, and I was
able to substantially improve my development skills with the help of my
mentor!</p>
</blockquote></li>
<li><p><strong>Support call hierarchy in Haskell Language Server</strong><br />
Student: Lei Zhu<br />
Mentors: Javier Neira, Pepeiborra<br />
<a href="https://github.com/July541/GSoC-2021">Student report</a></p>
<blockquote>
<p>Haskell community is warm and friendly to everyone, no matter you are
a beginner or an expert. This summer, I am more familiar with
haskell-language-server and GHC itself. Thank haskell.org and GSoC
for providing this opportunity!</p>
</blockquote></li>
<li><p><strong>Visualization Libraries for ghc-debug</strong><br />
Student: Ethan Tsz Hang Kiang<br />
Mentors: Matthew Pickering<br />
<a href="https://zyklotomic.github.io/blog/gsoc_2021_final_eval.html">Student report</a></p></li>
<li><p><strong>TOML Support in dhall-haskell</strong><br />
Student: Julio Grillo<br />
Mentors: Gabriella Gonzalez, Simon Jakobi<br />
<a href="https://gist.github.com/ear7h/78265c4755adc01fa6e6a19e3307ef4d">Student report</a></p></li>
</ol>
<p>We hope that Google hosts the program in 2022; and in that case we plan to apply
again. If you have ideas for projects that students could work on, we’ll be
using the same format as the years before – <a href="/ideas.html">this page</a> has more
information on how to submit an idea.</p>
<p>Thanks a lot to everyone involved!</p>]]></description>
    <pubDate>Thu, 23 Sep 2021 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2021-09-23-final-results.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Haskell.org GSoC results for 2020</title>
    <link>http://summer.haskell.org/news/2020-10-12-final-results.html</link>
    <description><![CDATA[<p><a href="https://haskell.org">Haskell.org</a> took part in <a href="https://summerofcode.withgoogle.com/">Google Summer of Code</a> again in 2020. Despite
unfortunately receiving less slots from Google this year, we had a number of
highly successful projects. In this blogpost, I’ve collected all write-ups and
reports from the students for your convenience.</p>
<ol type="1">
<li><p><strong>SPECIALIZABLE GHC pragma</strong><br />
Student: Francesco Gazzetta <span class="citation" data-cites="fgaz">@fgaz</span><br />
Mentors: Carter Schonwald, Andreas Klebinger, chessai<br />
<a href="https://github.com/fgaz/gsoc/blob/master/2020/report.md">Student report</a></p></li>
<li><p><strong>Add primops to expand the (boxed) array API</strong><br />
Student: buggymcbugfix<br />
Mentors: andrewthad, Andreas Klebinger, chessai<br />
<a href="https://github.com/buggymcbugfix/not-not-a-blog/blob/master/blog/2020-08-28-gsoc/post.md">Student report</a></p></li>
<li><p><strong>Build-integration and Badges for Hackage</strong><br />
Student: Shubham Awasthi<br />
Mentors: hvr, Gershom Bazerman<br />
<a href="https://awasthishubh.github.io/gsoc-2020-haskell/report.html">Student report</a></p></li>
<li><p><strong>Building the Haskell Language Server and more</strong><br />
Student: Luke Lau<br />
Mentors: Alan Zimmerman, Pepe Iborra, Zubin Duggal<br />
<a href="https://gist.github.com/bubba/22719e8854c728bc726d1a6cfb9ded81">Student report</a></p></li>
<li><p><strong>Custom Dataloader for Hasktorch</strong><br />
Student: Andre Daprato<br />
Mentors: Austin Huang, Adam Paszke, Torsten Scholak, Junji Hashimoto</p></li>
<li><p><strong>Documentation generator for the Dhall configuration language</strong><br />
Student: German Robayo<br />
Mentors: Profpatsch, Gabriel Gonzalez, sjakobi<br />
<a href="https://dev.to/german1608/season-finale-dhall-documentation-generator-2lfn">Student report</a></p></li>
<li><p><strong>Finish the package candidate workflow for Hackage</strong><br />
Student: Sitao Chen<br />
Mentors: hvr, Gershom Bazerman<br />
<a href="https://sitaochen.github.io/hackage-server/">Student report</a></p>
<blockquote>
<p>This summer, I have participated in Google Summer of Code with Haskell
org and worked on Hackage candidate UI and workflow. Without previous
experience in open source development, I was able to grasp a large
codebase and its structure in a short period with the help of my
mentors. Besides, I got a chance to learn about how to make API calls
and how to improve UI using Haskell in a formal setting. This
experience helps me have a better understanding of packages workflow
management and web services in Haskell. I wish I can contribute again
in the future!</p>
</blockquote></li>
<li><p><strong>Functional Machine Learning Algorithms for Music Generation</strong><br />
Student: Elizabeth Wilson<br />
Mentors: Alex McLean, Austin Huang, Torsten Scholak<br />
<a href="https://blog.tidalcycles.org/autonomous-live-coding-summer-of-haskell-project/">Student report</a></p></li>
<li><p><strong>Multiple Home Packages for GHC</strong><br />
Student: fendor<br />
Mentors: Zubin Duggal, John Ericson, Matthew Pickering<br />
<a href="https://mpickering.github.io/ide/posts/2020-10-12-multiple-home-units.html">Student report</a></p>
<blockquote>
<p>Haskell IDE Engine was the first open source project I ever contributed
to, and over time, it became of a project of passion for me. Over the
months I dove deeper into Haskell tooling, until I got the chance to work
on GHC itself in this year’s Google Summer of Code! I worked on this
project to improve the tooling situation for Haskell, as well as improving
the IDE experience by implementing features needed by both.</p>
<p>The project itself proved to be challenging, mainly because of my
unfamiliarity with the GHC code base. However, with the help of my helpful
mentors, I was able to overcome the challenges and learned a lot about
GHC. I am glad I had the chance to work on this project, although I did
not accomplish everything I wanted to, yet.</p>
</blockquote></li>
<li><p><strong>Number Field Sieves</strong><br />
Student: Federico Bongiorno<br />
Mentors: Sergey Vinokurov, Andrew Lelechenko<br />
<a href="https://github.com/folidota/GSoC2020/blob/master/GSoC2020/NumberFieldSieves.pdf">Student report</a></p></li>
<li><p><strong>Optimising Haskell developer tool performance using OpenTelemetry</strong><br />
Student: Michalis Pardalos<br />
Mentors: Dmitry Ivanov, Matthew Pickering</p>
<blockquote>
<p>My project was about adding support for opentelemetry tracing into ghcide,
the core component of haskell-language-server. I had very little
experience with open-source development, or the internals of haskell
and ghc before this project and I can say for sure that this has
changed. Aside from working on ghcide itself, I also had to submit patches
to haskell-opentelemetry, implementing features necessary for this
project. When the project was blocked by a ghc bug, I also took this as an
opportunity to dive into ghc and fix it myself, which I found incredibly
rewarding and consider a valuable experience.</p>
<p>Even though I ended up running out of time and not finishing everything
I hoped for in the project, I can say for sure that it was a positive
experience which I would absolutely recommend.</p>
</blockquote></li>
<li><p><strong>Update stylish-haskell to use ghc-lib-parser</strong><br />
Student: Beatrice Vergani<br />
Mentors: Jasper Van der Jeugt, lukaszgolebiewski, Paweł Szulc<br />
<a href="https://www.beatricevergani.com/posts/gsoc2020/">Student report</a></p></li>
</ol>
<p>Google will be hosting GSoC again in 2021, and of course we plan to apply again.
If you have ideas for projects that students could work on, we’ll be using the
same format as the years before – <a href="/ideas.html">this page</a> has more information
on how to submit an idea.</p>
<p>Thanks a lot to everyone involved!</p>]]></description>
    <pubDate>Mon, 12 Oct 2020 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2020-10-12-final-results.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Call for Ideas for 2020</title>
    <link>http://summer.haskell.org/news/2020-01-12-call-for-ideas.html</link>
    <description><![CDATA[<p><a href="https://summerofcode.withgoogle.com/">Google Summer of Code</a> will take place again in 2020!</p>
<p><a href="https://haskell.org">Haskell.org</a> has been able to take part in this program in the past two years,
and we’d like to keep this momentum up since it greatly benefits the community.</p>
<p>Google is not extremely open about what factors it considers for applications
from organizations, but they have stated multiple times that a well-organized
ideas list is crucial. For that, we would like to count on all of you again.</p>
<p>If you are the maintainer or a user of a Haskell project, and you have an
improvement in mind which a student could work on during the summer, please
submit an idea here:</p>
<p><a href="https://summer.haskell.org/ideas.html" class="uri">https://summer.haskell.org/ideas.html</a></p>
<p>For context, Google Summer of Code is a program where Google sponsors students
to work on open-source projects during the summer. Haskell.org has taken part
in this program in 2006-2015, and 2018-2019. Many important improvements to
the ecosystem have been the direct or indirect result of Google Summer of Code
projects, and it has also connected new people with the existing community.</p>
<p>Projects should benefit as many people as possible – e.g. an improvement to GHC
will benefit more people than an update to a specific library or tool, but both
are definitely valid. New libraries and applications written in Haskell, rather
than improvements to existing ones, are also accepted. Projects should be
concrete and small enough in scope such that they can be finished by a student
in three months. Past experience has shown that keeping projects “small” is
almost always a good idea.</p>]]></description>
    <pubDate>Sun, 12 Jan 2020 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2020-01-12-call-for-ideas.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Haskell.org GSoC results for 2019</title>
    <link>http://summer.haskell.org/news/2020-01-10-final-results.html</link>
    <description><![CDATA[<p><a href="https://haskell.org">Haskell.org</a> took part in <a href="https://summerofcode.withgoogle.com/">Google Summer of Code</a> again in 2019, and we
had some really successful projects!</p>
<p>Unfortunately; this summary is less successful – I meant to contact the
students immediately after the summer, but that mail never went through and
I failed to follow up on it – my apologies.</p>
<p>In either case, I still wanted to list the successful projects here for
posterirty. I reached out to the students again and will be updating this
post with more information and quotes as they get back to me.</p>
<ol type="1">
<li><p><strong>A language server for Dhall</strong><br />
Student: <a href="https://github.com/EggBaconAndSpam/eggbaconandspam.github.io/blob/master/posts/2019-08-22-final-report.md">Frederik Ramcke</a><br />
Mentors: Luke Lau, Gabriel Gonzalez</p></li>
<li><p><strong>A stronger foundation for interactive Haskell tooling</strong><br />
Student: dxld<br />
Mentors: Alan Zimmerman, Matthew Pickering</p></li>
<li><p><strong>Automated requirements checking as a GHC plugin</strong><br />
Student: <a href="https://starsandspira.ls/gsoc.html">Daniel Marshall</a><br />
Mentors: Chris Smith, chessai, Alphalambda</p></li>
<li><p><strong>Extending Alga</strong><br />
Student: <a href="https://adithyaov.github.io/">O V Adithya Kumar</a><br />
Mentors: Andrey Mokhov, Jasper Van der Jeugt, Alexandre Moine</p></li>
<li><p><strong>Extending Hasktorch With RNNs and Encoder-Decoder</strong><br />
Student: AdLucem<br />
Mentors: Austin Huang, Junji Hashimoto, Sam Stites</p></li>
<li><p><strong>Functional Machine Learning with Hasktorch: Produce Functional Machine
Learning Model Reference Implementations</strong><br />
Student: Jesse Sigal<br />
Mentors: Austin Huang, idontgetoutmuch, Junji Hashimoto, Sam Stites</p></li>
<li><p><strong>Hadrian Optimisation</strong><br />
Student: ratherforky<br />
Mentors: Andrey Mokhov, Neil Mitchell</p></li>
<li><p><strong>Implementing Chebyshev polynomial approximations in Haskell: Having the
speed and precision of numerics with complex, non-polynomial functions.</strong><br />
Student: <a href="https://www.cs.mcgill.ca/~dto4/projects/gsoc.html">Deifilia To</a><br />
Mentors: tmcdonell, idontgetoutmuch, Albert Krewinkel</p></li>
<li><p><strong>Improving Hackage Matrix Builder as a Real-world Fullstack Haskell
Project</strong><br />
Student: Andika Riyandi (Rizary)<br />
Mentors: Herbert Valerio Riedel, Robert Klotzner</p></li>
<li><p><strong>Improving HsYAML Library</strong><br />
Student: <a href="https://vijayphoenix.github.io/blog/gsoc-the-conclusion/">Vijay Tadikamalla</a><br />
Mentors: Herbert Valerio Riedel, Michał Gajda</p></li>
<li><p><strong>Issue-Wanted Web Application</strong><br />
Student: Rashad Gover<br />
Mentors: Veronika Romashkina, Dmitrii Kovanikov</p></li>
<li><p><strong>More graph algorithms for Alga</strong><br />
Student: <a href="/news/2019-08-26-alga-results.html">Vasily Alferov</a><br />
Mentors: Andrey Mokhov, Alexandre Moine</p></li>
<li><p><strong>Property-based testing stateful programs using
quickcheck-state-machine</strong><br />
Student: Kostas Dermentzis<br />
Mentors: stevana, Robert Danitz</p></li>
<li><p><strong>Putting hie Files to Good Use</strong><br />
Student: Zubin Duggal<br />
Mentors: Alan Zimmerman, Matthew Pickering</p></li>
<li><p><strong>Upgrading hs-web3 library</strong><br />
Student: amany9000<br />
Mentors: Alexander Krupenkin, Thomas Dietert</p></li>
</ol>
<p>Thanks to everyone involved!</p>]]></description>
    <pubDate>Fri, 10 Jan 2020 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2020-01-10-final-results.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Student Blog: Results for Bipartite Graphs Project</title>
    <link>http://summer.haskell.org/news/2019-08-26-alga-results.html</link>
    <description><![CDATA[<p>I am a student at Summer of Haskell this year, and that’s my final post. This
post is written to sum up the work I’ve done. Although this post is a formal
requirement of GSoC, I wanted to publish it here to reach a wider audience.</p>
<h2 id="my-proposal">My proposal</h2>
<p>When you apply to Summer of Code, you write a proposal. The proposal is a
document in which you describe your ideas on the chosen project. It should be a
clear, detailed text with suggestions on every subtask. The proposal should also
include a timeline, in which you estimate the time you intend to spend on each of those subtasks.</p>
<p>I chose <a href="https://summer.haskell.org/ideas.html#algebraic-graphs">this</a> project
for my summer. In my proposal, I drafted all the algorithms mentioned in the
list and suggested a few more. I published this part of my proposal as a Github
gist <a href="https://gist.github.com/vasalf/c246171d8ebd784487624853566b8df2">there</a>.</p>
<p>I don’t suggest this gist as a complete example of a good proposal: it’s only a part of
the document I submitted. You should also include some information about you,
together with the timeline. Communication with your future mentors is also a
significant part of the application.</p>
<p>However, as I mentioned in
<a href="https://summer.haskell.org/news/2019-05-29-alga-introduction.html">one of my previous posts</a>,
another student ended up doing the part suggested in the ideas list. So my task is to
introduce bipartite graphs.</p>
<p>This task was my idea. I mentioned it in my proposal. I meant that finding
maximum matchings in bipartite graphs should be easily implemented when we have
algorithms for finding maximum flows in networks. Kuhn’s algorithm is an
application of the Ford-Fulkerson algorithm, and the Hopcroft-Karp algorithm is
an application of Dinic’s algorithm.</p>
<p>However, this option is not the best. Both algorithms have specialized
implementations that work times faster. So my task for this summer was to
introduce bipartite graphs and special functions for working with them.</p>
<h2 id="what-ive-done">What I’ve done</h2>
<p>I made four pull requests to Alga this summer. Each pull request represents a
separate task and summarizes the work of several weeks.</p>
<p>Each PR contains the actual implementation, tests, and documentation. The whole
project is release-ready after merging each one of them. I put the tests in the
<code>test/</code> directory. The documentation for each function and datatype precedes the
declaration. After release, it will compile to beautiful Haddock file like
<a href="http://hackage.haskell.org/package/algebraic-graphs-0.4/docs/Algebra-Graph.html">this</a>.</p>
<h2 id="part-i.-definition-and-properties.">Part I. Definition and properties.</h2>
<p><strong>Link to PR:</strong> <a href="https://github.com/snowleopard/alga/pull/207" class="uri">https://github.com/snowleopard/alga/pull/207</a></p>
<p>In this part, I defined the <code>Bipartite.AdjacencyMap</code> datatype and added many
functions to work with adjacency maps.</p>
<p>The datatype represents a map of vertices into their neighbours. I defined it as
two maps:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">AdjacencyMap</span> a b <span class="ot">=</span> <span class="dt">BAM</span> {</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ot">    leftAdjacencyMap ::</span> <span class="dt">Map.Map</span> a (<span class="dt">Set.Set</span> b),</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="ot">    rightAdjacencyMap ::</span> <span class="dt">Map.Map</span> b (<span class="dt">Set.Set</span> a)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
<p>The properties are based on the existing
<a href="http://hackage.haskell.org/package/algebraic-graphs-0.4/docs/Algebra-Graph.html">properties</a>
of graphs in Alga.</p>
<h2 id="part-ii-testing-bipartiteness">Part II: Testing bipartiteness</h2>
<p><strong>Link to PR:</strong> <a href="https://github.com/snowleopard/alga/pull/218" class="uri">https://github.com/snowleopard/alga/pull/218</a></p>
<p>There is a folklore algorithm that checks if a given graph is bipartite. The
task to implement this algorithm in Haskell was a little challenging for me.</p>
<p>I finished up with the following definition of the function:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ot">detectParts ::</span> <span class="dt">Ord</span> a <span class="ot">=&gt;</span> <span class="dt">AM.AdjacencyMap</span> a <span class="ot">-&gt;</span> <span class="dt">Either</span> (<span class="dt">OddCycle</span> a) (<span class="dt">AdjacencyMap</span> a a)</span></code></pre></div>
<p>It is known that a graph is bipartite if and only if it contains no cycles of
odd length. This function either finds an odd cycle or returns a partition.</p>
<p>The implementation is so exciting that I wrote a whole
<a href="https://summer.haskell.org/news/2019-07-26-testing-bipartiteness.html">post</a>
about it. I explained the reason I needed monad transformers there and made some
interesting benchmarks that pointed me to use the explicit <code>INLINE</code> directive.</p>
<h2 id="wip-part-iii.-graph-families.">[WIP] Part III. Graph families.</h2>
<p><strong>Link to the unfinished PR</strong>: <a href="https://github.com/snowleopard/alga/pull/226" class="uri">https://github.com/snowleopard/alga/pull/226</a></p>
<p>Some families of graphs are bipartite: simple paths, even cycles, trees,
bicliques, etc. The task is to provide a simple method to construct all those
graphs.</p>
<p>The most exciting part of this task was to provide type-safe implementations.
For example, only cycles of even length are bipartite. And speaking of paths, we
should provide a method for constructing paths of vertices of two different
types.</p>
<p>The <code>circuit</code> definition for constructing graphs containing one even cycle is
simple:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ot">circuit ::</span> (<span class="dt">Ord</span> a, <span class="dt">Ord</span> b) <span class="ot">=&gt;</span> [(a, b)] <span class="ot">-&gt;</span> <span class="dt">AdjacencyMap</span> a b</span></code></pre></div>
<p>For the paths, I added a special type for alternating lists:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">List</span> a b <span class="ot">=</span> <span class="dt">Nil</span> <span class="op">|</span> <span class="dt">Cons</span> a (<span class="dt">List</span> b a)</span></code></pre></div>
<p>So the <code>path</code> definition is:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ot">path ::</span> (<span class="dt">Ord</span> a, <span class="dt">Ord</span> b) <span class="ot">=&gt;</span> <span class="dt">List</span> a b <span class="ot">-&gt;</span> <span class="dt">AdjacencyMap</span> a b</span></code></pre></div>
<p>As for now, the PR is almost merge-ready, only several small comments need fixes.</p>
<h2 id="wip-part-iv.-hopcroft-karp-algorithm-for-maximum-matchings">[WIP] Part IV. Hopcroft-Karp algorithm for maximum matchings</h2>
<p><strong>Link to the unfinished PR</strong>: <a href="https://github.com/snowleopard/alga/pull/229" class="uri">https://github.com/snowleopard/alga/pull/229</a></p>
<p>This algorithm is the fastest one for maximum matchings in bipartite graphs. The
implementation is rather straightforward.</p>
<p>However, there is an aspect of this PR I’d like to share there.</p>
<p>I implemented the following function:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ot">augmentingPath ::</span> (<span class="dt">Ord</span> a, <span class="dt">Ord</span> b) <span class="ot">=&gt;</span> <span class="dt">Matching</span> a b</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>                                 <span class="ot">-&gt;</span> <span class="dt">AdjacencyMap</span> a b</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>                                 <span class="ot">-&gt;</span> <span class="dt">Either</span> (<span class="dt">VertexCover</span> a b) (<span class="dt">List</span> a b)</span></code></pre></div>
<p>Given a matching in a graph, it returns either an augmenting path for the
matching or a vertex cover of the same size, thus proving that the given
matching is maximum. As both outcomes can be easily verified, this helps to
write perfect tests that ensure that the matching returned by my function is
maximum indeed.</p>
<p>This PR still needs some work. The reason is that two different implementations
behave weirdly on the benchmarks.</p>
<h2 id="results">Results</h2>
<p>I wrote a lot of Haskell this summer. This gave me a lot of experience in this
language. Although there’s still work to be done, I’m satisfied with the
results I got.</p>
<p>I adore the way functional programs are developed. I was surprised to know how
popular testing (QuickCheck) and benchmarking (Criterion) frameworks are
organized. And preciseness of the documentation makes the work a lot easier.</p>]]></description>
    <pubDate>Mon, 26 Aug 2019 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2019-08-26-alga-results.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>
<item>
    <title>Student Blog: Testing Bipartiteness with Monad Transformers</title>
    <link>http://summer.haskell.org/news/2019-07-26-testing-bipartiteness.html</link>
    <description><![CDATA[<p>I am a student at Summer of Haskell this year and this is my second post on
this platform. In my previous
<a href="https://summer.haskell.org/news/2019-05-29-alga-introduction.html">post</a> I
gave a brief explanation of my task. Now that I finished the “routine”
part of adding the necessary data types and manipulation functions, I’m here to
tell you about my implementation of the algorithm for testing bipartiteness of
graphs.</p>
<p>A graph is called bipartite if its vertices can be split into two parts in
such way that there are no edges inside one part. While testing graph on
tripartiteness is NP-hard, there is a linear algorithm that tests graph on
bipartiteness and restores the partition.</p>
<h2 id="vertex-on-your-side">Vertex On Your Side</h2>
<p>The algorithm is usually one of the first graph algorithms given in any
university course. The idea is rather straightforward: we try to assign
vertices to the left or right part in some way, and when we get a conflict, we
claim that the graph is not bipartite.</p>
<p>First, we assign some vertex to the left part. Then, we can confidently
say that all neighbours of this vertex should be assigned to the right part.
Then, all neighbours of this vertex should be assigned to the left part, and so
on. We continue this until all the vertices in the connected component are
assigned to some part, then we repeat the same action on the next connected
component, and so on.</p>
<p>If there is an edge between vertices in the same part, one can easily find an
odd cycle in the graph, hence the graph is not bipartite. Otherwise, we have
the partition, hence the graph is bipartite.</p>
<p>There are two common ways of implementing this algorithm in linear time: using
<a href="https://en.wikipedia.org/wiki/Depth-first_search">Depth-First Search</a> or
<a href="https://en.wikipedia.org/wiki/Breadth-first_search">Breadth-First Search</a>.
We usually select DFS for this algorithm in imperative languages. The reason is
that DFS implementation is a little bit simpler. I selected DFS, too, as a
traditional way.</p>
<p>So, now we came to the following scheme. We go through the vertices in DFS
order and assign them to parts, flipping the part when going through an edge.
If we try to assign some vertex to some part and see that it is already
assigned to another part, then we claim that the graph is not bipartite. When
all vertices are assigned to parts and we’ve looked through all edges, we have
the partition.</p>
<h2 id="the-purity-turned-upside-down">The Purity Turned Upside Down</h2>
<p>In Haskell, all computations are supposed to be <em>pure</em>. Still, if it was
<em>really</em> so, we wouldn’t be able to print anything to the console. And what I
find most funny about pure computations is that they are so lazy that there is
no pure reason to compute anything.</p>
<p>Monads are the Haskell way to express computations with <em>effects</em>. I’m not
going to give a complete explanation of how they work here, but I find
<a href="http://learnyouahaskell.com/a-fistful-of-monads">this one</a> very nice and
clear.</p>
<p>What I <strong>do</strong> want to notice there is that while some monads, like <code>IO</code>, are
implemented through some deep magic, others have simple and pure
implementations. So the entire computation in these monads is pure.</p>
<p>There are many monads that express all kinds of effects. It is a very beautiful
and powerful theory: they all implement the same interface. We will talk about
the three following monads:</p>
<ul>
<li><code>Either e a</code> — a computation that returns value of type <code>a</code> or throws an
error of type <code>e</code>. The behaviour is very much like exceptions in imperative
languages and the errors may be caught. The main difference is that this monad
is fully logically implemented in the standard library, while in imperative
languages it is usually implemented by the operating system or virtual machine.</li>
<li><code>State s a</code> — a computation that returns value of type <code>a</code> and has an access
to a modifiable state of type <code>s</code>.</li>
<li><code>Maybe a</code>. A <code>Monad</code> instance for <code>Maybe</code> expresses a computation that can be
at any moment interrupted with returning <code>Nothing</code>. But we will mostly speak
of <code>MonadPlus</code> instance, which expresses a vice versa effect: this is a
computation which can be at any moment interrupted with returning a concrete
value.</li>
</ul>
<h2 id="the-monad-where-it-happens">The Monad Where It Happens</h2>
<p>We have two data types, <code>Graph a</code> and <code>Bigraph a b</code>, first of them representing
graphs with vertex labels of type <code>a</code> and second representing bipartite graphs
with left part labels of type <code>a</code> and right part labels of type <code>b</code>.</p>
<p><strong>A Word of Warning</strong>: These are not Alga data types. Alga representation for
bipartite graphs is not yet released and there is no representation for
undirected graphs.</p>
<p>We also assume that we have the following functions.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- List of neighbours of a given vertex.</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ot">neighbours ::</span> <span class="dt">Ord</span> a <span class="ot">=&gt;</span> a <span class="ot">-&gt;</span> <span class="dt">AM.AdjacencyMap</span> a <span class="ot">-&gt;</span> [a]</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co">-- Convert a graph with vertices labelled with their parts to a bipartite</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="co">-- graph, ignoring the edges within one part.</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="ot">toBipartiteWith ::</span> (<span class="dt">Ord</span> a, <span class="dt">Ord</span> b, <span class="dt">Ord</span> c) <span class="ot">=&gt;</span> (a <span class="ot">-&gt;</span> <span class="dt">Either</span> b c)</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>                                         <span class="ot">-&gt;</span> <span class="dt">Graph</span> a</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a>                                         <span class="ot">-&gt;</span> <span class="dt">Bigraph</span> b c</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co">-- List of vertices</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="ot">vertexList ::</span> <span class="dt">Ord</span> a <span class="ot">=&gt;</span> <span class="dt">AM.AdjacencyMap</span> a <span class="ot">-&gt;</span> [a]</span></code></pre></div>
<p>Now we write the definition for the function we are going to implement.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="kw">type</span> <span class="dt">OddCycle</span> a <span class="ot">=</span> [a]</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ot">detectParts ::</span> <span class="dt">Ord</span> a <span class="ot">=&gt;</span> <span class="dt">Graph</span> a <span class="ot">-&gt;</span> <span class="dt">Either</span> (<span class="dt">OddCycle</span> a) (<span class="dt">Bigraph</span> a a)</span></code></pre></div>
<p>It can be easily seen that the odd cycle is at the top of the recursion stack
in case we failed to find the partition. So, in order to restore it, we only
need to cut everything from the recursion stack before the first occurrence of
the last vertex.</p>
<p>We will implement a Depth-First Search, while maintaining a map of part
identifiers for each vertex. The recursion stack for the vertex in which we
failed to find the partition will be automatically restored with the <code>Functor</code>
instance for the monad we choose: we only need to put all vertices from the
path into the result on our way back from the recursion.</p>
<p>The first idea is to use the <code>Either</code> monad, that fits perfectly well to our
goals. The first implementation I had was something very close to that. In
fact, I had five different implementations at some point to choose the best,
and I finally stopped at another option.</p>
<p>First, we need to maintain a map of effects — this is something about
<code>State</code>. Then, we need to stop when we found a conflict. This could be either
<code>Monad</code> instance for <code>Either</code> or <code>MonadPlus</code> instance for <code>Maybe</code>. The main
difference is that <code>Either</code> has a value to be returned in case of success
while <code>MonadPlus</code> instance for <code>Maybe</code> only returns a value in case we failed
to find the partition. As we don’t need a value because it’s already stored in
<code>State</code>, we choose <code>Maybe</code>. Now, we need to combine two monadic effects, so we
need <a href="https://en.wikibooks.org/wiki/Haskell/Monad_transformers">monad transformers</a>,
which are a way to combine several monadic effects.</p>
<p>Why had I chosen such complicated type? There are two reasons. The first is
that the implementation becomes very similar to one we have in imperative
languages. The second is that I needed to manipulate the value returned in case
of conflict to restore the odd cycle, and this becomes much simpler in <code>Maybe</code>.</p>
<p>So, here we go now.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ot">{-# LANGUAGE ExplicitForAll #-}</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ot">{-# LANGUAGE ScopedTypeVariables #-}</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Part</span> <span class="ot">=</span> <span class="dt">LeftPart</span> <span class="op">|</span> <span class="dt">RightPart</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="ot">otherPart ::</span> <span class="dt">Part</span> <span class="ot">-&gt;</span> <span class="dt">Part</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a>otherPart <span class="dt">LeftPart</span>  <span class="ot">=</span> <span class="dt">RightPart</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>otherPart <span class="dt">RightPart</span> <span class="ot">=</span> <span class="dt">LeftPart</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a><span class="kw">type</span> <span class="dt">PartMap</span> a <span class="ot">=</span> <span class="dt">Map.Map</span> a <span class="dt">Part</span></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="kw">type</span> <span class="dt">OddCycle</span> a <span class="ot">=</span> [a]</span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a><span class="ot">toEither ::</span> <span class="dt">Ord</span> a <span class="ot">=&gt;</span> <span class="dt">PartMap</span> a <span class="ot">-&gt;</span> a <span class="ot">-&gt;</span> <span class="dt">Either</span> a a</span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a>toEither m v <span class="ot">=</span> <span class="kw">case</span> fromJust (v <span class="ot">`Map.lookup`</span> m) <span class="kw">of</span></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a>                    <span class="dt">LeftPart</span>  <span class="ot">-&gt;</span> <span class="dt">Left</span>  v</span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a>                    <span class="dt">RightPart</span> <span class="ot">-&gt;</span> <span class="dt">Right</span> v</span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a><span class="kw">type</span> <span class="dt">PartMonad</span> a <span class="ot">=</span> <span class="dt">MaybeT</span> (<span class="dt">State</span> (<span class="dt">PartMap</span> a)) [a]</span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a><span class="ot">detectParts ::</span> <span class="kw">forall</span> a<span class="op">.</span> <span class="dt">Ord</span> a <span class="ot">=&gt;</span> <span class="dt">Graph</span> a <span class="ot">-&gt;</span> <span class="dt">Either</span> (<span class="dt">OddCycle</span> a) (<span class="dt">Bigraph</span> a a)</span>
<span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a>detectParts g <span class="ot">=</span> <span class="kw">case</span> runState (runMaybeT dfs) Map.empty <span class="kw">of</span></span>
<span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a>                     (<span class="dt">Just</span> c, _)  <span class="ot">-&gt;</span> <span class="dt">Left</span>  <span class="op">$</span> oddCycle c</span>
<span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a>                     (<span class="dt">Nothing</span>, m) <span class="ot">-&gt;</span> <span class="dt">Right</span> <span class="op">$</span> toBipartiteWith (toEither m) g</span>
<span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a>    <span class="kw">where</span></span>
<span id="cb3-25"><a href="#cb3-25" aria-hidden="true" tabindex="-1"></a><span class="ot">        inVertex ::</span> <span class="dt">Part</span> <span class="ot">-&gt;</span> a <span class="ot">-&gt;</span> <span class="dt">PartMonad</span> a</span>
<span id="cb3-26"><a href="#cb3-26" aria-hidden="true" tabindex="-1"></a>        inVertex p v <span class="ot">=</span> ((<span class="op">:</span>) v) <span class="op">&lt;$&gt;</span> <span class="kw">do</span> modify <span class="op">$</span> Map.insert v p</span>
<span id="cb3-27"><a href="#cb3-27" aria-hidden="true" tabindex="-1"></a>                                      <span class="kw">let</span> q <span class="ot">=</span> otherPart p</span>
<span id="cb3-28"><a href="#cb3-28" aria-hidden="true" tabindex="-1"></a>                                      msum [ onEdge q u <span class="op">|</span> u <span class="ot">&lt;-</span> neigbours v g ]</span>
<span id="cb3-29"><a href="#cb3-29" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-30"><a href="#cb3-30" aria-hidden="true" tabindex="-1"></a>        <span class="ot">{-# INLINE onEdge #-}</span></span>
<span id="cb3-31"><a href="#cb3-31" aria-hidden="true" tabindex="-1"></a><span class="ot">        onEdge ::</span> <span class="dt">Part</span> <span class="ot">-&gt;</span> a <span class="ot">-&gt;</span> <span class="dt">PartMonad</span> a</span>
<span id="cb3-32"><a href="#cb3-32" aria-hidden="true" tabindex="-1"></a>        onEdge p v <span class="ot">=</span> <span class="kw">do</span> m <span class="ot">&lt;-</span> get</span>
<span id="cb3-33"><a href="#cb3-33" aria-hidden="true" tabindex="-1"></a>                        <span class="kw">case</span> v <span class="ot">`Map.lookup`</span> m <span class="kw">of</span></span>
<span id="cb3-34"><a href="#cb3-34" aria-hidden="true" tabindex="-1"></a>                             <span class="dt">Nothing</span> <span class="ot">-&gt;</span> inVertex p v</span>
<span id="cb3-35"><a href="#cb3-35" aria-hidden="true" tabindex="-1"></a>                             <span class="dt">Just</span> q  <span class="ot">-&gt;</span> <span class="kw">do</span> guard (q <span class="op">/=</span> p)</span>
<span id="cb3-36"><a href="#cb3-36" aria-hidden="true" tabindex="-1"></a>                                           <span class="fu">return</span> [v]</span>
<span id="cb3-37"><a href="#cb3-37" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-38"><a href="#cb3-38" aria-hidden="true" tabindex="-1"></a><span class="ot">        processVertex ::</span> a <span class="ot">-&gt;</span> <span class="dt">PartMonad</span> a</span>
<span id="cb3-39"><a href="#cb3-39" aria-hidden="true" tabindex="-1"></a>        processVertex v <span class="ot">=</span> <span class="kw">do</span> m <span class="ot">&lt;-</span> get</span>
<span id="cb3-40"><a href="#cb3-40" aria-hidden="true" tabindex="-1"></a>                             guard (v <span class="ot">`Map.notMember`</span> m)</span>
<span id="cb3-41"><a href="#cb3-41" aria-hidden="true" tabindex="-1"></a>                             inVertex <span class="dt">LeftPart</span> v</span>
<span id="cb3-42"><a href="#cb3-42" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-43"><a href="#cb3-43" aria-hidden="true" tabindex="-1"></a><span class="ot">        dfs ::</span> <span class="dt">PartMonad</span> a</span>
<span id="cb3-44"><a href="#cb3-44" aria-hidden="true" tabindex="-1"></a>        dfs <span class="ot">=</span> msum [ processVertex v <span class="op">|</span> v <span class="ot">&lt;-</span> vertexList g ]</span>
<span id="cb3-45"><a href="#cb3-45" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-46"><a href="#cb3-46" aria-hidden="true" tabindex="-1"></a><span class="ot">        oddCycle ::</span> [a] <span class="ot">-&gt;</span> [a]</span>
<span id="cb3-47"><a href="#cb3-47" aria-hidden="true" tabindex="-1"></a>        oddCycle c <span class="ot">=</span> <span class="fu">tail</span> (<span class="fu">dropWhile</span> ((<span class="op">/=</span>) <span class="fu">last</span> c) c)</span></code></pre></div>
<p>I’ll try to explain each of the first four scoped functions: this is the core
of the algorithm.</p>
<ul>
<li><code>inVertex</code> is the part of DFS that happens when we visit the vertex for the
first time. Here, we assign the vertex to the part and launch <code>onEdge</code> for
every incident edge. And that’s the place where we hope to restore the call
stack: if a <code>Just</code> is returned from sum edge, we add <code>v</code> to the beginning.</li>
<li><code>onEdge</code> is the part that happens when we visit any edge. It happens twice
for each edge. Here we check if the vertex on the other side is visited. If
not, we visit it. Else we check whether we found an odd cycle. If we did, we
simple return the current vertex as a singleton. The other vertices from the
path are added at the way back from the recursion.</li>
<li><code>processVertex</code> checks if the vertex is visited and runs DFS on it if not.</li>
<li><code>dfs</code> runs <code>processVertex</code> on all vertices.</li>
</ul>
<p>That’s it.</p>
<h2 id="the-story-of-inline">The Story of INLINE</h2>
<p>When I first wrote the above code, <code>action</code> was not explicitly inlined. Then,
when I was benchmarking different versions of <code>detectParts</code> to select the best,
I noticed that on some graphs this version with transformers had a serious
overhead over the version with <code>Either</code>. I had no idea of what was going on,
because semantically two functions were supposed to perform the same operations.
And it became even weirder when I ran it on another machine with another
version of GHC and didn’t notice any overhead there.</p>
<p>After a weekend of reading GHC Core code, I managed to fix this with one
explicit inline. At some point between GHC 8.4.4 and GHC 8.6.5 they changed the
optimizer in some way that it didn’t inline <code>action</code>.</p>
<p>This is just a crazy thing about programming I didn’t expect to come through
with Haskell. Still, it seems that the optimizers make mistakes even in our
time and it is our job to give them hints of what should be done. For example,
here we knew that the function should be inlined as it is in the imperative
version, and that’s a reason to give GHC a hint.</p>
<h2 id="what-comes-next">What Comes Next?</h2>
<p>When this patch is merged, I’m going to start implementing Hopcroft-Karp
algorithm. I think the BFS part is going to be rather interesting, so the next
blog post will come in a couple of weeks.</p>]]></description>
    <pubDate>Fri, 26 Jul 2019 00:00:00 UT</pubDate>
    <guid>http://summer.haskell.org/news/2019-07-26-testing-bipartiteness.html</guid>
    <dc:creator>Haskell.org committee</dc:creator>
</item>

    </channel>
</rss>
