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 Calc where | |
import ToyParser | |
choiceChar :: Char -> Char -> Parser Char Char | |
choiceChar a b = char a </> char b | |
valueP :: Parser Char Int | |
valueP = num </> (char '(' +> exprP <+ char ')') |
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 Control.Monad | |
nothingMaybe :: Maybe Int | |
nothingMaybe = do | |
a <- Just 4 | |
Nothing | |
return a |
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.IO | |
import System.Directory | |
import qualified Data.Map as M | |
import Data.List.Split | |
-- リストのリストを結合し、一つのリストにする | |
flatten :: [[a]] -> [a] | |
flatten [] = [] | |
flatten (x:xs) = x ++ flatten xs |
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 qualified Data.Char as C | |
type FirstName = String | |
type LastName = String | |
flatten :: [[a]] -> [a] | |
flatten [] = [] | |
flatten (x:xs) = x ++ flatten xs | |
toUpper :: String -> 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
import std.stdio; | |
interface Functor(T) { | |
Functor!T fmap(Functor!T delegate(T) lam); | |
} | |
class TestFunctor(T) : Functor!T { | |
private T _value; | |
this(T value) { |
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 std.stdio; | |
class Test { | |
private string _value; | |
this(string value) { | |
this._value = value; | |
} | |
Test opOpAssign(string op)(Test delegate(string) test) if(op == ">>") { |
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 std.stdio; | |
enum udaprop = "udaprop"; | |
class UDATest { | |
@udaprop private int intProperty; | |
@udaprop private string stringProperty; | |
private float floatProperty; | |
} |
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 std.stdio; | |
mixin template Foo() { | |
void show() { | |
this.member.writeln; | |
} | |
} | |
class Bar { | |
mixin Foo; |
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
class Class(T) { | |
private bool[string] methods; | |
this() { | |
initialize(); | |
} | |
void initialize() { | |
foreach(member; __traits(derivedMembers, T)) { | |
if(__traits(isVirtualFunction, mixin("T." ~ member))) { |
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
var SERVER_PORT = 80; | |
var LIFE_TIME = 30000; | |
var REDIS_HOST = "xxx.xxx.xxx"; | |
var REDIS_PORT = 6379; | |
var http = require('http'); | |
var io = require('socket.io'); | |
var server = http.createServer(); | |
var manager = null; |