This is my recommended path for learning Haskell.
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(function_options). | |
| -export([my_fn/1, my_fn/2]). | |
| -include_lib("eunit/include/eunit.hrl"). | |
| %% we'll populate a record with all of our interesting pieces. this also allows the specification of | |
| %% defaults for things the user may not provide. required_arg will hold our required param, so we'll | |
| %% leave them undefined. anything that starts with opt, however may or may not be supplied |
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
| > (macroexpand '(include-lib "webmachine/include/webmachine.hrl")) | |
| (progn | |
| (defrecord wm_reqdata | |
| method | |
| scheme | |
| version | |
| peer | |
| sock | |
| wm_state | |
| disp_path |
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
| sequenceUntil :: Monad m => (a -> Bool) -> [m a] -> m [a] | |
| sequenceUntil _ [] = return [] | |
| sequenceUntil p (m:ms) = do a <- m | |
| if p a | |
| then return $ init [a] | |
| else do as <- sequenceUntil p ms | |
| return (a:as) |
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
| // Package readyset provides a simple set implementation. | |
| package readyset | |
| import "fmt" | |
| // Set is a container for arbitrary data which ensures that duplicates elements will not be stored multiple times. | |
| type Set map[interface{}]struct{} | |
| // NewSet creates a new Set containing the given elements. | |
| func NewSet(in ...interface{}) Set { |
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
| {-# OPTIONS -Wall #-} | |
| module Main where | |
| import Control.Concurrent (threadDelay) | |
| import System.Environment (getArgs) | |
| import System.INotify | |
| main :: IO () | |
| main = do |
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
| (ns immutant.init | |
| (:require [immutant.messaging :as msg] | |
| [immutant.pipeline :as pl] | |
| [clojure.tools.logging :as log])) | |
| (defn add-two [m] | |
| (log/info "add-two processing" m) | |
| (+ 2 m)) |
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
| package main | |
| // This is a basic example of running an nsqd instance embedded. It creates | |
| // and runs an nsqd with all of the default options, and then produces | |
| // and consumes a single message. You are probably better off running a | |
| // standalone instance, but embedding it can simplify deployment and is | |
| // useful in testing. | |
| // See https://github.com/nsqio/nsq/blob/master/nsqd/options.go and | |
| // https://github.com/nsqio/nsq/blob/master/apps/nsqd/nsqd.go for |
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
| (require '[clojure.walk :refer [postwalk]] | |
| [clojure.string :as s]) | |
| (defn keyword-to-property | |
| "Replace :foo-bar with \"foo.bar\", etc." | |
| [k] | |
| (s/replace (name k) #"\-" ".")) | |
| (defn propertyize-map | |
| "Recursively transforms all map keys from keywords to Java property strings and values to strings (if necessary)." |
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
| package groupcache_expire | |
| import ( | |
| "log" | |
| "strings" | |
| "time" | |
| "github.com/golang/groupcache" | |
| ) |