Ethereum ブロックチェーンに接続するためのミドルウェア
$ # geth のインストール
$ brew install ethereum| import Data.List | |
| import Control.Monad.State | |
| type Weight = Int | |
| type Vertex = Char | |
| newtype WEdge = WEdge (Vertex, Vertex, Weight) | |
| head' :: WEdge -> Vertex | |
| head' (WEdge (x, _, _)) = x |
以下 Haskell Maxims and Arrows の翻訳
私は2001年から仕事でもプライベートでもHaskellを書いてきました。仕事で書いていたのはそのうち3年のことです。これらは私が学んだことです…
| name: ista | |
| version: 0.1.0.0 | |
| build-type: Simple | |
| cabal-version: >=1.10 | |
| executable app | |
| main-is: ista.hs | |
| ghc-options: -threaded -rtsopts -with-rtsopts=-N | |
| build-depends: base | |
| , mwc-random |
| {-# LANGUAGE RankNTypes #-} | |
| module Main where | |
| import Control.Monad | |
| import Control.Monad.IO.Class (MonadIO, liftIO) | |
| import Control.Monad.Morph (hoist, generalize) | |
| import Control.Monad.State (State, StateT) | |
| import qualified Control.Monad.State as State | |
| import Data.List (genericLength) |
| {-# LANGUAGE RankNTypes #-} | |
| action :: ((forall s. s -> s) -> IO ()) -> IO () | |
| action f = f id | |
| f :: (forall s. s -> s) -> () | |
| f _ = () | |
| main = do | |
| action (\x -> pure $ f x) |
| $ curl -XPOST -d'name=Alice' -d'age=15' http://localhost:8080/person | |
| Person {name = "Alice", age = 15} | |
| $ curl -XPOST -d'name=Bob' -d'age=16' http://localhost:8080/person | |
| Person {name = "Bob", age = 16} | |
| $ curl -XPOST -d'name=Carol' -d'age=abc' http://localhost:8080/person | |
| Bad Request. | |
| $ curl http://localhost:8080/person |
| {- | |
| - 株データAPI | |
| - http://www.orenokabu.com/apis | |
| -} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where |
| {-# LANGUAGE OverloadedStrings #-} | |
| import Control.Concurrent (threadDelay) | |
| import Control.Lens | |
| import Control.Monad.IO.Class (liftIO) | |
| import Control.Monad.State | |
| import Data.List (nub, isPrefixOf) | |
| import Data.Text.Lazy.Encoding (decodeUtf8) | |
| import Data.Text.Lens (unpacked) | |
| import qualified Network.Wreq as Wreq |