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 FlexibleInstances #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE Rank2Types #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE StandaloneDeriving #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE ViewPatterns #-} |
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
| module PatternSynonymsImport where | |
| -- one can use either an unqualified import | |
| import PatternSynonymsTest | |
| -- alternatively one can use explicit imports (this requires enabling the | |
| -- PatternSynonyms language extension): | |
| -- import PatternSynonymsTest (Option(..), pattern None) | |
| maybeToOption :: Maybe a -> Option a | |
| maybeToOption Nothing = None |
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 TypeFamilies #-} | |
| type family InvertArrow x :: * where | |
| InvertArrow (a -> b) = b -> a | |
| myId :: InvertArrow (a -> b) -> b -> a | |
| myId x = 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
| 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 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
| -- 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 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 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 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 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 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 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 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
| 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 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 OverloadedStrings #-} | |
| module NestedRoutesExample where | |
| import Web.Routes.Nested | |
| import Data.Text.Lazy as LT | |
| import Network.Wai | |
| import Data.Attoparsec.Text | |
| router :: Application |