MARK P. JONES
Pacific Software Research Center
Department of Computer Science and Engineering
Oregon Graduate Institute of Science and Technology
module DepthFirstSearch where | |
import Data.Foldable (asum) | |
import Data.List ((\\)) | |
dfs :: (Eq a) => (a -> [a]) -> a -> a -> Maybe [a] | |
dfs next start goal = dfs' [] start | |
where dfs' path current | |
| current == goal = Just . reverse $ goal : path | |
| null nexts = Nothing |
It is seductive to imagine that effect handlers in an algebraic effect system are not part of the program itself but metalanguage-level folds over the program tree. And in traditional free-like formulations, this is in fact the case. The Eff
monad represents the program tree, which has only two cases:
data Eff effs a where
Pure :: a -> Eff effs a
Op :: Op effs a -> (a -> Eff effs b) -> Eff effs b
data Op effs a where
image: nixpkgs/cachix-flakes:nixos-20.03 | |
build: | |
before_script: | |
- mkdir -p /etc/nix | |
- echo "experimental-features = nix-command flakes ca-references recursive-nix" >> /etc/nix/nix.conf | |
- cachix use numtide | |
- nix path-info --all > /tmp/store-path-pre-build | |
script: | |
- nix flake check |
newtype Fn a = Fn {unFn :: a -> a} | |
instance Semigroup (Fn a) where | |
(<>) (Fn a) (Fn b) = Fn (b . a) | |
import Control.Monad | |
import Data.Foldable (fold) | |
import Data.Monoid (appEndo) | |
import Hedgehog |
{-# LANGUAGE RankNTypes #-} | |
import Control.Comonad.Cofree | |
import Control.Lens hiding ((:<)) | |
import qualified Data.Map as Map | |
import Data.Map (Map) | |
import Prelude hiding (lookup) | |
import Data.Maybe (isJust) | |
import Test.QuickCheck |
### | |
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places. | |
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of | |
###. things to watch out for: | |
### - Check out the `nix-darwin` instructions, as they have changed. | |
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026 | |
### | |
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs). | |
# So here's a minimal Gist which worked for me as an install on a new M1 Pro. |
-- | In response to https://twitter.com/_gilmi/status/1478846678409035779 | |
-- | |
-- The challenge is three-fold: | |
-- | |
-- 1. define the type 'Expr2' as "the same as 'Expr1' but with this constructor | |
-- instead of that one", without having to repeat all the other constructors. | |
-- 2. convert from 'Expr1' to 'Expr2' by only providing a translation for the | |
-- one constructor which is different. | |
-- 3. write a polymorphic function which works with both 'Expr1' and 'Expr2' | |
-- because it doesn't touch the constructor which differs. |