この記事はごちうさ住民 Advent Calendar 2014の2日目です。 あとタイトルは内容にあんまり関係ありません。 みなさん、心ぴょんぴょんしてますか? 今日は、鉄道指向を使って心ぴょんぴょんしてみたいと思います。 まずは、鉄道指向プログラミングの翻訳記事を参考に、鉄道指向で用いるResultモジュールを定義します。 type ('a, 'b) t = Success of 'a | Failure of 'b let succeed x = Success x let fail x = Failure x let either successFunc failureFunc = function | Success s -> successFunc s | Failure f -> failureFunc f let plus addS addF f1 f2 r = match