560 blogs tracked4,950 posts indexed

#haskell

21 posts · 1 company · newest first

3

Implementing Co, a Small Language With Coroutines #5: Adding Sleep (opens on the source site)

In the previous post, we added channels to Co, the small language we are implementing in this series of posts. In this post, we add the sleep primitive to it, enabling time-based coroutine scheduling. We then use sleep to build a simulation of digital logic circuits.

programming-languagesinterpretersexcerpt only · body stays at the source
From the web
4

A Fast Bytecode VM for Arithmetic: The Virtual Machine (opens on the source site)

In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM. Benchmarking our code to see how the different passes perform. All the while keeping an eye on…

interpretersvirtual-machinesexcerpt only · body stays at the source
From the web
5

A Fast Bytecode VM for Arithmetic: The Compiler (opens on the source site)

In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM. Benchmarking our code to see how the different passes perform. All the while keeping an eye on…

compilersvirtual-machinesexcerpt only · body stays at the source
From the web
6

A Fast Bytecode VM for Arithmetic: The Parser (opens on the source site)

In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM. Benchmarking our code to see how the different passes perform. All the while keeping an eye on…

parsersinterpretersexcerpt only · body stays at the source
From the web
7

Solving Advent of Code “Seating System” with Comonads and Stencils (opens on the source site)

In this post, we solve the Advent of Code 2020 “Seating System” challenge in Haskell using comonads and stencils. This post was originally published on abhinavsarkar.net. This post is a part of the series: Solving Advent of Code. “Handy Haversacks” in Type-level Haskell “No Space Left On Device” with Parsers, Zippers and Interpreters “Rock-Paper-Scissors” in Type-level Haskell “Aplenty” by Compiling “Seating System” with Comonads and Stencils 👈 Contents The Challenge The Cellular Automaton The Solution The Zipper The Comonad The Array The Stencil The Challenge# Here’s a quick summary of the…

haskellpuzzlesexcerpt only · body stays at the source
From the web
8

Going REPLing with Haskeline (opens on the source site)

So you went ahead and created a new programming language, with an AST, a parser, and an interpreter. And now you hate how you have to write the programs in your new language in files to run them? You need a REPL! In this post, we’ll create a shiny REPL with lots of nice features using the Haskeline library to go along with your new PL that you implemented in Haskell.

programming-languagesinterpretersexcerpt only · body stays at the source
From the web
12

Implementing Co, a Small Language With Coroutines #3: Adding Coroutines (opens on the source site)

In the previous post, we wrote the interpreter for basic features of Co, the small language we are building in this series of posts. In this post, we explore and implement what makes Co really interesting: support for lightweight concurrency using Coroutines.

programming-languagesinterpretersexcerpt only · body stays at the source
From the web
13

Writing a Static Site Generator Using Shake (opens on the source site)

Static site generators (SSGs) are all rage these days as people realize that plain HTML websites are good enough for most cases. SSGs take raw data in various formats—often Markdown, JSON, and YAML—and process them to produce the static websites, which can then be hosted easily on any hosting provider, or on personal VPSes. In this post, we write a bespoke SSG using the Shake build system.

build-systemshaskellexcerpt only · body stays at the source
From the web
15

Implementing Co, a Small Language With Coroutines #2: The Interpreter (opens on the source site)

In the previous post, we wrote the parser for Co, the small language we are building in this series of posts. The previous post was all about the syntax of Co. In this post we dive into the semantics of Co, and write an interpreter for its basic features.

programming-languagesinterpretersexcerpt only · body stays at the source
From the web
16

Implementing Co, a Small Language With Coroutines #1: The Parser (opens on the source site)

Many major programming languages these days support some lightweight concurrency primitives. The most recent popular ones are Goroutines in Go, Coroutines in Kotlin and Async in Rust. Let’s explore some of these concepts in detail by implementing a programming language with support for coroutines and Go-style channels.

programming-languagesparsersexcerpt only · body stays at the source
From the web
17

Solving Advent of Code “Handy Haversacks” in Type-level Haskell (opens on the source site)

I have been trying to use type-level programming in Haskell to solve interesting problems since I read Thinking with Types by Sandy Maguire. Then I found myself solving the problems in Advent of Code 2020 and some of them seemed suitable to be solved with type-level programming. So I decided to give it a shot.

type-levelhaskellexcerpt only · body stays at the source
From the web
18

JSON Parsing from Scratch in Haskell: Error Reporting—Part 2 (opens on the source site)

In the previous post, we set out to rewrite the JSON parser we wrote in Haskell in an earlier post, to add support for error reporting. The parser was written very naively: if it failed, it returned nothing. You couldn’t tell what the failure was or where it happened. That’s OK for a toy parser but error reporting is an absolute must requirement for all good parsers. In the previous post, we finished writing the basic framework for the same. In this post, we’ll finish adding simple but useful error reporting capability to our JSON parser.

parsersjsonexcerpt only · body stays at the source
From the web
19

JSON Parsing from Scratch in Haskell: Error Reporting—Part 1 (opens on the source site)

In the previous post we wrote a simple but correct JSON parser in Haskell. The parser was written very naively: if it failed, it returned nothing. You couldn’t tell what the failure was or where it happened. That’s OK for a toy parser but error reporting is an absolute must requirement for all good parsers. So in this post and next post, we’ll add simple but useful error reporting capability to our JSON parser.

parsersjsonexcerpt only · body stays at the source
From the web
20

JSON Parsing from Scratch in Haskell (opens on the source site)

JSON is probably the most used standard file format for storing and transmitting data on the Internet in recent times. Though it was historically derived from JavaScript, it is a programming language independent format and is now supported by almost all languages. JSON has a simple syntax specification with only four scalar data types and two composite data types. So, writing a parser for JSON is a great exercise for learning the basics of parsing. Let’s write one from scratch in Haskell.

parsersjsonexcerpt only · body stays at the source
From the web
21

Notes for ‘Thinking with Types: Type-level Programming in Haskell’, Chapters 1–5 (opens on the source site)

Haskell—with its powerful type system—has a great support for type-level programming and it has gotten much better in the recent times with the new releases of the GHC compiler. But type-level programming remains a daunting topic even with seasoned haskellers. Thinking with Types: Type-level Programming in Haskell by Sandy Maguire is a book which attempts to fix that. I’ve taken some notes to summarize my understanding of the same.

type-levelhaskellexcerpt only · body stays at the source
From the web
21 shown

Privacy choices

Reading never requires analytics. These choices last 90 days on this browser.

Essential sign-in and security storage always stays on. Read the privacy notice.