Duet has this folding example:
data List a = Nil | Cons a (List a)
foldr = \f z l ->
case l of
Nil -> z
Cons x xs -> f x (foldr f z xs)| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE ExistentialQuantification #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE GADTs #-} | |
| -- | A restricted web type. | |
| module Web | |
| ( Web(..) | |
| , runWebHandler |
| {-# LANGUAGE BangPatterns #-} | |
| import Control.DeepSeq | |
| import Data.List hiding (foldl) | |
| import Prelude hiding (foldl) | |
| foldl = \f accumulator list -> | |
| case list of | |
| [] -> accumulator | |
| x:xs -> foldlS f (f accumulator x) xs |
| -- | Execute the steps. | |
| execute :: [SomeStep] -> RIO MainEnv () | |
| execute steps = do | |
| resources <- newIORef mempty | |
| mapRIO | |
| (\MainEnv {logger} -> ExecuteEnv {logger = logger . ExecuteLog, resources}) | |
| (mapM_ executeSomeStep steps) |
| > :set -XOverloadedStrings | |
| > :set -XTemplateHaskell | |
| > import Language.Haskell.TH | |
| > $(bsToExp "Hello, World" >>= stringE . show) | |
| "AppE (VarE GHC.IO.Unsafe.unsafePerformIO) (AppE (AppE (VarE Data.ByteString.Unsafe.unsafePackAddressLen) \ | |
| \(LitE (IntegerL 12))) (LitE (StringPrimL [72,101,108,108,111,44,32,87,111,114,108,100])))" | |
| > | |
| > :set -ddump-splices |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| import Data.Bifunctor |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| module Data.Graph.Shuffle where | |
| -- | Shuffle a graph into a randomly sorted list, preserving | |
| -- topological order. | |
| {- | |
| > quickCheckWith stdArgs {maxSuccess=10000} prop_identity |
| {-# LANGUAGE PartialTypeSignatures #-} | |
| module StableShuffle where | |
| import Control.Monad | |
| import Control.Monad.Random | |
| import Data.Bifunctor | |
| import Data.List | |
| import qualified Data.Map.Strict as M | |
| import Data.Maybe | |
| import Data.Ord |
| {-# LANGUAGE PartialTypeSignatures #-} | |
| module StableShuffle where | |
| import Control.Monad | |
| import Control.Monad.Random.Class | |
| import Data.List | |
| import qualified Data.Map.Strict as M | |
| import Data.Maybe | |
| import Data.Ord | |
| import System.Random.Shuffle |
| chris@precision:~/Work/chrisdone/prj$ stack build -v | |
| Version 2.2.0, Git revision 896869ee79d82e3bd9bead30d610ac2bf580cd99 (dirty) (7790 commits) PRE-RELEASE x86_64 hpack-0.31.2 | |
| 2019-07-31 14:16:17.668130: [debug] Checking for project config at: /home/chris/Work/chrisdone/prj/stack.yaml | |
| 2019-07-31 14:16:17.668320: [debug] Loading project config file stack.yaml | |
| 2019-07-31 14:16:17.674494: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-07-30 13:16:17.674439 UTC] | |
| 2019-07-31 14:16:17.675171: [debug] Using package location completions from a lock file | |
| 2019-07-31 14:16:17.877293: [debug] Asking for a supported GHC version | |
| 2019-07-31 14:16:17.877678: [debug] Installed tools: | |
| - ghc-8.2.2 | |
| - ghc-8.6.3 |