Skip to content

Instantly share code, notes, and snippets.

Ollie Charles ocharles

Block or report user

Report or block ocharles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:900ffc2990f166fe2ce633c1a3614f3e
# This is probably a ball

Solving Planning Problems with Fast Downward and Haskell

In this post I'll demonstrate my new fast-downward library to solve planning problems. The name "Fast Downward" comes from the backend solver - Fast Downward. But what's a planning problem?

Roughly speaking, planning problems are a subclass of AI problems where we have:

  • A known starting state - information about the world we know to be true right now.
  • A set of possible effects - deterministic ways we can change the world.
  • A goal state that we wish to reach.
  • A solution to a planning problem is a plan - a totally ordered sequence of steps that converge the starting state into the goal state.
View Free? monads with mtl.hs
{-# language ConstraintKinds #-}
{-# language FlexibleContexts #-}
{-# language FlexibleInstances #-}
{-# language GADTs #-}
{-# language MultiParamTypeClasses #-}
{-# language GeneralizedNewtypeDeriving #-}
{-# language RankNTypes #-}
{-# language QuantifiedConstraints #-}
{-# language TypeApplications #-}
{-# language TypeOperators #-}

MonadError via MonadCatch and MonadThrow

First, the code

newtype Exceptional e m a = Exceptional { deExceptional :: m a }
  deriving (Functor, Applicative, Monad)

instance (Exception e, MonadThrow m) => MonadError e (Exceptional e m) where
  throwError = Exceptional . throwM
View Q3 BSP Parser.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
View Modern FP with mtl.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
View gist:556b35e3d16565cab457
> import Control.Monad.Trans
> import Control.Monad.Trans.Iter
The completely iterative free monad transformer lets us capture non-termination as an effect. Furthermore, it's a monad *transformer*, so we can add non-termination on top of other effects.
A convenient combinator is
> untilSuccess :: Monad m => m (Maybe a) -> IterT m a
> untilSuccess f = maybe (delay (untilSuccess f)) return =<< lift f

Keybase proof

I hereby claim:

  • I am ocharles on github.
  • I am ocharles ( on keybase.
  • I have a public key whose fingerprint is 741D 56D6 5A2F A961 3B4A CD13 B834 A915 55D4 8746

To claim this, I am signing this object:

ocharles / Soundex.hs
Created Aug 14, 2014
Soundex in Haskell
View Soundex.hs
import Control.Arrow ((&&&))
import Data.Char (toLower)
import Data.Maybe (catMaybes)
import System.Random
import qualified Data.Map as M
data Sxcode = Sxcode Char [Sxdigit]
deriving (Eq, Ord, Show)
View gist:3584582
something = foo
blah one 2
somethingCorrect = foo (bar) (baz (blah one 2)) (blah)
You can’t perform that action at this time.