Skip to main content

All Questions

6 votes
1 answer
473 views

Terse finite state machines in Haskell

I'm writing a parser for a markup language in haskell, and a finite state machine fell out of my ideal API. I have code that looks a bit like this: Token = BoldWord String | Word String | ...
user avatar
2 votes
2 answers
2k views

Patterns for tracking state in recursive Haskell code

A frequent pattern in my Haskell code is element-wise recursion for transformation of a list with some carried state generated using the data in the list. Usually, this looks something like this: ...
TheEnvironmentalist's user avatar
4 votes
1 answer
472 views

What are some practical uses of Generalized Algebraic Datatypes? [closed]

All tutorials on GADTs that I've seen (in Haskell, Coq and Idris) use one same exapmle of a well-typed interpreter to show how GADTs can be useful, where you use the type index to encode the type of ...
Alex's user avatar
  • 284
6 votes
1 answer
269 views

Is the use of DSLs in a state monad a good approach to building complex stateful computations?

First, sorry if that title makes no sense. I am a little out of my depth here with the terminology. So, imagine that I'm writing a text editor in Haskell. For the purposes of this question, let's ...
mdunsmuir's user avatar
  • 243
103 votes
2 answers
26k views

What is the "Free Monad + Interpreter" pattern?

I've seen people talking about Free Monad with Interpreter, particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement ...
Benjamin Hodgson's user avatar