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
NotExist: Doesn't exist | |
NotPresent: Not submitted | |
NotNumber t@Text: "#{t}" is not a number | |
NotLetter t@Text: "#{t}" doesn't only contain letters | |
NotValidEmail t@Text: "#{t}" is not a valid email address | |
NotValidName t@Text: "#{t}" is not a valid name | |
ParsecError t@Text: Syntax error: #{t} | |
LengthGreater t@Text i@Int: "#{t}" is longer than #{show i} characters | |
LowerThan ii@Integer: is greater than #{show ii} | |
Invalid t@Text: #{show t} is invalid |
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 Cofree f a = a :< (f (Cofree f a)) | |
-- Fix point | |
newtype Mu f = Mu { unMu :: f (Mu f) } | |
extract :: Cofree f a -> a | |
extract (a :< _) = a | |
-- catamorphism | |
cata :: Functor f => (f b -> b) -> Mu f -> 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 GADTs, RankNTypes #-} | |
import Prelude hiding (read, print) | |
-- The "operational" form | |
data Action a where | |
Print :: String -> Action () | |
Read :: Action String | |
{- |
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 GADTs #-} | |
data Free f a = Done a | Free (f (Free f a)) | |
instance Functor f => Monad (Free f) where | |
return = Done | |
Done a >>= f = f a | |
Free s >>= f = Free $ fmap (f =<<) s |
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.Functor.Foldable | |
-- | takeStrictlyLessThan take elements of a list whils their sum is | |
-- _strictly_ less than a given number | |
-- | |
-- Point-free: I didnt' try without parameter, you can easily "hide" the 2nd | |
-- parameter (ie. takeStrictlyLessThan x = ) | |
-- Level: MEDIUM | |
-- | |
-- Examples: |
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.Traversable (for) | |
import Data.Aeson (Value, json) | |
import Data.AttoParsec (parseOnly) | |
import Snap.Core | |
getPostJsonParam :: MonadSnap m => ByteString -> m (Maybe Value) | |
getPostJsonParam key = do | |
bsOpt <- getPostParam key | |
for bsOpt $ \bs -> |
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.Functor.Foldable | |
divIfMultiple :: Integral a => a -> [a] -> Maybe [a] | |
divIfMultiple x = cata go | |
where | |
go Nil = Just [] | |
go (Cons a r) | |
| mod a x == 0 = fmap (div a x:) r | |
| otherwise = 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 ExistentialQuantification #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE GADTs #-} | |
module Data.Process where | |
import Prelude hiding (zipWith) | |
import Control.Applicative | |
import Control.Monad | |
import Data.Foldable |
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
Sun Feb 2 20:44 2014 Time and Allocation Profiling Report (Final) | |
spellcheck +RTS -p -sstderr -RTS | |
total time = 0.00 secs (0 ticks @ 1000 us, 1 processor) | |
total alloc = 90,424 bytes (excludes profiling overheads) | |
COST CENTRE MODULE %time %alloc | |
CAF GHC.IO.Handle.FD 0.0 38.4 |
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
From d8730a5b72f263754e82c5e18ee53abf0c002b46 Mon Sep 17 00:00:00 2001 | |
From: YoEight <[email protected]> | |
Date: Sat, 11 Jan 2014 13:30:23 +0100 | |
Subject: [PATCH] Apply changes relative to TH.Pred becoming a TH.Type's | |
synonym (issue #7021) | |
--- | |
compiler/deSugar/DsMeta.hs | 53 +++++++++++++++++++---------------------- | |
compiler/hsSyn/Convert.lhs | 16 +++++-------- | |
compiler/typecheck/TcSplice.lhs | 41 +++++++++++++++++++++++-------- |