The document discusses using Free monads and STM (Software Transactional Memory) for building concurrent applications in Haskell. It provides examples of applications like a labyrinth game and meteor shower simulation that are built using Free monads, STM transactions, processes and signals to coordinate concurrent operations. The document also discusses building a blockchain application using a similar approach with nodes, services, state and declarative protocols.
Cluj Big Data Meetup - Big Data in PracticeSteffen Wenz
At the Cluj Big Data Meetup, we shared some insights into TrustYou's big data tech stack. Also we introduced two tools which we've found useful in our production jobs: Apache Pig and Luigi.
Also check out the code samples on GitHub: https://github.com/trustyou/meetups/tree/master/big-data
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseSages
Szybkie wprowadzenie do technologii Pig i Hive z ekosystemu Hadoop. Prezentacja wykonana w ramach warsztatów Codepot w dniu 29.08.2015. Prezentacja wykonana przez Radosława Stankiewicza oraz Bartłomieja Tartanusa.
Helping travelers make better hotel choices - 500 million times a month
TrustYou analyzes online hotel reviews to create a summary for every hotel in the world. What do travelers think of the service? Is this hotel suitable for business travelers? TrustYou data is integrated on countless websites (Trivago, Wego, Kayak), helping travelers make better choices. Try it out yourself on http://www.trust-score.com/
TrustYou runs almost exclusively on Python. Every week, we find 3 million new hotel reviews on the web, process them, analyze the text using Natural Language Processing, and update our database of 600,000 hotels. In this talk, Steffen will give insights into how Python is used at TrustYou to collect, analyze and visualize these large amounts of data.
Numerical Methods with Computer ProgrammingUtsav Patel
This report includes computer programming of some of the basic numerical methods. The programming language used is C++. Outputs of the programs are attached in the form of a screenshot. It can be helpful in the assignments on programming.
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)Ontico
"Все гениальное просто" — таким бы мог быть слоган Redux, одной из имплементаций FLUX-архитектуры, которой 31 мая исполняется ровно год. И вот уже практически год, как мы приняли решение использовать Redux в наших проектах. Это был осознанный риск, о котором мы ничуть не пожалели.
За этот год мы научились писать тестируемый код, избегать мутаций и применять методы оптимизации для выбранного стека. Также нам пришлось написать собственные решения для инкапсуляции состояния при написании переиспользуемых компонент и для работы с формами произвольной глубины вложенности, а также мы написали свою сетку для отображения бесконечного числа элементов.
Кроме этого, на больших нагрузках мы столкнулись с проблемами производительности рендеринга на сервере в изоморфном приложении и с успехом их решили.
Обо всем этом я расскажу в своем докладе, поделюсь тем опытом и ощущениями, которые мне лично удалось получить за время работы с React и Redux.
Cluj Big Data Meetup - Big Data in PracticeSteffen Wenz
At the Cluj Big Data Meetup, we shared some insights into TrustYou's big data tech stack. Also we introduced two tools which we've found useful in our production jobs: Apache Pig and Luigi.
Also check out the code samples on GitHub: https://github.com/trustyou/meetups/tree/master/big-data
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseSages
Szybkie wprowadzenie do technologii Pig i Hive z ekosystemu Hadoop. Prezentacja wykonana w ramach warsztatów Codepot w dniu 29.08.2015. Prezentacja wykonana przez Radosława Stankiewicza oraz Bartłomieja Tartanusa.
Helping travelers make better hotel choices - 500 million times a month
TrustYou analyzes online hotel reviews to create a summary for every hotel in the world. What do travelers think of the service? Is this hotel suitable for business travelers? TrustYou data is integrated on countless websites (Trivago, Wego, Kayak), helping travelers make better choices. Try it out yourself on http://www.trust-score.com/
TrustYou runs almost exclusively on Python. Every week, we find 3 million new hotel reviews on the web, process them, analyze the text using Natural Language Processing, and update our database of 600,000 hotels. In this talk, Steffen will give insights into how Python is used at TrustYou to collect, analyze and visualize these large amounts of data.
Numerical Methods with Computer ProgrammingUtsav Patel
This report includes computer programming of some of the basic numerical methods. The programming language used is C++. Outputs of the programs are attached in the form of a screenshot. It can be helpful in the assignments on programming.
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)Ontico
"Все гениальное просто" — таким бы мог быть слоган Redux, одной из имплементаций FLUX-архитектуры, которой 31 мая исполняется ровно год. И вот уже практически год, как мы приняли решение использовать Redux в наших проектах. Это был осознанный риск, о котором мы ничуть не пожалели.
За этот год мы научились писать тестируемый код, избегать мутаций и применять методы оптимизации для выбранного стека. Также нам пришлось написать собственные решения для инкапсуляции состояния при написании переиспользуемых компонент и для работы с формами произвольной глубины вложенности, а также мы написали свою сетку для отображения бесконечного числа элементов.
Кроме этого, на больших нагрузках мы столкнулись с проблемами производительности рендеринга на сервере в изоморфном приложении и с успехом их решили.
Обо всем этом я расскажу в своем докладе, поделюсь тем опытом и ощущениями, которые мне лично удалось получить за время работы с React и Redux.
As part of our Qiskit learning, we have this notebook sample that demonstrates the different generic quantum neural network (QNN) implementations provided in Qiskit Machine Learning. The networks are meant as application-agnostic computational units that can be used for many different use cases
You may have heard about reactive programming. Maybe even checked out RxSwift. But if you're not using it in your daily development, you're really missing out! Rx decimates the boilerplate code you'd have to write to do the same things in the traditional, imperative manner. And, in this day and age where the answer to supporting multiple platforms has given rise to using "lowest common denominator" cross-platform development technologies, Rx shifts the focus back to developers who want to stay true to their platform of choice, by unifying the patterns and operators used to write app code on any platform. Come see how reactive programming with RxSwift will change your life and make you richer than your wildest dreams.
New and delete are a thing of the past, with the new features in C++14 and beyond (such as smart pointers and move semantics) memory management is easier and safer. Learn how to use the new constructs of C++14 and beyond to create, move, and free objects in a safer and more efficient manner.
Shift Remote FRONTEND: Reactivity in Vue.JS 3 - Marko Boskovic (Barrage)Shift Conference
In previous versions of Vue we needed abstracted patterns like Higher Order Components (HOC), mixins or props to implement reactivity. The new functional API gives us the ability to encapsulate and reuse logic across multiple components without those abstracted patterns.
What is the difference between Final Tagless and Free Monads from the Software Design point of view? What is Hierarchical Free Monads approach? How to build real applications in Haskell?
This talk was given on FPure 2019, Kazan.
As part of our Qiskit learning, we have this notebook sample that demonstrates the different generic quantum neural network (QNN) implementations provided in Qiskit Machine Learning. The networks are meant as application-agnostic computational units that can be used for many different use cases
You may have heard about reactive programming. Maybe even checked out RxSwift. But if you're not using it in your daily development, you're really missing out! Rx decimates the boilerplate code you'd have to write to do the same things in the traditional, imperative manner. And, in this day and age where the answer to supporting multiple platforms has given rise to using "lowest common denominator" cross-platform development technologies, Rx shifts the focus back to developers who want to stay true to their platform of choice, by unifying the patterns and operators used to write app code on any platform. Come see how reactive programming with RxSwift will change your life and make you richer than your wildest dreams.
New and delete are a thing of the past, with the new features in C++14 and beyond (such as smart pointers and move semantics) memory management is easier and safer. Learn how to use the new constructs of C++14 and beyond to create, move, and free objects in a safer and more efficient manner.
Shift Remote FRONTEND: Reactivity in Vue.JS 3 - Marko Boskovic (Barrage)Shift Conference
In previous versions of Vue we needed abstracted patterns like Higher Order Components (HOC), mixins or props to implement reactivity. The new functional API gives us the ability to encapsulate and reuse logic across multiple components without those abstracted patterns.
What is the difference between Final Tagless and Free Monads from the Software Design point of view? What is Hierarchical Free Monads approach? How to build real applications in Haskell?
This talk was given on FPure 2019, Kazan.
lldb kann mehr als nur einfache Breakpoints oder po. In dem Vortrag zeigt Oliver Bayer, wie sich mit Hilfe von lldb Programmcode zur Ausführungszeit manipulieren lässt, ohne das hierfür der Sourcecode anzupassen ist. Sei es, damit Test- oder Debugcode nicht in die produktiv App gelangt, oder weil der Sourcecode für einen Teil der App nicht vorliegt.
Event: macoun, 04.10.2019
Speaker: Oliver Bayer, inovex
Mehr Tech-Vorträge: inovex.de/vortraege
Mehr Tech-Artikel: inovex.de/blog
Original Presentation "Much Ado About CoffeeScript - LSRC V" By Mattt Thompson => http://www.slideshare.net/matttthompson/much-ado-about-coffeescript-lsrc-v
A better version can be found at https://app.box.com/s/8zuk8yd4x9m7rbvinkb0xztz17x6xoqj
This is the slide for a presentation at Golang Melbourne meetup.
Hierarchical free monads and software design in fpAlexander Granin
I invented the approach I call "Hierarchical Free Monads". It helps to build applications in Haskell with achieving all the needed code quality requirements. I tested this approach in several real world projects and companies, and it works very well.
The Present and The Future of Functional Programming in C++Alexander Granin
Keynote talk for C++ Siberia 2019.
I'm speaking about why Functional Programming is important in C++ world, what is the philosophy of FP in C++, and what features do we have. I'm presenting a connection of constexpr and template metaprogramming to pure FP, and talking about why monads are inevitable. I'm also discussing an upcoming features in C++.
Software transactional memory. pure functional approachAlexander Granin
Slides for C++ Russia 2018
I'm presenting my `cpp_stm_free` library: composable monadic STM for C++ on Free monads for lock-free concurrent programming.
Небольшой доклад о мифах в функциональном программировании для DevDay@2GIS.
Slides for my talk to DevDay@2GIS about functional programming: See the talk here (Rus):
https://youtu.be/jSkYvNqQWqs
Линзы - концепция функционального программирования, позволяющая легко оперировать сколь угодно сложными структурами данных. Линзы решают две проблемы: снижают сложность обработки данных и предоставляют абстракцию над запросами к данным, делая код устойчивым к поломкам при изменении структуры данных.
Доклад о дизайне кода в функциональном стиле на C++, представленный вниманию плюсовиков на C++ User Group Novosibirsk 2014.
В качестве демонстрационного проекта была реализована игра "Амбер" по мотивам "Хроник Амбера" Р. Желязны.
https://github.com/graninas/Amber
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...SkillCertProExams
• For a full set of 760+ questions. Go to
https://skillcertpro.com/product/databricks-certified-data-engineer-associate-exam-questions/
• SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
• It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
• SkillCertPro updates exam questions every 2 weeks.
• You will get life time access and life time free updates
• SkillCertPro assures 100% pass guarantee in first attempt.
This presentation, created by Syed Faiz ul Hassan, explores the profound influence of media on public perception and behavior. It delves into the evolution of media from oral traditions to modern digital and social media platforms. Key topics include the role of media in information propagation, socialization, crisis awareness, globalization, and education. The presentation also examines media influence through agenda setting, propaganda, and manipulative techniques used by advertisers and marketers. Furthermore, it highlights the impact of surveillance enabled by media technologies on personal behavior and preferences. Through this comprehensive overview, the presentation aims to shed light on how media shapes collective consciousness and public opinion.
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...Suzanne Lagerweij
This is a workshop about communication and collaboration. We will experience how we can analyze the reasons for resistance to change (exercise 1) and practice how to improve our conversation style and be more in control and effective in the way we communicate (exercise 2).
This session will use Dave Gray’s Empathy Mapping, Argyris’ Ladder of Inference and The Four Rs from Agile Conversations (Squirrel and Fredrick).
Abstract:
Let’s talk about powerful conversations! We all know how to lead a constructive conversation, right? Then why is it so difficult to have those conversations with people at work, especially those in powerful positions that show resistance to change?
Learning to control and direct conversations takes understanding and practice.
We can combine our innate empathy with our analytical skills to gain a deeper understanding of complex situations at work. Join this session to learn how to prepare for difficult conversations and how to improve our agile conversations in order to be more influential without power. We will use Dave Gray’s Empathy Mapping, Argyris’ Ladder of Inference and The Four Rs from Agile Conversations (Squirrel and Fredrick).
In the session you will experience how preparing and reflecting on your conversation can help you be more influential at work. You will learn how to communicate more effectively with the people needed to achieve positive change. You will leave with a self-revised version of a difficult conversation and a practical model to use when you get back to work.
Come learn more on how to become a real influencer!
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsRosie Wells
Insight: In a landscape where traditional narrative structures are giving way to fragmented and non-linear forms of storytelling, there lies immense potential for creativity and exploration.
'Collapsing Narratives: Exploring Non-Linearity' is a micro report from Rosie Wells.
Rosie Wells is an Arts & Cultural Strategist uniquely positioned at the intersection of grassroots and mainstream storytelling.
Their work is focused on developing meaningful and lasting connections that can drive social change.
Please download this presentation to enjoy the hyperlinks!
2. Plan
● In love with Free monads and STM
● Testing?
● How does this magic work?
● Performance?
● Conclusion: The truths I learned
● (Bonus) No, really, how does this magic work?
2
13. 13
MeteorCounter app (Hydra framework)
meteorsMonitoring :: AppConfig -> AppL ()
meteorsMonitoring cfg = do
st <- atomically $ initState cfg
process $ forever $ meteorCounter st
process $ forever $ withRandomDelay st $ meteorShower st NorthEast
process $ forever $ withRandomDelay st $ meteorShower st NorthWest
process $ forever $ withRandomDelay st $ meteorShower st SouthEast
process $ forever $ withRandomDelay st $ meteorShower st SouthWest
atomically $ do
let totalVar :: StateVar Int = _totalMeteors st
total <- readVar totalVar
when (total < 1000) retry
14. 14
MeteorCounter app (Hydra framework)
meteorsMonitoring :: AppConfig -> AppL ()
meteorsMonitoring cfg = do
st <- atomically $ initState cfg
process $ forever $ meteorCounter st
process $ forever $ withRandomDelay st $ meteorShower st NorthEast
process $ forever $ withRandomDelay st $ meteorShower st NorthWest
process $ forever $ withRandomDelay st $ meteorShower st SouthEast
process $ forever $ withRandomDelay st $ meteorShower st SouthWest
atomically $ do
let totalVar :: StateVar Int = _totalMeteors st
total <- readVar totalVar
when (total < 1000) retry
Processes
15. 15
MeteorCounter app (Hydra framework)
meteorsMonitoring :: AppConfig -> AppL ()
meteorsMonitoring cfg = do
st <- atomically $ initState cfg
process $ forever $ meteorCounter st
process $ forever $ withRandomDelay st $ meteorShower st NorthEast
process $ forever $ withRandomDelay st $ meteorShower st NorthWest
process $ forever $ withRandomDelay st $ meteorShower st SouthEast
process $ forever $ withRandomDelay st $ meteorShower st SouthWest
atomically $ do
let totalVar :: StateVar Int = _totalMeteors st
total <- readVar totalVar
when (total < 1000) retry
Finish condition
29. 29
spec :: Spec
spec = unstableTest $ slowTest
$ describe "PoW and graph node interaction"
$ fromHUnitTest $ TestList
[ TestLabel "Accept kblocks produced in order" $ testAcceptKblock InOrder
, TestLabel "Accept kblocks produced in random order" $ testAcceptKblock RandomOrder
]
testAcceptKblock :: Ordering -> Test
testAcceptKblock order = TestCase $ withNodesManager $ mgr -> do
void $ startNode mgr $ graphNode graphNodeTransmitterConfig
waitForNode transmitterRpcAddress
void $ startNode mgr $ powNode $ genPoWNodeConfig { _kblocksOrder = order}
waitForNode powRpcAddress
void $ makeIORpcRequest powRpcAddress $ NBlockPacketGeneration kblockCount timeGap
let predicate kBlock = kBlock ^. number == kblockCount
void $ makeRpcRequestWithPredicate predicate transmitterRpcAddress GetLastKBlock
Testing nodes (virtual environment)
30. 30
spec :: Spec
spec = do
around (withCoreRuntime Nothing) // Arrange
$ it "generated labyrinth has correct bounds"
$ runtime -> property
$ withMaxSuccess 5
$ monadicIO
$ do
eLab <- run $ try $ runLangL runtime generateRndLabyrinth // Act
case eLab of
Left (err :: SomeException) -> assert False // Assert
Right lab -> do
let LabyrinthInfo {liBounds, liWormholes} = analyzeLabyrinth lab
let (x, y) = liBounds
let wms = Map.size liWormholes
assert $ x * y >= 16 && x * y <= 100
assert $ (wms >= 2) && (wms <= 5)
Testing the labyrinth logic (black box, property-based)
31. 31
spec :: Spec
spec = do
around (withAppRuntime Nothing) $ // Arrange
describe "Labyrinth generation tests" $
it "generateLabyrinth" $ rt -> do
lab <- runLangL (_coreRuntime rt) $ generateLabyrinth (4, 4) 3 5 // Act
let LabyrinthInfo {liBounds, liWormholes, liExits} = analyzeLabyrinth lab
liBounds `shouldBe` (4, 4) // Assert
(Map.size liWormholes) `shouldSatisfy` (x -> x >= 2 && x <= 5)
(Set.size liExits) `shouldSatisfy` (x -> x >= 1 && x <= 3)
Testing the labyrinth logic (black box, integration)
48. 48
Additional Materials
● Automatic White-Box Testing with Free Monads | Article, Showcase
● Hierarchical Free Monads and Software Design in Haskell | Talk
● Hierarchical Free Monads: The Most Developed Approach In Haskell
● Functional Design and Architecture | Book
● Hydra | Framework (web services with SQL/KV DB and concurrency)
● Node | Framework (distributed apps with KV DB and concurrency)
● Final Tagless vs Free Monads | Talk
● Software Design in Haskell | List of materials
50. 50
Hydra Framework
Implementation & Runtime
Interfaces
(Hierarchical Free Monad eDSLs)
Domain & Business Logic
ProcessL
Runtime, Interpreters, Configs, Environment
Application
Domain
Model
Business
Logic
DB Model
AppL
SqlDBL
LangL
Beam
LoggerL
StateL
51. 51
newtype StateVar a = StateVar { _varId :: Int }
data StateF next where
NewVar :: a -> (StateVar a -> next) -> StateF next
ReadVar :: StateVar a -> (a -> next) -> StateF next
WriteVar :: StateVar a -> a -> (() -> next) -> StateF next
Retry :: (a -> next) -> StateF next
EvalGraph :: TGraph c -> Free (HGraphF (TNodeL c)) x -> (x -> next) -> StateF next
EvalDelayedLogger :: LoggerL () -> (() -> next) -> StateF next
type StateL = Free StateF
STM-like Free interface
52. 52
STM-like Free language -> STM
newVar' :: StateRuntime -> a -> STM VarId
newVar' stateRt !a = do
nodeState <- takeTMVar $ stateRt ^. state
varId <- getVarId stateRt
tvar <- newTVar $ unsafeCoerce a
let !newMap = Map.insert varId (VarHandle tvar) nodeState
putTMVar (stateRt ^. state) newMap
pure varId
interpretStateF :: StateRuntime -> StateF a -> STM a
interpretStateF _ (Retry _) = retry
interpretStateF stateRt (NewVar !val next) = do
var <- newVar' stateRt val
pure $ next $ StateVar var
runStateL :: StateRuntime -> StateL a -> STM a
runStateL stateRt = foldFree (interpretStateF stateRt)
53. 53
Container language
data LangF next where
EvalLogger :: LoggerL () -> (() -> next) -> LangF next
EvalIO :: IO a -> (a -> next) -> LangF next
...
EvalStateAtomically :: StateL a -> (a -> next) -> LangF next
type LangL = Free LangF
atomically :: StateL a -> LangL a
atomically action = liftF $ EvalStateAtomically action id
54. 54
Upper level language -> IO
interpretLangF :: CoreRuntime -> LangF a -> IO a
interpretLangF coreRt (EvalStateAtomically action next) = do
let stateRt = coreRt ^. stateRuntime
let logHndl = coreRt ^. loggerRuntime . hsLoggerHandle
res <- atomically $ runStateL stateRt action
flushStmLogger (stateRt ^. stmLog) logHndl
pure $ next res
interpretLangF _ (EvalIO f next) = do
!r <- f
pure $ next r
interpretLangF coreRt (EvalLogger loggerAct next) =
next <$> runLoggerL (coreRt ^. loggerRuntime . hsLoggerHandle) loggerAct