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 MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
class Dual f g | f -> g, g -> f where | |
zap :: (a -> b -> c) -> f a -> g b -> c | |
data PrintF a = PrintF String a deriving Functor | |
data CoPrintF a = CoPrintF { coPrint :: String -> a } deriving Functor |
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 TemplateHaskell, DeriveFunctor #-} | |
fact1 :: Integer -> Integer | |
fact1 n = product [1..n] | |
reduceProduct [] = [] | |
reduceProduct [x] = [x] | |
reduceProduct (a:b:xs) = (a*b) : reduceProduct xs | |
product' [] = 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 TemplateHaskell, TypeFamilies, DeriveFunctor #-} | |
{-# LANGUAGE BangPatterns #-} | |
import Data.Functor.Foldable | |
import TH | |
import Data.List | |
fact1 :: Integer -> Integer | |
fact1 n = product [1..n] |
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 ScopedTypeVariables #-} | |
{-# LANGUAGE ViewPatterns #-} | |
{-# OPTIONS -Wall #-} | |
module Main where | |
import Data.Functor.Foldable | |
import Control.Comonad.Cofree | |
type Item = (String, Int, Double) |
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 LambdaCase, OverloadedStrings, FlexibleInstances #-} | |
{-# LANGUAGE ViewPatterns, TemplateHaskell #-} | |
module TH where | |
import Control.Applicative | |
import Control.Lens | |
import Control.Monad | |
import Data.Functor.Foldable | |
import Language.Haskell.TH |
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
{-# OPTIONS -Wall #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
import Network.HTTP.Conduit | |
import qualified Data.ByteString as B | |
import qualified Data.ByteString.Char8 as C8 | |
import qualified Data.ByteString.Lazy as BL | |
import qualified Data.ByteString.Lazy.Char8 as C8L | |
import Data.List (intersperse) |
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, ScopedTypeVariables, NoMonomorphismRestriction, | |
TupleSections #-} | |
-- | A couple arrow-like functions for enumeratees. Consider this example: | |
-- | |
-- Suppose you have the following | |
-- | |
-- 1. Consumer :: Iteratee [(Int,Char)] m a | |
-- 2. Mapper :: Enumeratee Int Char m a | |
-- 3. Source :: Enumerator Int m a |