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
| #!/usr/bin/env runhaskell | |
| module Main where | |
| import Text.Printf(printf) | |
| import Data.List(intercalate) | |
| import Data.Bool (bool) | |
| kg2lb = | |
| (*2.2) |
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
| import Data.Monoid | |
| -- This code doesn't work... | |
| -- How can you make a multi-parameter data type be Foldable? | |
| -- foldMap over `a` so it can be converted to a Monoid | |
| data BinaryTree3 a v | |
| = Node3 a (BinaryTree3 a v) (BinaryTree3 a v) | |
| | Leaf3 a v | |
| deriving (Show) |
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
| #!/usr/bin/env runhaskell | |
| import Text.Printf | |
| fromRadian a = a / pi * 180 | |
| toRadian a = a / 180 * pi | |
| showDiff :: Int -> String | |
| showDiff x = | |
| let x' = toRadian (fromIntegral x) | |
| diff = fromRadian (x' - sin x') |
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
| #!/usr/bin/env runhaskell | |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE DeriveFoldable #-} | |
| import Data.Foldable | |
| import Text.Printf | |
| data Point a = | |
| Point { |
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
| data LSystem a b = | |
| LSystem | |
| [a] | |
| (a -> [b]) | |
| type LSystem' a = | |
| LSystem a a | |
| instance Functor (LSystem a) where | |
| fmap k (LSystem a 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
| f :: Store a b -> Store a (Store a b) | |
| f s = | |
| let (set, get) = runStore s | |
| in store (store set) get |
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
| {-# OPTIONS_GHC -Wall #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| import Control.Lens | |
| data These a b = | |
| This a | |
| | That b | |
| | Both a b | |
| deriving (Eq, Show) |
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 LambdaCase #-} | |
| import Control.Lens | |
| data Blah a = | |
| Blah1 a | |
| | Blah2 a | |
| | BlahS String | |
| deriving (Eq, Show) |
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
| // >>> given([notnull 1,null,notnull 3]) | |
| // null | |
| // >>> given([notnull 1,notnull 2,notnull 3]) | |
| // notnull [1,2,3] | |
| given(list) { | |
| var r = List.empty | |
| for(var i = 0; i < list.length; i++) { | |
| if(list[i] == null) | |
| return null | |
| else |
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
| FROM ubuntu:16.04 | |
| RUN apt-get update | |
| RUN apt-get install -y libreoffice imagemagick ghostscript rsync bash pdftk texlive-xetex texlive-luatex ttf-dejavu sudo zlib1g-dev ghc cabal-install | |
| RUN export TZ=Australia/Brisbane | |
| RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
| RUN export LANG=C.UTF-8 | |
| RUN grep write /etc/ImageMagick-6/policy.xml |