- http://bitemyapp.com/posts/2017-09-23-please-stop-using-typed-holes.html
- http://vaibhavsagar.com/blog/2017/05/22/discovering-continuations/
- http://matthew.brecknell.net/post/hole-driven-haskell/
- https://www.youtube.com/watch?v=52VsgyexS8Q
- https://wiki.haskell.org/GHC/Typed_holes
- https://github.com/maddogdavis/holey
- https://ghc.haskell.org/trac/ghc/wiki/Holes
- https://www.shimweasel.com/2015/02/17/typed-holes-for-beginners
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
count:: Int -> [Int] -> Int | |
count x arr = length $ filter (\i -> i == x) arr | |
freq:: [Int] -> [Int] -> [(Int, Int)] | |
freq [] _ = [] | |
freq (x:xs) acc = [(x, count x acc + 1)] ++ freq xs (x: acc) | |
example:: [(Int, Int)] | |
example = freq [1,2,1,2,4,2,1] [] |
Stephen Diehl (@smdiehl )
Since I wrote these slides for a little user group talk I gave two years ago they have become a surprisingly popular reference. I decided to actually turn them into a proper skimmable reference for intermediate and advanced level Haskell topics that don't necessarily have great coverage or that tend be somewhat opaque as to where to get going, and then aggregate a bunch of the best external resources for diving into those subjects with more depth. Hopefully it still captures the "no bullshit brain dump" style that seemed to be liked.
The source for all code is available here. If there are any errors or you think of a more illustrative example feel free to submit a pull request.
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
-- I haven't been able to actually run the program (broken archlinux packages), but it typechecks | |
open import Data.String | |
open import Function | |
open import IO.Primitive | |
Either : Set → Set → Set₁ | |
Either l r = {a : Set} → (l → a) → (r → a) → a | |
Left : { l r : Set } → l → Either l r |
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
import Control.Applicative ((<$>)) | |
center :: String -> Int -> String | |
center s n = spaces ++ s ++ spaces | |
where spaces = replicate ((n - length s) `div` 2) ' ' | |
-- http://www.haskell.org/haskellwiki/Blow_your_mind, Ctrl-F "pascal" | |
pascal :: [[Int]] | |
pascal = iterate (\row -> zipWith (+) ([0] ++ row) (row ++ [0])) [1] |
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
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE LambdaCase #-} | |
import Data.Functor.Foldable hiding (Foldable) | |
import qualified Data.Functor.Foldable as Functor | |
import Data.Traversable | |
import qualified Data.Map as Map |
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
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
module Data.Functor.Foldable.Monadic | |
( cataM | |
, anaM | |
, futuM | |
) where | |
import Protolude |