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
(ns dsls.core) | |
(def x 4) | |
(comment | |
"Delaying evaluation with Quote" | |
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
{-# LANGUAGE OverloadedStrings #-} | |
module Parsing.Examples where | |
import Data.Attoparsec.Text | |
import Control.Applicative | |
something :: Parser (String, Maybe String) | |
something = | |
do a <- manyTill anyChar (string "--") <|> many anyChar |
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
(add-hook 'haskell-mode-hook (lambda () (run-with-idle-timer (seconds-to-time 1) t 'ghc-show-type))) |
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
class Semigroup a where | |
mappend :: a -> a -> a | |
class Semigroup a => Monoid a where | |
mempty :: a | |
mconcat :: [a] -> a | |
mconcat = foldr mappend mempty | |
instance Semigroup Int where |
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
(defn parse-necronomemoticon | |
[s] | |
(let [rdr (BufferedReader. (StringReader. s)) | |
expr (->> (line-seq rdr) (map seq) first)] | |
(match [expr] | |
[([\( \; \, \; \)] :seq)] :evil | |
:else :failure))) |
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 Untyped.Context where | |
type Context = [String] | |
mkContext :: Context | |
mkContext = [] | |
bindVarName :: Context -> String -> Context | |
bindVarName ctx x = x : ctx |
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, ScopedTypeVariables, DeriveGeneric #-} | |
module Main where | |
import Data.Aeson.Types | |
import qualified Data.ByteString.Lazy as BSL | |
import qualified Data.ByteString.UTF8 as UTF8 | |
import GHC.Generics | |
import Network.Riak |
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 DeriveGeneric | |
, FlexibleInstances | |
, OverloadedStrings | |
, ScopedTypeVariables | |
, TypeSynonymInstances #-} | |
module Main where | |
import Control.Monad | |
import Data.Aeson.Types |
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
var Lazy = require('lazy.js'); | |
function isHeads(x) { return x >= 0.5; } | |
function isTails(x) { return x < 0.5; } | |
function toss(n) { | |
var successes = Lazy.generate(function() { return Math.random(); }) | |
.take(n) | |
.filter(isHeads) | |
.size(); |
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
# Memoization doesn't get you all the way there. While a memoized | |
# function might exhibit referential transparency *at two successive | |
# callsites*, your program as a whole will not exhibit that | |
# property. An example with destructive updates of a mutable data | |
# structure, an inherently effectful operation: | |
phonebook = {} | |
# assuming this function is augmented with memoization |
OlderNewer