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 TypeFamilies #-} | |
type family InvertArrow x :: * where | |
InvertArrow (a -> b) = b -> a | |
myId :: InvertArrow (a -> b) -> b -> a | |
myId x = x |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
-- Draws an image similar to the cover of Okasaki's Purely Functional Data Structures | |
module Main where | |
import Diagrams.Backend.SVG.CmdLine | |
import Diagrams.Prelude | |
side = sqrt 2 | |
triangleRect :: Diagram B |
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 BangPatterns #-} | |
module Paley where | |
import Data.Function (on) | |
import Data.List (find, insertBy) | |
import Data.Maybe (catMaybes) | |
import Control.Monad (forM_) | |
-- | Prime numbers |
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
#!/usr/bin/env stack | |
-- stack --resolver lts-3.11 --install-ghc runghc --package hmatrix-glpk-0.4.1.0 | |
module Main where | |
import Numeric.LinearProgramming | |
constraints :: [Bound [Double]] | |
constraints = | |
-- first vector is valid |
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 TypeOperators, ScopedTypeVariables #-} | |
import Prelude hiding (until) | |
import Control.Monad hiding (when) | |
import Control.Applicative hiding (empty) | |
import Data.Set hiding (filter,fold, foldl,map) | |
import Control.FRPNow | |
import Control.FRPNow.Gloss | |
import Graphics.Gloss.Interface.Pure.Game |
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
module BankersQueue where | |
data LenList a = LenList { len :: !Int, items :: [a] } | |
instance Monoid (LenList a) where | |
mempty = LenList 0 [] | |
mappend (LenList n xs) (LenList m ys) = | |
LenList (n+m) (xs++ys) | |
coh' :: LenList a -> Maybe (a, LenList a) | |
coh' (LenList _ []) = Nothing |
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 OverloadedStrings #-} | |
module NestedRoutesExample where | |
import Web.Routes.Nested | |
import Data.Text.Lazy as LT | |
import Network.Wai | |
import Data.Attoparsec.Text | |
router :: Application |
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 TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE RankNTypes #-} |
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 #-} | |
module TraversalIso where | |
import Control.Lens.Traversal | |
import Control.Monad.State.Lazy | |
import Data.Traversable (Traversable (..)) | |
{- | |
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t |