This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FoldsAndUnfolds where | |
import Data.List -- for unfoldr | |
class Functor f => Recursive f t | t -> f where | |
project :: t -> f t | |
cata :: (f a -> a) -> t -> a | |
cata alg = go where go = alg . fmap go . project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -fno-warn-orphans #-} | |
module Repl where | |
import Cachix.Config (readConfig) | |
import Cachix.Env (setupApp) | |
import Cachix.Server.Prelude | |
import qualified Control.Exception.Safe as Safe | |
import qualified Language.Haskell.Interpreter as Interpreter | |
import Protolude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spec where | |
import Quickstrom | |
import Data.Foldable (any) | |
import Data.Maybe (maybe) | |
import Data.Tuple (Tuple(..)) | |
import Data.String.CodeUnits (contains) | |
import Data.String.Pattern (Pattern(..)) | |
readyWhen = "body" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- in response to https://twitter.com/chrislpenner/status/1221784005156036608 | |
-- | |
-- The goal is to mimic this Scala code, but in Haskell: | |
-- | |
-- > "spotify:user:123:playlist:456" match { | |
-- > case s"spotify:user:$userId:playlist:$playlistId" | |
-- > => ($userId, $playlistId) // ("123", "456") | |
-- > } | |
{-# LANGUAGE DeriveFunctor, LambdaCase, PatternSynonyms, QuasiQuotes, RankNTypes, TemplateHaskell, TypeOperators, ViewPatterns #-} | |
{-# OPTIONS -Wno-name-shadowing #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------- | |
-- Is List or NonEmpty "simpler"? Neither: | |
type NonEmpty a = Fix (Compose ((,) a) Maybe) | |
type List a = Fix (Compose Maybe ((,) a)) | |
-------------------------------------------------------------------------------- | |
newtype Fix f = Fix {unFix :: f (Fix f)} |
NewerOlder