Downloaded from cessna.com via web.archive.org.
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 FunctionalDependencies #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| -- If there were an opportunity to fix the IsList type-class... | |
| import Control.Lens | |
| import Data.List.NonEmpty hiding (fromList) | |
| class FromList l f | l -> f 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
| {-# OPTIONS_GHC -Wall #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE DefaultSignatures #-} | |
| -- A better One type-class than Relude.Container.One | |
| import Control.Applicative | |
| import Control.Lens |
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
| {-# 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
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| -- ghci -package lens -package tagged LeftLike.hs | |
| import Control.Lens | |
| import Data.Maybe |
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
| case class ReaderWriterStateT[R, W, S, F[_], A]( | |
| run: (R, S) => F[(W, A, S)] | |
| ) { | |
| def map[B](f: A => B)(implicit F: Functor[F]) | |
| : ReaderWriterStateT[R, W, S, F, B] = | |
| ReaderWriterStateT { | |
| case (r, s) => F.map(run(r, s)) { | |
| case (w, a, s) => (w, f(a), s) | |
| } | |
| } |
NewerOlder