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 it. | |
> newtype End = End (Request -> Maybe Request) | |
> newtype Node = Node (Request -> Maybe Request) | |
> Node granny // Node mom = Node (mom <=< granny) | |
> Node mom /> End son = End (son <=< mom) | |
> End left \/ End right = End (left `orelse` right) |
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 RecordWildCards #-} | |
import Control.Monad | |
{- | |
Later, `Class {..}` will autobind all attributes to their names | |
in the field of visibility | |
-} | |
data Structure = Class { name :: String | |
, abilities :: Structure |
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 System.Environment | |
import System.IO | |
import System.Directory | |
import Data.String.Utils | |
import Control.Monad | |
main = do places <- getArgs | |
let place = if places == [] |
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 RecordWildCards #-} | |
module TaskGen where | |
import Control.Monad | |
data Task = Task { combos :: [String] | |
, description :: String | |
, actions :: [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 FunctionalDependencies, | |
FlexibleInstances #-} | |
module Parser where | |
import Control.Monad | |
newtype Parser e s a = Parser { runParser :: s -> Either (Error e s) (a, s) } | |
data Error a b = Error a String b deriving Show |
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 (llist). | |
-compile(export_all). | |
unfold(X, F) -> | |
case F(X) of | |
{ok, X1} -> [X1 | fun() -> unfold(X1, F) end]; | |
false -> [] | |
end. |
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 FlashHelper | |
[:success, :info].each do |kind| | |
define_method "flash_#{kind}" do |options = {}| | |
msg = options[:message] || kind | |
flash_notice message: msg, kind: kind, now: options[:now] | |
end | |
end | |
def flash_error(options = {}) |
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 Adapter where | |
import qualified Data.Map as Map | |
_create :: Ord k => k -> v -> Map k v -> Map k v | |
_create = Map.insert | |
_update :: Ord k => k -> v -> Map k v -> Map k v | |
_update = Map.insert |
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
int main(int argc, char *argv[]) { | |
int count = 10, silent = 0; | |
char * command = 0; | |
char letter; | |
while ((letter = getopt_long(argc, argv, "n:c:s")) != -1) { | |
switch (letter) { | |
case 'n': | |
count = atoi(optarg); | |
break; |
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.List | |
import System.Environment | |
import System.IO | |
import System.Directory | |
import Data.String.Utils hiding (join) | |
import Control.Monad | |
import System.FilePath.Posix |