<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Haskell on grzenow</title><link>http://www.grzenow.com/tags/haskell/</link><description>Recent content in Haskell on grzenow</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 24 May 2024 00:00:00 +0000</lastBuildDate><atom:link href="http://www.grzenow.com/tags/haskell/index.xml" rel="self" type="application/rss+xml"/><item><title>Logic in Computer Science</title><link>http://www.grzenow.com/projects/logic-in-computer-science/</link><pubDate>Fri, 24 May 2024 00:00:00 +0000</pubDate><guid>http://www.grzenow.com/projects/logic-in-computer-science/</guid><description>&lt;p&gt;This is a collection of projects completed for the Logic in Computer Science course, including:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Propositional logic in Haskell (Part 1):&#10;&lt;ul&gt;&#10;&lt;li&gt;Satisfiable formulas, tautologies, disjunctive normal form (DNF), DNF-based SAT solver.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Propositional logic in Haskell (Part 2):&#10;&lt;ul&gt;&#10;&lt;li&gt;Conjunctive normal form (CNF), equisatisfiable CNF (ENCF), Davis-Putnam SAT solver.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;SAT solving with Z3 in Python (Part 1):&#10;&lt;ul&gt;&#10;&lt;li&gt;Generating all satisfying assignments, pebbling formulas, n-queens problem.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;SAT solving with Z3 in Python (Part 2):&#10;&lt;ul&gt;&#10;&lt;li&gt;Shortest common superstring (SCS) problem, phase transitions for the k-SAT problem.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;SMT solving with Z3 in Python:&#10;&lt;ul&gt;&#10;&lt;li&gt;Łoś principle, function 91, Sudoku solver.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Intuitionistic propositional logic in Agda:&#10;&lt;ul&gt;&#10;&lt;li&gt;Conjunction and disjunction proofs, de Morgan&amp;rsquo;s laws, weak Pierce&amp;rsquo;s law.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Intuitionistic first order logic in Agda:&#10;&lt;ul&gt;&#10;&lt;li&gt;Universal and existential quantifier proofs, relations.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;&lt;a href="https://github.com/grzenow4/LDI-lab" class="external-link" target="_blank" rel="noopener"&gt;Source code&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Latte Compiler</title><link>http://www.grzenow.com/projects/latte-compiler/</link><pubDate>Sun, 21 Jan 2024 00:00:00 +0000</pubDate><guid>http://www.grzenow.com/projects/latte-compiler/</guid><description>&lt;p&gt;One of the major projects during my graduate studies was building a compiler for the &lt;a href="https://www.mimuw.edu.pl/~ben/Zajecia/Mrj2022/Latte/description.html" class="external-link" target="_blank" rel="noopener"&gt;Latte&lt;/a&gt; language, extended with features such as arrays, structs, and objects with single inheritance. The compiler parses Latte code using the &lt;a href="https://hackage.haskell.org/package/BNFC" class="external-link" target="_blank" rel="noopener"&gt;BNFC&lt;/a&gt; tool and compiles it into x86 assembly.&lt;/p&gt;&#10;&lt;p&gt;The compiler&amp;rsquo;s core is implemented using a &lt;code&gt;Reader-Writer-State&lt;/code&gt; monad:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-haskell" data-lang="haskell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff7b72"&gt;data&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Reader&lt;/span&gt; &lt;span style="color:#ff7b72;font-weight:bold"&gt;=&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Rd&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; { func &lt;span style="color:#ff7b72;font-weight:bold"&gt;::&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt;&lt;span style="color:#ff7b72;font-weight:bold"&gt;.&lt;/span&gt;&lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;String&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;TType&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; , clss &lt;span style="color:#ff7b72;font-weight:bold"&gt;::&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt;&lt;span style="color:#ff7b72;font-weight:bold"&gt;.&lt;/span&gt;&lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;String&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;ClassEnv&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff7b72"&gt;type&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Writer&lt;/span&gt; &lt;span style="color:#ff7b72;font-weight:bold"&gt;=&lt;/span&gt; [&lt;span style="color:#ff7b72"&gt;AsmInstr&lt;/span&gt;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff7b72"&gt;data&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;State&lt;/span&gt; &lt;span style="color:#ff7b72;font-weight:bold"&gt;=&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;St&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; { nextlab &lt;span style="color:#ff7b72;font-weight:bold"&gt;::&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Int&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; , newloc &lt;span style="color:#ff7b72;font-weight:bold"&gt;::&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Int&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; , env &lt;span style="color:#ff7b72;font-weight:bold"&gt;::&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt;&lt;span style="color:#ff7b72;font-weight:bold"&gt;.&lt;/span&gt;&lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;String&lt;/span&gt; (&lt;span style="color:#ff7b72"&gt;TType&lt;/span&gt;, &lt;span style="color:#ff7b72"&gt;String&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; , rodata &lt;span style="color:#ff7b72;font-weight:bold"&gt;::&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt;&lt;span style="color:#ff7b72;font-weight:bold"&gt;.&lt;/span&gt;&lt;span style="color:#ff7b72"&gt;Map&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;String&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;String&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; , rspOff &lt;span style="color:#ff7b72;font-weight:bold"&gt;::&lt;/span&gt; &lt;span style="color:#ff7b72"&gt;Int&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where&lt;/p&gt;</description></item><item><title>Instant Compiler</title><link>http://www.grzenow.com/projects/instant-compiler/</link><pubDate>Sat, 28 Oct 2023 00:00:00 +0000</pubDate><guid>http://www.grzenow.com/projects/instant-compiler/</guid><description>&lt;p&gt;&lt;strong&gt;Instant&lt;/strong&gt; is a programming language that supports two types of statements:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;expression&lt;/code&gt; - prints the value of the &lt;code&gt;expression&lt;/code&gt; on stdout,&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;variable = expression&lt;/code&gt; - assigns the value of the &lt;code&gt;expression&lt;/code&gt; to the &lt;code&gt;variable&lt;/code&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Expressions can consist of integers, variables, and arithmetic operations between them.&lt;/p&gt;&#10;&lt;p&gt;The goal of this project was to create a compiler from &lt;strong&gt;Instant&lt;/strong&gt; to JVM and LLVM architectures.&lt;/p&gt;&#10;&lt;p&gt;A detailed description can be found &lt;a href="https://github.com/grzenow4/MRJP-Instant-Compiler/blob/main/Instant-en.md" class="external-link" target="_blank" rel="noopener"&gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://github.com/grzenow4/MRJP-Instant-Compiler" class="external-link" target="_blank" rel="noopener"&gt;Source code&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Latte Interpreter</title><link>http://www.grzenow.com/projects/latte-interpreter/</link><pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate><guid>http://www.grzenow.com/projects/latte-interpreter/</guid><description>&lt;p&gt;One of the larger projects I did during my undergraduate studies is undoubtedly an interpreter for the simple programming language &lt;a href="https://www.mimuw.edu.pl/~ben/Zajecia/Mrj2022/Latte/description.html" class="external-link" target="_blank" rel="noopener"&gt;Latte&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;The interpreter is written in Haskell, and the grammar is parsed into this language using the &lt;a href="https://hackage.haskell.org/package/BNFC" class="external-link" target="_blank" rel="noopener"&gt;BNFC&lt;/a&gt; tool. The implemented functionalities are described in detail on GitHub (link below), along with numerous examples, so below is a brief overview of the implementation details.&lt;/p&gt;&#10;&lt;p&gt;The code of the Latte language is automatically parsed by BNFC and then passed to static type checking. The monad representing the state of the TypeChecker looks as follows:&lt;/p&gt;</description></item><item><title>Sokoban</title><link>http://www.grzenow.com/projects/sokoban/</link><pubDate>Thu, 08 Dec 2022 00:00:00 +0000</pubDate><guid>http://www.grzenow.com/projects/sokoban/</guid><description>&lt;p&gt;&lt;strong&gt;Sokoban&lt;/strong&gt; is a puzzle game created as part of a functional programming course in Haskell.&lt;/p&gt;&#10;&lt;p&gt;The game was implemented in Haskell on the &lt;a href="https://code.world/" class="external-link" target="_blank" rel="noopener"&gt;CodeWorld&lt;/a&gt; platform, where you can play it by clicking on this &lt;a href="https://code.world/haskell#Plg7ON0XRfShvcgT0D7DElw" class="external-link" target="_blank" rel="noopener"&gt;link&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Controls:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Space&lt;/strong&gt; - start game&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;WSAD / Arrow keys&lt;/strong&gt; - move forward&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;U&lt;/strong&gt; - undo move&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;B&lt;/strong&gt; - previous level&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;N&lt;/strong&gt; - next level&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;R&lt;/strong&gt; - reset level&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Esc&lt;/strong&gt; - reset game&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;a href="https://github.com/grzenow4/Sokoban" class="external-link" target="_blank" rel="noopener"&gt;Source code&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>