SlideShare une entreprise Scribd logo
1  sur  59
Télécharger pour lire hors ligne
Hierarchical Free Monads
& Software Design
in Functional Programming
Functional Conf, Bangalore, 2019
1
Alexander Granin
graninas@gmail.com, Twitter: @graninas
Plan
● About me
● Software Design in Haskell
● Software Design Principles
● Hierarchical Free Monads
● Conclusion
● My Links
2
About me
Developer Haskell, PureScript, C++, C#, Python
Worked for Juspay, Restaumatic, Kaspersky Lab, 2GIS, Enecuum
Experience >10 years: web-services, data analysis, backends
Researcher Functional Software Design in Haskell & C++
Author Book “Functional Design and Architecture”
Speaker FPConf, C++ Russia, Dev2Dev, FPure, meetups…
Organizer C++ Russia (Program Committee); LambdaNsk (leader)
3
4
Software Design in Haskell
Babyhood
5
Childhood: Bare IO
main :: IO ()
main = do
let res1 = pureFunc1 1 2
let res2 = pureFunc2 3 “ab”
impureFunc res1 res2
impureFunc :: Int -> String -> IO ()
impureFunc result = ...
pureFunc1 :: Int -> Int -> Int
pureFunc1 a b = …
pureFunc2 :: Int -> String -> String
pureFunc2 a s = ...
Impure Pure
6
Boyhood: Monad Stacks
main :: IO ()
main = runGame initialState
runGame :: GameSt -> IO ()
runGame st = do
let (r, st’) = runStateT gameTurn st
putStrLn (“Game state: ” ++ show st’)
putStrLn (“Turn result: ” ++ show r)
case r of
Continue -> runGame st’
EndOfGam -> pure ()
data GameSt = GameSt
{ hitPoints :: Int
, score :: Int
}
type GameApp a = StateT GameSt IO a
data TurnResult = EndOfGame Int | Continue
gameTurn :: GameApp TurnResult
gameTurn = ...
Runtime Application
7
Boyhood: Service Handle Pattern
data Handle = Handle
{ logger :: (String -> IO ())
}
logSomething :: Handle -> String -> IO ()
logSomething (Handle logger) msg = logger msg
main :: IO ()
main = do
let handle = Handle { logger = putStrLn }
logSomething handle "Hello World!"
8
Boyhood: ReaderT Pattern
data Env = Env
{ logger :: (String -> IO ())
}
class HasLog a where
getLog :: a -> (String -> IO ())
instance HasLog (String -> IO ()) where
getLog = id
instance HasLog Env where
getLog = envLog
logSomething
:: (MonadReader env m, HasLog env, MonadIO m)
=> String
-> m ()
logSomething msg = do
env <- ask
liftIO $ getLog env msg
9
Youthhood: Effect Systems
class Monad m => Logger m where
logMessage :: LogLevel -> Message -> m ()
class Monad m => Random m where
getRandomInt :: (Int, Int) -> m Int
class (Logger m, Random m) => Lang m
someFunc :: Lang m => m ()
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
10
Youthhood: Effect Systems
someFunc
:: forall e
. Eff
( avar :: AVAR
, exception :: EXCEPTION
, fs :: FS
, console :: CONSOLE
| e)
Result
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
11
Youthhood: Effect Systems
data FileSystem r where
ReadFile :: FilePath -> FileSystem String
WriteFile :: FilePath -> String -> FileSystem ()
readFile1 :: Member FileSystem effs => FilePath -> Eff effs String
readFile2 :: FilePath -> Eff '[FileSystem] String
runFileSystem :: Eff (FileSystem ': effs) ~> Eff effs
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
12
Youthhood: Effect Systems
data Log v where
Log :: String -> Log ()
log :: Member Log r => String -> Eff r ()
runLogger :: Eff (Log :> r) a -> Eff r (a, [String])
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
13
Youthhood: Effect Systems
data State s v where
Get :: State s s
Put :: s -> State s ()
get :: Member (State s) r => Eff r s
runState :: Eff (State s ': r) a -> s -> Eff r (a, s)
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
14
Youthhood: Effect Systems
data Teletype s where
PutStrLn :: String -> Teletype ()
GetLine :: Teletype String
ExitSuccess :: Teletype ()
putStrLn' :: Member Teletype r => String -> Eff r ()
runTeletype :: Eff '[Teletype] w -> IO w
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
15
Youthhood: Effect Systems
data Teletype m a where
ReadTTY :: Teletype m String
WriteTTY :: String -> Teletype m ()
echo :: Member Teletype r => Sem r ()
runTeletype
:: Member (Embed IO) r
=> Sem (Teletype ': r) a -> Sem r a
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
16
Youthhood: Effect Systems
No Sample
(Sorry, I’m tired)
● Final Tagless / mtl
● PureScript 0.11
Effect System
● freer-simple
● extensible-effects
● freer-effects
● freer
● polysemy
● capability
17
18
“Mathy” approaches in Haskell
(Youthful Maxi-Mathism)
Adulthood: Frameworks
cake-slayer
RIO
Yesod
Hydra
Node
Servant
ZIO
PureScript
Presto
PureScript
Presto Backend
19
Oldness: Dependent Types
?
20
21
Software Design Principles
Inversion of Control
Why? How? When?
22
Inversion of Control
Why?
Complexity reducing
Abstraction
Separation of concerns
Low coupling
Effects control
Testability
Maintainability
How? When?
23
Inversion of Control
Why?
Complexity reducing
Abstraction
Separation of concerns
Low coupling
Effects control
Testability
Maintainability
How?
Final Tagless
Free Monad
Service Handle Pattern
ReaderT Pattern
...
When?
24
Inversion of Control
Why?
Complexity reducing
Abstraction
Separation of concerns
Low coupling
Effects control
Testability
Maintainability
How?
Final Tagless
Free Monad
Service Handle Pattern
ReaderT Pattern
...
When?
Big applications
Complex domain
Long lifecycle
Team development
25
SOLID Principles?
26
SOLID Principles?
27
Layering
“A Modern Architecture for FP”, John De Goes
(“Onion Architecture”)
“Three Layer Haskell Cake”, Matt Parsons
Interfaces / Effects
(eDSLs)
Business Logic
Implementation /
Runtime
28
29
Hierarchical Free Monads
Sequelize
KVDB
Flow
Runtime, Interpreters, Configs, Environment
Application
SqlDB
Logger
App
State
Business
Logic
App
Configs
30
Presto.Backend Framework (Juspay)
Implementation & Runtime
Interfaces
(Hierarchical Free Monad eDSLs)
Domain & Business Logic
Redis
SysCmd
https://github.com/juspay/purescript-presto-backend
31
Hydra Framework
Implementation & Runtime
Interfaces
(Hierarchical Free Monad eDSLs)
Domain & Business Logic
https://github.com/graninas/Hydra
ProcessL
Runtime, Interpreters, Configs, Environment
Application
Domain
Model
Business
Logic
DB Model
AppL
SqlDBL
LangL
Beam
LoggerL
StateL
32
Sample REST Application with Hydra: Astro
33
Domain Model
type MeteorID = Int
data Coords = Coords
{ azimuth :: Int
, altitude :: Int
}
data Meteor = Meteor
{ meteorId :: MeteorID
, size :: Int
, mass :: Int
, coords :: Coords
}
type Meteors = [Meteor]
Application
Domain
Model
34
DB Model: DB Table (beam-powered)
data MeteorDbT f = MeteorDb
{ meteorDbId :: C f Int
, meteorDbSize :: C f Int
, meteorDbMass :: C f Int
, meteorDbAzimuth :: C f Int
, meteorDbAltitude :: C f Int
} deriving (Generic, Beamable)
type MeteorDb = MeteorDbT Identity
Application
Domain
Model
DB Model
35
DB Model: DB Scheme (beam-powered)
data MeteorDbT f = MeteorDb
{ meteorDbId :: C f Int
, meteorDbSize :: C f Int
, meteorDbMass :: C f Int
, meteorDbAzimuth :: C f Int
, meteorDbAltitude :: C f Int
} deriving (Generic, Beamable)
type MeteorDb = MeteorDbT Identity
data AstroDb f = AstroDb
{ meteorsDbTable
:: f (TableEntity MeteorDbT)
} deriving (Generic, Database be)
astroDb :: DatabaseSettings be AstroDb
astroDb = defaultDbSettings
Application
Domain
Model
DB Model
36
Business Logic Scenarios
getMeteors
:: SqlConn SqliteM
-> AppL Meteors
getMeteors conn = do
AppL
Application
Domain
Model
Business
Logic
DB Model
37
Business Logic Scenarios
getMeteors
:: SqlConn SqliteM
-> AppL Meteors
getMeteors conn = do
eDbRows <- scenario
$ runDB conn
$ findRows
$ Beam.select
$ Beam.all_ (meteorsDb astroDb)
SqlDBL
AppL
Application
LangL
Domain
Model
Business
Logic
DB Model
AppL
SqlDBL
Beam
Beam
LangL
38
Business Logic Scenarios
getMeteors
:: SqlConn SqliteM
-> AppL Meteors
getMeteors conn = do
eDbRows <- scenario
$ runDB conn
$ findRows
$ Beam.select
$ Beam.all_ (meteorsDb astroDb)
dbRows <- case eDbRows of
Right ms -> pure ms
Left err -> do
logError (show err)
pure []
pure (map fromDBMeteor dbRows)
AppL
Application
Domain
Model
Business
Logic
DB Model
LoggerL
SqlDBL
LangL
Beam
LoggerL
39
Free Monad Runner & Runtime
data AppRuntime = AppRuntime
{ rocksDBs :: RocksDBHandles
, redisConns :: RedisConnections
, loggerRuntime :: LoggerRuntime
, stateRuntime :: StateRuntime
, sqlConns :: MVar (Map ConnTag NativeSqlConn)
}
runApp' :: AppL a -> IO a
runApp' act = bracket
createAppRuntime
clearAppRuntime
(rt -> runApp rt act)
Runtime, Interpreters, Configs, Environment
Application
Domain
Model
Business
Logic
DB Model
AppL
LoggerL
SqlDBL
LangL
Beam
40
AppL Free Monad Language
data AppF next where
EvalLang
:: LangL a
-> (a -> next)
-> AppF next
InitSqlDB
:: DBConfig beM
-> (DBResult (SqlConn beM) -> next)
-> AppF next
type AppL = Free AppF
scenario :: LangL a -> AppL a
scenario act = liftF (EvalLang act id)
ProcessL
Runtime, Interpreters, Configs, Environment
Application
Domain
Model
Business
Logic
DB Model
AppL
SqlDBL
LangL
Beam
LoggerL
StateL
41
Nested Free Monad Language
data LoggerF next where
LogMessage
:: LogLevel
-> Message
-> (() -> next)
-> LoggerMethod next
type LoggerL = Free LoggerF
logMessage
:: LogLevel
-> Message
-> LoggerL ()
logMessage lvl msg =
liftF (LogMessage lvl msg id)
ProcessL
Runtime, Interpreters, Configs, Environment
Application
Domain
Model
Business
Logic
DB Model
AppL
SqlDBL
LangL
Beam
LoggerL
StateL
42
Free Monad Language Interpreter
runFlow :: AppRuntime -> AppL a -> IO a
runFlow appRt = foldFree (interpretAppF appRt)
interpretAppF :: AppRuntime -> AppF a -> IO a
interpretAppF appRt (EvalLang act next) =
next <$> runLangL appRt act
LangL
LoggerL
AppL
AppL
Interpreter
43
Nested Free Monad Interpreter
runFlow :: AppRuntime -> AppL a -> IO a
runFlow appRt = foldFree (interpretAppF appRt)
interpretAppF :: AppRuntime -> AppF a -> IO a
interpretAppF appRt (EvalLang act next) =
next <$> runLangL appRt act
runLangL :: AppRuntime -> LangL a -> IO a
runLangL appRt = foldFree (interpretLangF appRt)
interpretLangF :: AppRuntime -> LangF a -> IO a
interpretLangF appRt (EvalLogger act next) =
next <$> runLoggerL appRt act
LangL
LoggerL
LangL
Interpreter
AppL
AppL
Interpreter
44
Nested Free Monad Interpreters
runFlow :: AppRuntime -> AppL a -> IO a
runFlow appRt = foldFree (interpretAppF appRt)
interpretAppF :: AppRuntime -> AppF a -> IO a
interpretAppF appRt (EvalLang act next) =
next <$> runLangL appRt act
runLangL :: AppRuntime -> LangL a -> IO a
runLangL appRt = foldFree (interpretLangF appRt)
interpretLangF :: AppRuntime -> LangF a -> IO a
interpretLangF appRt (EvalLogger act next) =
next <$> runLoggerL appRt act
runLoggerL :: LoggerRuntime -> LoggerL () -> IO ()
LangL
LoggerL
Real Logger
LangL
Interpreter
LoggerL
Interpreter
AppL
AppL
Interpreter
45
REST API Description (Servant-based)
type AstroAPI
= ( "meteors"
:> QueryParam "mass" Int
:> QueryParam "size" Int
:> Get '[JSON] Meteors
)
:<|>
( "meteor"
:> ReqBody '[JSON] MeteorTemplate
:> Post '[JSON] MeteorID
)
:<|> EmptyAPI
astroAPI :: Proxy AstroAPI
astroAPI = Proxy
46
API Handlers (Servant Handler + Free Monad)
data Env = Env AppRuntime
type AppHandler = ReaderT Env (ExceptT ServerError IO)
type AppServer = ServerT AstroAPI AppHandler
astroServer' :: AppServer
astroServer' = meteors :<|> meteor :<|> emptyServer
47
API Handlers (Servant Handler + Free Monad)
data Env = Env AppRuntime
type AppHandler = ReaderT Env (ExceptT ServerError IO)
type AppServer = ServerT AstroAPI AppHandler
astroServer' :: AppServer
astroServer' = meteors :<|> meteor :<|> emptyServer
meteors :: Maybe Int -> Maybe Int -> AppHandler Meteors
meteors mbMass mbSize = withAppRuntime $ do
conn <- connectOrFail $ mkSQLiteConfig "astroDB" "/tmp/astro.db"
getMeteors' mbMass mbSize conn
48
API Handlers (Servant Handler + Free Monad)
data Env = Env AppRuntime
type AppHandler = ReaderT Env (ExceptT ServerError IO)
type AppServer = ServerT AstroAPI AppHandler
astroServer' :: AppServer
astroServer' = meteors :<|> meteor :<|> emptyServer
meteors :: Maybe Int -> Maybe Int -> AppHandler Meteors
meteors mbMass mbSize = withAppRuntime $ do
conn <- connectOrFail $ mkSQLiteConfig "astroDB" "/tmp/astro.db"
getMeteors' mbMass mbSize conn
withAppRuntime :: AppL a -> AppHandler a
withAppRuntime flow = do
Env appRt <- ask
lift $ lift $ runApp appRt flow
49
Hierarchical Free Monads: Conclusions
50
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
51
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
● Simplicity: hierarchical nesting frees from type level magic
52
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
● Simplicity: hierarchical nesting frees from type level magic
● Layering: the application is highly maintainable
53
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
● Simplicity: hierarchical nesting frees from type level magic
● Layering: the application is highly maintainable
● Convenience: easy to write business logic
54
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
● Simplicity: hierarchical nesting frees from type level magic
● Layering: the application is highly maintainable
● Convenience: easy to write business logic
● No magic: languages and interpreters are just values
55
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
● Simplicity: hierarchical nesting frees from type level magic
● Layering: the application is highly maintainable
● Convenience: easy to write business logic
● No magic: languages and interpreters are just values
● Boilerplate: absent on the business logic layer
56
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
● Simplicity: hierarchical nesting frees from type level magic
● Layering: the application is highly maintainable
● Convenience: easy to write business logic
● No magic: languages and interpreters are just values
● Boilerplate: absent on the business logic layer
● Performance: Church-Encoded Free Monads are fast
57
Hierarchical Free Monads: Conclusions
● Accidental complexity: reduced dramatically
● Simplicity: hierarchical nesting frees from type level magic
● Layering: the application is highly maintainable
● Convenience: easy to write business logic
● No magic: languages and interpreters are just values
● Boilerplate: absent on the business logic layer
● Performance: Church-Encoded Free Monads are fast
● Killer feature: automatic white-box (regression) testing
58
My Links
● “Functional Design and Architecture” book Patreon program
● “Functional Design and Architecture” book page
● “Hydra” (framework & comparison of FM, Church Encoded FM and FT)
● “Node” (real-world framework for building distributed concurrent apps)
● Automatic White-Box Testing with Free Monads (article & showcase)
● stm-free: STM with Free Monads (PoC & showcase)
● cpp_stm_free: STM with Free Monads in C++ (PoC & showcase)
● My talks
Free Monads are Powerful and Fast.
Alexander Granin
graninas@gmail.com, Twitter: @graninas
Functional Conf, Bangalore, 2019
59

Contenu connexe

Tendances

Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Leonardo Borges
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Nishan Barot
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)mehul patel
 
GeeCon 2016 - Beyond Lambdas, the Aftermath
GeeCon 2016 - Beyond Lambdas, the AftermathGeeCon 2016 - Beyond Lambdas, the Aftermath
GeeCon 2016 - Beyond Lambdas, the AftermathDaniel Sawano
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Trisha Gee
 
Spotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the AftermathSpotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the AftermathDaniel Sawano
 
JDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the AftermathJDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the AftermathDaniel Sawano
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL fileRACHIT_GUPTA
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()daewon jeong
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015NAVER / MusicPlatform
 
JAVA 8 : Migration et enjeux stratégiques en entreprise
JAVA 8 : Migration et enjeux stratégiques en entrepriseJAVA 8 : Migration et enjeux stratégiques en entreprise
JAVA 8 : Migration et enjeux stratégiques en entrepriseSOAT
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and UtilitiesPramod Kumar
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present FutureIndicThreads
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersBartosz Kosarzycki
 
Is java8a truefunctionallanguage
Is java8a truefunctionallanguageIs java8a truefunctionallanguage
Is java8a truefunctionallanguageSamir Chekkal
 
Is java8 a true functional programming language
Is java8 a true functional programming languageIs java8 a true functional programming language
Is java8 a true functional programming languageSQLI
 
Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8RichardWarburton
 

Tendances (20)

Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
GeeCon 2016 - Beyond Lambdas, the Aftermath
GeeCon 2016 - Beyond Lambdas, the AftermathGeeCon 2016 - Beyond Lambdas, the Aftermath
GeeCon 2016 - Beyond Lambdas, the Aftermath
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Spotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the AftermathSpotify 2016 - Beyond Lambdas - the Aftermath
Spotify 2016 - Beyond Lambdas - the Aftermath
 
Java practical
Java practicalJava practical
Java practical
 
JDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the AftermathJDays 2016 - Beyond Lambdas - the Aftermath
JDays 2016 - Beyond Lambdas - the Aftermath
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL file
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
 
JAVA 8 : Migration et enjeux stratégiques en entreprise
JAVA 8 : Migration et enjeux stratégiques en entrepriseJAVA 8 : Migration et enjeux stratégiques en entreprise
JAVA 8 : Migration et enjeux stratégiques en entreprise
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 
Is java8a truefunctionallanguage
Is java8a truefunctionallanguageIs java8a truefunctionallanguage
Is java8a truefunctionallanguage
 
Is java8 a true functional programming language
Is java8 a true functional programming languageIs java8 a true functional programming language
Is java8 a true functional programming language
 
Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8
 

Similaire à Hierarchical free monads and software design in fp

Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applicationsRoman Podoliaka
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 itiAhmed mar3y
 
Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11Matt Warren
 
Apache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapApache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapKostas Tzoumas
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonCodemotion
 
The Ring programming language version 1.5.1 book - Part 25 of 180
The Ring programming language version 1.5.1 book - Part 25 of 180The Ring programming language version 1.5.1 book - Part 25 of 180
The Ring programming language version 1.5.1 book - Part 25 of 180Mahmoud Samir Fayed
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_netNico Ludwig
 
Final tagless vs free monad
Final tagless vs free monadFinal tagless vs free monad
Final tagless vs free monadAlexander Granin
 
Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016Matt Warren
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8franciscoortin
 
Functional patterns and techniques in C#
Functional patterns and techniques in C#Functional patterns and techniques in C#
Functional patterns and techniques in C#Péter Takács
 
Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityMarcin Stepien
 
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeKotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeVíctor Leonel Orozco López
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DMithun Hunsur
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
 

Similaire à Hierarchical free monads and software design in fp (20)

Performance is a Feature!
Performance is a Feature!Performance is a Feature!
Performance is a Feature!
 
Flink internals web
Flink internals web Flink internals web
Flink internals web
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11Performance is a Feature! at DDD 11
Performance is a Feature! at DDD 11
 
Apache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapApache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmap
 
SOLID Ruby SOLID Rails
SOLID Ruby SOLID RailsSOLID Ruby SOLID Rails
SOLID Ruby SOLID Rails
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - Warburton
 
The Ring programming language version 1.5.1 book - Part 25 of 180
The Ring programming language version 1.5.1 book - Part 25 of 180The Ring programming language version 1.5.1 book - Part 25 of 180
The Ring programming language version 1.5.1 book - Part 25 of 180
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
Final tagless vs free monad
Final tagless vs free monadFinal tagless vs free monad
Final tagless vs free monad
 
Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016Performance and how to measure it - ProgSCon London 2016
Performance and how to measure it - ProgSCon London 2016
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8
 
Functional patterns and techniques in C#
Functional patterns and techniques in C#Functional patterns and techniques in C#
Functional patterns and techniques in C#
 
Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for Maintainability
 
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeKotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 

Plus de Alexander Granin

Concurrent applications with free monads and stm
Concurrent applications with free monads and stmConcurrent applications with free monads and stm
Concurrent applications with free monads and stmAlexander Granin
 
The present and the future of functional programming in c++
The present and the future of functional programming in c++The present and the future of functional programming in c++
The present and the future of functional programming in c++Alexander Granin
 
О разработке десктопных приложений / About desktop development
О разработке десктопных приложений / About desktop developmentО разработке десктопных приложений / About desktop development
О разработке десктопных приложений / About desktop developmentAlexander Granin
 
Принципы и практики разработки ПО 2 / Principles and practices of software de...
Принципы и практики разработки ПО 2 / Principles and practices of software de...Принципы и практики разработки ПО 2 / Principles and practices of software de...
Принципы и практики разработки ПО 2 / Principles and practices of software de...Alexander Granin
 
Принципы и практики разработки ПО / Principles and practices of software deve...
Принципы и практики разработки ПО / Principles and practices of software deve...Принципы и практики разработки ПО / Principles and practices of software deve...
Принципы и практики разработки ПО / Principles and practices of software deve...Alexander Granin
 
Закон Деметры / Demetra's law
Закон Деметры / Demetra's lawЗакон Деметры / Demetra's law
Закон Деметры / Demetra's lawAlexander Granin
 
Design of big applications in FP
Design of big applications in FPDesign of big applications in FP
Design of big applications in FPAlexander Granin
 
GitHub - зеркало разработчика
GitHub - зеркало разработчикаGitHub - зеркало разработчика
GitHub - зеркало разработчикаAlexander Granin
 
The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++Alexander Granin
 
Functional programming in C++ LambdaNsk
Functional programming in C++ LambdaNskFunctional programming in C++ LambdaNsk
Functional programming in C++ LambdaNskAlexander Granin
 
Transition graph using free monads and existentials
Transition graph using free monads and existentialsTransition graph using free monads and existentials
Transition graph using free monads and existentialsAlexander Granin
 
Software transactional memory. pure functional approach
Software transactional memory. pure functional approachSoftware transactional memory. pure functional approach
Software transactional memory. pure functional approachAlexander Granin
 
Вы не понимаете ФП / You don't understand FP
Вы не понимаете ФП / You don't understand FPВы не понимаете ФП / You don't understand FP
Вы не понимаете ФП / You don't understand FPAlexander Granin
 
Functional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonadsFunctional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonadsAlexander Granin
 
Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Alexander Granin
 
Дизайн больших приложений в ФП
Дизайн больших приложений в ФПДизайн больших приложений в ФП
Дизайн больших приложений в ФПAlexander Granin
 
Линзы - комбинаторная манипуляция данными
Линзы - комбинаторная манипуляция даннымиЛинзы - комбинаторная манипуляция данными
Линзы - комбинаторная манипуляция даннымиAlexander Granin
 
Линзы - комбинаторная манипуляция данными (Dev2Dev)
Линзы - комбинаторная манипуляция данными (Dev2Dev)Линзы - комбинаторная манипуляция данными (Dev2Dev)
Линзы - комбинаторная манипуляция данными (Dev2Dev)Alexander Granin
 
Идиоматичный функциональный код
Идиоматичный функциональный кодИдиоматичный функциональный код
Идиоматичный функциональный кодAlexander Granin
 

Plus de Alexander Granin (20)

Concurrent applications with free monads and stm
Concurrent applications with free monads and stmConcurrent applications with free monads and stm
Concurrent applications with free monads and stm
 
Monadic parsers in C++
Monadic parsers in C++Monadic parsers in C++
Monadic parsers in C++
 
The present and the future of functional programming in c++
The present and the future of functional programming in c++The present and the future of functional programming in c++
The present and the future of functional programming in c++
 
О разработке десктопных приложений / About desktop development
О разработке десктопных приложений / About desktop developmentО разработке десктопных приложений / About desktop development
О разработке десктопных приложений / About desktop development
 
Принципы и практики разработки ПО 2 / Principles and practices of software de...
Принципы и практики разработки ПО 2 / Principles and practices of software de...Принципы и практики разработки ПО 2 / Principles and practices of software de...
Принципы и практики разработки ПО 2 / Principles and practices of software de...
 
Принципы и практики разработки ПО / Principles and practices of software deve...
Принципы и практики разработки ПО / Principles and practices of software deve...Принципы и практики разработки ПО / Principles and practices of software deve...
Принципы и практики разработки ПО / Principles and practices of software deve...
 
Закон Деметры / Demetra's law
Закон Деметры / Demetra's lawЗакон Деметры / Demetra's law
Закон Деметры / Demetra's law
 
Design of big applications in FP
Design of big applications in FPDesign of big applications in FP
Design of big applications in FP
 
GitHub - зеркало разработчика
GitHub - зеркало разработчикаGitHub - зеркало разработчика
GitHub - зеркало разработчика
 
The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++
 
Functional programming in C++ LambdaNsk
Functional programming in C++ LambdaNskFunctional programming in C++ LambdaNsk
Functional programming in C++ LambdaNsk
 
Transition graph using free monads and existentials
Transition graph using free monads and existentialsTransition graph using free monads and existentials
Transition graph using free monads and existentials
 
Software transactional memory. pure functional approach
Software transactional memory. pure functional approachSoftware transactional memory. pure functional approach
Software transactional memory. pure functional approach
 
Вы не понимаете ФП / You don't understand FP
Вы не понимаете ФП / You don't understand FPВы не понимаете ФП / You don't understand FP
Вы не понимаете ФП / You don't understand FP
 
Functional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonadsFunctional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonads
 
Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Functional microscope - Lenses in C++
Functional microscope - Lenses in C++
 
Дизайн больших приложений в ФП
Дизайн больших приложений в ФПДизайн больших приложений в ФП
Дизайн больших приложений в ФП
 
Линзы - комбинаторная манипуляция данными
Линзы - комбинаторная манипуляция даннымиЛинзы - комбинаторная манипуляция данными
Линзы - комбинаторная манипуляция данными
 
Линзы - комбинаторная манипуляция данными (Dev2Dev)
Линзы - комбинаторная манипуляция данными (Dev2Dev)Линзы - комбинаторная манипуляция данными (Dev2Dev)
Линзы - комбинаторная манипуляция данными (Dev2Dev)
 
Идиоматичный функциональный код
Идиоматичный функциональный кодИдиоматичный функциональный код
Идиоматичный функциональный код
 

Dernier

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 

Dernier (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 

Hierarchical free monads and software design in fp

  • 1. Hierarchical Free Monads & Software Design in Functional Programming Functional Conf, Bangalore, 2019 1 Alexander Granin graninas@gmail.com, Twitter: @graninas
  • 2. Plan ● About me ● Software Design in Haskell ● Software Design Principles ● Hierarchical Free Monads ● Conclusion ● My Links 2
  • 3. About me Developer Haskell, PureScript, C++, C#, Python Worked for Juspay, Restaumatic, Kaspersky Lab, 2GIS, Enecuum Experience >10 years: web-services, data analysis, backends Researcher Functional Software Design in Haskell & C++ Author Book “Functional Design and Architecture” Speaker FPConf, C++ Russia, Dev2Dev, FPure, meetups… Organizer C++ Russia (Program Committee); LambdaNsk (leader) 3
  • 6. Childhood: Bare IO main :: IO () main = do let res1 = pureFunc1 1 2 let res2 = pureFunc2 3 “ab” impureFunc res1 res2 impureFunc :: Int -> String -> IO () impureFunc result = ... pureFunc1 :: Int -> Int -> Int pureFunc1 a b = … pureFunc2 :: Int -> String -> String pureFunc2 a s = ... Impure Pure 6
  • 7. Boyhood: Monad Stacks main :: IO () main = runGame initialState runGame :: GameSt -> IO () runGame st = do let (r, st’) = runStateT gameTurn st putStrLn (“Game state: ” ++ show st’) putStrLn (“Turn result: ” ++ show r) case r of Continue -> runGame st’ EndOfGam -> pure () data GameSt = GameSt { hitPoints :: Int , score :: Int } type GameApp a = StateT GameSt IO a data TurnResult = EndOfGame Int | Continue gameTurn :: GameApp TurnResult gameTurn = ... Runtime Application 7
  • 8. Boyhood: Service Handle Pattern data Handle = Handle { logger :: (String -> IO ()) } logSomething :: Handle -> String -> IO () logSomething (Handle logger) msg = logger msg main :: IO () main = do let handle = Handle { logger = putStrLn } logSomething handle "Hello World!" 8
  • 9. Boyhood: ReaderT Pattern data Env = Env { logger :: (String -> IO ()) } class HasLog a where getLog :: a -> (String -> IO ()) instance HasLog (String -> IO ()) where getLog = id instance HasLog Env where getLog = envLog logSomething :: (MonadReader env m, HasLog env, MonadIO m) => String -> m () logSomething msg = do env <- ask liftIO $ getLog env msg 9
  • 10. Youthhood: Effect Systems class Monad m => Logger m where logMessage :: LogLevel -> Message -> m () class Monad m => Random m where getRandomInt :: (Int, Int) -> m Int class (Logger m, Random m) => Lang m someFunc :: Lang m => m () ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 10
  • 11. Youthhood: Effect Systems someFunc :: forall e . Eff ( avar :: AVAR , exception :: EXCEPTION , fs :: FS , console :: CONSOLE | e) Result ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 11
  • 12. Youthhood: Effect Systems data FileSystem r where ReadFile :: FilePath -> FileSystem String WriteFile :: FilePath -> String -> FileSystem () readFile1 :: Member FileSystem effs => FilePath -> Eff effs String readFile2 :: FilePath -> Eff '[FileSystem] String runFileSystem :: Eff (FileSystem ': effs) ~> Eff effs ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 12
  • 13. Youthhood: Effect Systems data Log v where Log :: String -> Log () log :: Member Log r => String -> Eff r () runLogger :: Eff (Log :> r) a -> Eff r (a, [String]) ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 13
  • 14. Youthhood: Effect Systems data State s v where Get :: State s s Put :: s -> State s () get :: Member (State s) r => Eff r s runState :: Eff (State s ': r) a -> s -> Eff r (a, s) ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 14
  • 15. Youthhood: Effect Systems data Teletype s where PutStrLn :: String -> Teletype () GetLine :: Teletype String ExitSuccess :: Teletype () putStrLn' :: Member Teletype r => String -> Eff r () runTeletype :: Eff '[Teletype] w -> IO w ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 15
  • 16. Youthhood: Effect Systems data Teletype m a where ReadTTY :: Teletype m String WriteTTY :: String -> Teletype m () echo :: Member Teletype r => Sem r () runTeletype :: Member (Embed IO) r => Sem (Teletype ': r) a -> Sem r a ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 16
  • 17. Youthhood: Effect Systems No Sample (Sorry, I’m tired) ● Final Tagless / mtl ● PureScript 0.11 Effect System ● freer-simple ● extensible-effects ● freer-effects ● freer ● polysemy ● capability 17
  • 18. 18 “Mathy” approaches in Haskell (Youthful Maxi-Mathism)
  • 22. Inversion of Control Why? How? When? 22
  • 23. Inversion of Control Why? Complexity reducing Abstraction Separation of concerns Low coupling Effects control Testability Maintainability How? When? 23
  • 24. Inversion of Control Why? Complexity reducing Abstraction Separation of concerns Low coupling Effects control Testability Maintainability How? Final Tagless Free Monad Service Handle Pattern ReaderT Pattern ... When? 24
  • 25. Inversion of Control Why? Complexity reducing Abstraction Separation of concerns Low coupling Effects control Testability Maintainability How? Final Tagless Free Monad Service Handle Pattern ReaderT Pattern ... When? Big applications Complex domain Long lifecycle Team development 25
  • 28. Layering “A Modern Architecture for FP”, John De Goes (“Onion Architecture”) “Three Layer Haskell Cake”, Matt Parsons Interfaces / Effects (eDSLs) Business Logic Implementation / Runtime 28
  • 30. Sequelize KVDB Flow Runtime, Interpreters, Configs, Environment Application SqlDB Logger App State Business Logic App Configs 30 Presto.Backend Framework (Juspay) Implementation & Runtime Interfaces (Hierarchical Free Monad eDSLs) Domain & Business Logic Redis SysCmd https://github.com/juspay/purescript-presto-backend
  • 31. 31 Hydra Framework Implementation & Runtime Interfaces (Hierarchical Free Monad eDSLs) Domain & Business Logic https://github.com/graninas/Hydra ProcessL Runtime, Interpreters, Configs, Environment Application Domain Model Business Logic DB Model AppL SqlDBL LangL Beam LoggerL StateL
  • 32. 32 Sample REST Application with Hydra: Astro
  • 33. 33 Domain Model type MeteorID = Int data Coords = Coords { azimuth :: Int , altitude :: Int } data Meteor = Meteor { meteorId :: MeteorID , size :: Int , mass :: Int , coords :: Coords } type Meteors = [Meteor] Application Domain Model
  • 34. 34 DB Model: DB Table (beam-powered) data MeteorDbT f = MeteorDb { meteorDbId :: C f Int , meteorDbSize :: C f Int , meteorDbMass :: C f Int , meteorDbAzimuth :: C f Int , meteorDbAltitude :: C f Int } deriving (Generic, Beamable) type MeteorDb = MeteorDbT Identity Application Domain Model DB Model
  • 35. 35 DB Model: DB Scheme (beam-powered) data MeteorDbT f = MeteorDb { meteorDbId :: C f Int , meteorDbSize :: C f Int , meteorDbMass :: C f Int , meteorDbAzimuth :: C f Int , meteorDbAltitude :: C f Int } deriving (Generic, Beamable) type MeteorDb = MeteorDbT Identity data AstroDb f = AstroDb { meteorsDbTable :: f (TableEntity MeteorDbT) } deriving (Generic, Database be) astroDb :: DatabaseSettings be AstroDb astroDb = defaultDbSettings Application Domain Model DB Model
  • 36. 36 Business Logic Scenarios getMeteors :: SqlConn SqliteM -> AppL Meteors getMeteors conn = do AppL Application Domain Model Business Logic DB Model
  • 37. 37 Business Logic Scenarios getMeteors :: SqlConn SqliteM -> AppL Meteors getMeteors conn = do eDbRows <- scenario $ runDB conn $ findRows $ Beam.select $ Beam.all_ (meteorsDb astroDb) SqlDBL AppL Application LangL Domain Model Business Logic DB Model AppL SqlDBL Beam Beam LangL
  • 38. 38 Business Logic Scenarios getMeteors :: SqlConn SqliteM -> AppL Meteors getMeteors conn = do eDbRows <- scenario $ runDB conn $ findRows $ Beam.select $ Beam.all_ (meteorsDb astroDb) dbRows <- case eDbRows of Right ms -> pure ms Left err -> do logError (show err) pure [] pure (map fromDBMeteor dbRows) AppL Application Domain Model Business Logic DB Model LoggerL SqlDBL LangL Beam LoggerL
  • 39. 39 Free Monad Runner & Runtime data AppRuntime = AppRuntime { rocksDBs :: RocksDBHandles , redisConns :: RedisConnections , loggerRuntime :: LoggerRuntime , stateRuntime :: StateRuntime , sqlConns :: MVar (Map ConnTag NativeSqlConn) } runApp' :: AppL a -> IO a runApp' act = bracket createAppRuntime clearAppRuntime (rt -> runApp rt act) Runtime, Interpreters, Configs, Environment Application Domain Model Business Logic DB Model AppL LoggerL SqlDBL LangL Beam
  • 40. 40 AppL Free Monad Language data AppF next where EvalLang :: LangL a -> (a -> next) -> AppF next InitSqlDB :: DBConfig beM -> (DBResult (SqlConn beM) -> next) -> AppF next type AppL = Free AppF scenario :: LangL a -> AppL a scenario act = liftF (EvalLang act id) ProcessL Runtime, Interpreters, Configs, Environment Application Domain Model Business Logic DB Model AppL SqlDBL LangL Beam LoggerL StateL
  • 41. 41 Nested Free Monad Language data LoggerF next where LogMessage :: LogLevel -> Message -> (() -> next) -> LoggerMethod next type LoggerL = Free LoggerF logMessage :: LogLevel -> Message -> LoggerL () logMessage lvl msg = liftF (LogMessage lvl msg id) ProcessL Runtime, Interpreters, Configs, Environment Application Domain Model Business Logic DB Model AppL SqlDBL LangL Beam LoggerL StateL
  • 42. 42 Free Monad Language Interpreter runFlow :: AppRuntime -> AppL a -> IO a runFlow appRt = foldFree (interpretAppF appRt) interpretAppF :: AppRuntime -> AppF a -> IO a interpretAppF appRt (EvalLang act next) = next <$> runLangL appRt act LangL LoggerL AppL AppL Interpreter
  • 43. 43 Nested Free Monad Interpreter runFlow :: AppRuntime -> AppL a -> IO a runFlow appRt = foldFree (interpretAppF appRt) interpretAppF :: AppRuntime -> AppF a -> IO a interpretAppF appRt (EvalLang act next) = next <$> runLangL appRt act runLangL :: AppRuntime -> LangL a -> IO a runLangL appRt = foldFree (interpretLangF appRt) interpretLangF :: AppRuntime -> LangF a -> IO a interpretLangF appRt (EvalLogger act next) = next <$> runLoggerL appRt act LangL LoggerL LangL Interpreter AppL AppL Interpreter
  • 44. 44 Nested Free Monad Interpreters runFlow :: AppRuntime -> AppL a -> IO a runFlow appRt = foldFree (interpretAppF appRt) interpretAppF :: AppRuntime -> AppF a -> IO a interpretAppF appRt (EvalLang act next) = next <$> runLangL appRt act runLangL :: AppRuntime -> LangL a -> IO a runLangL appRt = foldFree (interpretLangF appRt) interpretLangF :: AppRuntime -> LangF a -> IO a interpretLangF appRt (EvalLogger act next) = next <$> runLoggerL appRt act runLoggerL :: LoggerRuntime -> LoggerL () -> IO () LangL LoggerL Real Logger LangL Interpreter LoggerL Interpreter AppL AppL Interpreter
  • 45. 45 REST API Description (Servant-based) type AstroAPI = ( "meteors" :> QueryParam "mass" Int :> QueryParam "size" Int :> Get '[JSON] Meteors ) :<|> ( "meteor" :> ReqBody '[JSON] MeteorTemplate :> Post '[JSON] MeteorID ) :<|> EmptyAPI astroAPI :: Proxy AstroAPI astroAPI = Proxy
  • 46. 46 API Handlers (Servant Handler + Free Monad) data Env = Env AppRuntime type AppHandler = ReaderT Env (ExceptT ServerError IO) type AppServer = ServerT AstroAPI AppHandler astroServer' :: AppServer astroServer' = meteors :<|> meteor :<|> emptyServer
  • 47. 47 API Handlers (Servant Handler + Free Monad) data Env = Env AppRuntime type AppHandler = ReaderT Env (ExceptT ServerError IO) type AppServer = ServerT AstroAPI AppHandler astroServer' :: AppServer astroServer' = meteors :<|> meteor :<|> emptyServer meteors :: Maybe Int -> Maybe Int -> AppHandler Meteors meteors mbMass mbSize = withAppRuntime $ do conn <- connectOrFail $ mkSQLiteConfig "astroDB" "/tmp/astro.db" getMeteors' mbMass mbSize conn
  • 48. 48 API Handlers (Servant Handler + Free Monad) data Env = Env AppRuntime type AppHandler = ReaderT Env (ExceptT ServerError IO) type AppServer = ServerT AstroAPI AppHandler astroServer' :: AppServer astroServer' = meteors :<|> meteor :<|> emptyServer meteors :: Maybe Int -> Maybe Int -> AppHandler Meteors meteors mbMass mbSize = withAppRuntime $ do conn <- connectOrFail $ mkSQLiteConfig "astroDB" "/tmp/astro.db" getMeteors' mbMass mbSize conn withAppRuntime :: AppL a -> AppHandler a withAppRuntime flow = do Env appRt <- ask lift $ lift $ runApp appRt flow
  • 50. 50 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically
  • 51. 51 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically ● Simplicity: hierarchical nesting frees from type level magic
  • 52. 52 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically ● Simplicity: hierarchical nesting frees from type level magic ● Layering: the application is highly maintainable
  • 53. 53 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically ● Simplicity: hierarchical nesting frees from type level magic ● Layering: the application is highly maintainable ● Convenience: easy to write business logic
  • 54. 54 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically ● Simplicity: hierarchical nesting frees from type level magic ● Layering: the application is highly maintainable ● Convenience: easy to write business logic ● No magic: languages and interpreters are just values
  • 55. 55 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically ● Simplicity: hierarchical nesting frees from type level magic ● Layering: the application is highly maintainable ● Convenience: easy to write business logic ● No magic: languages and interpreters are just values ● Boilerplate: absent on the business logic layer
  • 56. 56 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically ● Simplicity: hierarchical nesting frees from type level magic ● Layering: the application is highly maintainable ● Convenience: easy to write business logic ● No magic: languages and interpreters are just values ● Boilerplate: absent on the business logic layer ● Performance: Church-Encoded Free Monads are fast
  • 57. 57 Hierarchical Free Monads: Conclusions ● Accidental complexity: reduced dramatically ● Simplicity: hierarchical nesting frees from type level magic ● Layering: the application is highly maintainable ● Convenience: easy to write business logic ● No magic: languages and interpreters are just values ● Boilerplate: absent on the business logic layer ● Performance: Church-Encoded Free Monads are fast ● Killer feature: automatic white-box (regression) testing
  • 58. 58 My Links ● “Functional Design and Architecture” book Patreon program ● “Functional Design and Architecture” book page ● “Hydra” (framework & comparison of FM, Church Encoded FM and FT) ● “Node” (real-world framework for building distributed concurrent apps) ● Automatic White-Box Testing with Free Monads (article & showcase) ● stm-free: STM with Free Monads (PoC & showcase) ● cpp_stm_free: STM with Free Monads in C++ (PoC & showcase) ● My talks
  • 59. Free Monads are Powerful and Fast. Alexander Granin graninas@gmail.com, Twitter: @graninas Functional Conf, Bangalore, 2019 59