- Monday, August 6: Chapter 16 hosted by Charlottesville Haskell Book Reading Group in Charlottesville, va, USA
- Monday, August 6: Combinating - The Weekly Function hosted by Orange Combinator - Functional Programming In OC in Irvine, CA
- Tuesday, August 7: Techniques in Functional JavaScript hosted by NoFUN - New Orleans Functional Programming in New Orleans, USA
- Tuesday, August 7: [Lightning talks / Show and tell](https://www.meetup.
This file contains hidden or 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
-- Something like this when teaching using GHC | |
-- so that beginners don't get confused by FTP versions | |
-- of length, sum, product, etc. | |
-- Usage: in ghci, `:l FtpFree.hs` | |
module FtpFree (length, sum, product) where | |
import Prelude hiding (length, sum, product) | |
length :: [a] -> Int |
This file contains hidden or 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
Using cabal to install quickcheck: | |
Make a directory to work in. | |
Inside the directory: “cabal sandbox init” | |
Then: “cabal install quickcheck” | |
You can open the GHCI repl in the sandbox: | |
"cabal repl" | |
And use normal commands like ":load filename.hs" |
This file contains hidden or 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
---Very simple evaluation for arithmetic expressions with only constants | |
---(and only "plus"...obviously extendable to other operations) | |
data Expr = C Float | | |
Expr :+ Expr | |
deriving Show | |
eval :: Expr -> Float | |
eval (C x) = x | |
eval (e1 :+ e2) = let v1 = eval e1 |
This file contains hidden or 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 FunkyList where | |
import Control.Monad | |
instance Functor FunkyList where | |
fmap = liftM | |
instance Applicative FunkyList where | |
pure = return | |
(<*>) = ap | |
This file contains hidden or 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 FlexibleInstances #-} | |
module NumFunction where | |
instance Num a => Num (a -> a) where | |
(f + g) x = f x + g x | |
(f * g) x = f x * g x | |
abs f = abs . f | |
signum f = signum . f | |
fromInteger x = const (fromInteger x) | |
negate f = negate . f |
This file contains hidden or 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 Life where | |
import Data.Set (Set) | |
import qualified Data.Set as S | |
import Data.Foldable (foldMap) | |
type Cell = (Int, Int) | |
type World = Set Cell |
This file contains hidden or 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 ExistentialQuantification #-} | |
-- This is adapted from http://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types | |
-- See also https://www.haskell.org/haskellwiki/Heterogenous_collections#Existential_types | |
module HeterogeneousList where | |
data ShowBox = forall s. Show s => SB s | |
heteroList :: [ShowBox] |
This file contains hidden or 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 Game2048 where | |
import Graphics.Collage as Collage | |
import Keyboard | |
import Random | |
import Transform2D as TF | |
import List exposing (..) | |
import Color exposing (rgb, green, black, grey) | |
import Graphics.Element exposing (show, color, centered, Element) | |
import Graphics.Collage exposing (Form) |