download for better quality - Learn about the sequence and traverse functions
through the work of Runar Bjarnason and Paul Chiusano, authors of Functional Programming in Scala https://www.manning.com/books/functional-programming-in-scala
The document discusses the Lua virtual machine (LuaVM) bytecode format and instructions. It shows an example Lua function written in bytecode format, with each instruction taking up one bytecode. The bytecode format uses registers to reference values on the stack and constants to reference values in the constant table. Common Lua operations like variable assignment and table indexing can be represented in a single bytecode instruction this way.
The document discusses graph databases and their properties. Graph databases are structured to store graph-based data by using nodes and edges to represent entities and their relationships. They are well-suited for applications with complex relationships between entities that can be modeled as graphs, such as social networks. Key graph database technologies mentioned include Neo4j, OrientDB, and TinkerPop which provides graph traversal capabilities.
Reinventing the Transaction Script (NDC London 2020)Scott Wlaschin
?
The Transaction Script pattern organizes business logic as a single procedure. It has always been considered less sophisticated and flexible than a layered architecture with a rich domain model. But is that really true?
In this talk, we'll reinvent the Transaction Script using functional programming principles. We'll see that we can still do domain-driven design, and still have code which is decoupled and reusable, all while preserving the simplicity and productivity of the original one-script-per-workflow approach.
Event : Visual Studio Users Community Japan #1
Date : 2019/09/14
ソフトウェア/サービス開発において最も後回しにされるものの代表が「パフォーマンスの向上」です。C#/.NET の最大の武器は開発生産性ですが、C# 7.0 以降はパフォーマンス向上のための機能追加が多数行われています。いくつかのポイントを押さえることで実装時からより高速なコードを書くことができるようになります。
このドキュメントでは、そんなポイントとなる箇所をふんだんにお届けします。
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
?
- The document describes how product types (built using AND) and sum types (built using OR) are used to define types for representing fruit salads and fruit snacks in F#, Haskell, Scala, and Java.
- Product types combine elements and are used to define the FruitSalad type, while sum types allow alternatives and are used to define the FruitSnack type consisting of different fruits.
- Pattern matching is demonstrated to write functions that analyze and return different strings based on the values of FruitSalad and FruitSnack types.
The document discusses the Lua virtual machine (LuaVM) bytecode format and instructions. It shows an example Lua function written in bytecode format, with each instruction taking up one bytecode. The bytecode format uses registers to reference values on the stack and constants to reference values in the constant table. Common Lua operations like variable assignment and table indexing can be represented in a single bytecode instruction this way.
The document discusses graph databases and their properties. Graph databases are structured to store graph-based data by using nodes and edges to represent entities and their relationships. They are well-suited for applications with complex relationships between entities that can be modeled as graphs, such as social networks. Key graph database technologies mentioned include Neo4j, OrientDB, and TinkerPop which provides graph traversal capabilities.
Reinventing the Transaction Script (NDC London 2020)Scott Wlaschin
?
The Transaction Script pattern organizes business logic as a single procedure. It has always been considered less sophisticated and flexible than a layered architecture with a rich domain model. But is that really true?
In this talk, we'll reinvent the Transaction Script using functional programming principles. We'll see that we can still do domain-driven design, and still have code which is decoupled and reusable, all while preserving the simplicity and productivity of the original one-script-per-workflow approach.
Event : Visual Studio Users Community Japan #1
Date : 2019/09/14
ソフトウェア/サービス開発において最も後回しにされるものの代表が「パフォーマンスの向上」です。C#/.NET の最大の武器は開発生産性ですが、C# 7.0 以降はパフォーマンス向上のための機能追加が多数行われています。いくつかのポイントを押さえることで実装時からより高速なコードを書くことができるようになります。
このドキュメントでは、そんなポイントとなる箇所をふんだんにお届けします。
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
?
- The document describes how product types (built using AND) and sum types (built using OR) are used to define types for representing fruit salads and fruit snacks in F#, Haskell, Scala, and Java.
- Product types combine elements and are used to define the FruitSalad type, while sum types allow alternatives and are used to define the FruitSnack type consisting of different fruits.
- Pattern matching is demonstrated to write functions that analyze and return different strings based on the values of FruitSalad and FruitSnack types.
This document discusses Haskell concepts and how they compare to object-oriented programming concepts in languages like C++ and Python. It covers topics like algebraic data types, classes and instances in Haskell, and how concepts like private fields differ between Haskell and other languages. It also includes examples of data types, functions, and classes in Haskell as well as frequently asked questions about Haskell features.
Tableau Conference On Tour 2015 Tokyoで登壇した際の資料です。
サイバーエージェント アドテクスタジオでは複数の広告部門?子会社より構成されており、広告のビッグデータをTableauを利用して可視化し、業務に役立てています。
今回どのような基盤で、どのような解析をしているかについて発表させていただきました。
4. データ型の定義 (2)
data Point = Point Float Float deriving (Show)
data Shape = Circle Point Float | Rectangle Point Point
deriving (Show)
area (Circle _ r) = pi * r ^ 2
area (Rectangle (Point x1 y1) (Point x2 y2))
= (abs $ x2 - x1) * (abs $ y2 - y1)
左辺の Point はデータ型
右辺の Point は値コンストラクタ
値コンストラクタは引数を取れる
5. レコード構文
data Car = Car {
company :: String,
model :: String,
year :: Int
} deriving (Eq, Show)
car = Car {company="Ford", model="Mustang", year=1967}
6. 型引数と型コンストラクタ
data Maybe a = Nothing | Just a
data Either a b = Left a | Right b
deriving (Eq, Ord, Read, Show)
この例の a や b が型引数
Maybe や Either が型コンストラクタ
7. 型シノニム (エイリアス)
type String = [Char]
type PhoneNumber = String
type Name = String
type PhoneBook = [(Name, PhoneNumber)]
type AssocList k v = [(k, v)]
新しい型を定義するわけではない
最後の式は多相的な型シノニムの例
9. 型のエクスポート
module Shape (
Point(..),
Shape(..),
area
) where
(..) を付けると値コンストラクタが公開される
値コンストラクタを隠蔽すると抽象度が上がる
10. 型クラス制約
data Vector a = Vector a a a deriving (Show)
vplus :: (Num a) => Vector a -> Vector a -> Vector a
dotProd :: (Num a) => Vector a -> Vector a -> a
vmult :: (Num a) => Vector a -> a -> Vector a
データ宣言には型クラス制約を付けない規約
11. 再帰的なデータ型
data Tree a = EmptyTree | Node a (Tree a) (Tree a)
deriving (Show)
singleton :: a -> Tree a
treeElem :: (Ord a) => a -> Tree a -> Bool
12. 再帰的なデータ型 (2)
infixr 5 :-:
data List a = Empty | a :-: (List a)
deriving (Eq, Ord, Show, Read)
infixr 5 ^++
(^++) :: [a] -> [a] -> [a]
Empty ^++ ys = ys
(x :-: xs) ^++ ys = x :-: (xs ^++ ys)
13. 型クラスの定義
class Eq a where
(==) :: a -> a -> Bool
(/=) :: a -> a -> Bool
...
class (Eq a) => Num a where
...
14. インスタンスの手動導出
data TrafficLight = Red | Yellow | Green
instance Show TrafficLight where
...
instance Eq (Maybe m) where
(Just x == Just y) = (x == y)
(Nothing == Nothing) = True
(_ == _) = False
15. 型の調べ方
Prelude> :info Bool
data Bool = False | True -- Defined in `GHC.Types'
instance Bounded Bool -- Defined in `GHC.Enum'
instance Enum Bool -- Defined in `GHC.Enum'
instance Eq Bool -- Defined in `GHC.Classes'
instance Ord Bool -- Defined in `GHC.Classes'
instance Read Bool -- Defined in `GHC.Read'
instance Show Bool -- Defined in `GHC.Show'
16. 型クラスの調べ方
Prelude> :info Num
class Num a where
(+) :: a -> a -> a
(*) :: a -> a -> a
(-) :: a -> a -> a
negate :: a -> a
abs :: a -> a
signum :: a -> a
fromInteger :: Integer -> a
-- Defined in `GHC.Num'
instance Num Integer -- Defined in `GHC.Num'
instance Num Int -- Defined in `GHC.Num'
instance Num Float -- Defined in `GHC.Float'
instance Num Double -- Defined in `GHC.Float'