- Fuel: 188L (full)
- Baggage: 45.4kg (maximum)
- Tony: 80kg
- Juliana: 70kg
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 DataKinds #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} |
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.Bool | |
| filter' :: | |
| (a -> Either b c) | |
| -> [a] | |
| -> ([b], [c]) | |
| filter' _ [] = | |
| ([], []) | |
| filter' f (a:as) = | |
| let (bs, cs) = filter' f as |
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
| ;; Pure functional I/O using clojure | |
| ;; ================================= | |
| ;; | |
| ;; Defines a grammar of three operations in `defrecord Operation` using the free monad technique | |
| ;; 1. read file | |
| ;; 2. write file | |
| ;; 3. print to standard output | |
| ;; | |
| ;; Defines I/O operations by combining the Operation grammar in `defrecord IO` | |
| ;; |
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
| skipRight :: | |
| (a -> [a] -> ([a] -> b) -> b) | |
| -> b | |
| -> [a] | |
| -> b | |
| skipRight _ z [] = | |
| z | |
| skipRight f z (h:t) = | |
| f h t (skipRight f z) |
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 Control.Applicative(Alternative(..), liftA2) | |
| newtype ValidationT f a b = | |
| ValidationT (f (Either a b)) | |
| instance Functor f => Functor (ValidationT f a) where | |
| fmap f (ValidationT x) = | |
| ValidationT (fmap (fmap f) x) | |
| instance Applicative f => Applicative (ValidationT f a) where |
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 { |
NewerOlder