Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Haskell All the Way Down

Haskell All the Way Down

Talk on my experience building a codebase from scratch using Haskell

Arnaud Bailly

April 02, 2015
Tweet

More Decks by Arnaud Bailly

Other Decks in Technology

Transcript

  1. Arnaud Bailly
    [email protected]
    http://www.capital-match.com
    @abailly
    1
    Haskell All the Way Down
    Building a startup using Haskell

    View full-size slide

  2. Functional Programmers Paris - 2015-04-01
    Agenda
    ▪ Who/Why/What
    ▪ How we use Haskell
    ▪ The Good, the Bad and the Ugly
    ▪ Future work
    !
    This is not a Monad tutorial….
    2

    View full-size slide

  3. Functional Programmers Paris - 2015-04-01
    Who? What? Why?
    3

    View full-size slide

  4. Functional Programmers Paris - 2015-04-01
    Who?
    ▪ Pawel Kuznicki
    – CEO, ex-Rocket, ex-McKinsey, ex-Zalora
    ▪ Kevin Lim
    – CFO, ex-JPMorgan, ex-SCB
    ▪ Arnaud Bailly
    – 20+ years experience, mostly Java for food,
    discovered Haskell in 2001
    ▪ Willem van den Ende
    ▪ 20+ years experience, XP since the
    beginning, Smalltalk/Clojure/.Net…
    4

    View full-size slide

  5. Functional Programmers Paris - 2015-04-01
    !
    What? Marketplace Lending!
    ~S$32,400 repayment in 1
    year
    Bank
    P2P
    lending
    Bank n lenders
    n deposits = S$30,000

    @ 1.5% interest rate
    SME(borrower)
    S$30,000 loan @ 8%
    ~S$30,450 repayment in 1
    year
    Return of 6.5%
    or S$1,950
    ~S30,500
    or 1.5%
    RETURN
    5
    Capital Match
    Lender 1
    Lender 2
    Lender 3
    SME(borrower)
    Loan syndication on
    behalf of the
    lenders
    S$30,000 loan @ 6.3%
    1%+ underwriting fee = S
    $300-400
    S$5,000 loan @ 7%
    S$5,000 loan @ 7%
    S$20,000 loan @ 6%
    ~S$31,900 repayment in 1
    year ~S$31,500 repayment
    20% commission on
    returns = S$400
    ~S20,960
    or 4.8%
    ~S$5,280
    or 5.6%
    ~S$5,280
    or 5.6%
    1% provisional fund = S$300
    Provis. Fund

    View full-size slide

  6. Functional Programmers Paris - 2015-04-01
    Why Haskell?
    ▪ Pawel had very good experience working with
    Haskell developers at previous job
    ▪ He posted job offer on http://functionaljobs.com
    ▪ I wanted to do some real stuff in Haskell
    ▪ I had good experience working for people in
    Singapore
    ▪ It seems fun!
    Let’s do it!
    6

    View full-size slide

  7. Functional Programmers Paris - 2015-04-01
    How we use Haskell?
    7

    View full-size slide

  8. Functional Programmers Paris - 2015-04-01
    (Nearly) Everything!
    ▪ Dev. Env ⟶ ghc-mod, stylish-haskell
    ▪ Web Backend ⟶ Scotty, Blaze
    ▪ Database ⟶ Custom Event Sourcing
    ▪ Unit/Integration Testing ⟶ HSpec, QuickCheck
    ▪ End-to-End Testing ⟶ hs-webdriver
    ▪ Build ⟶ Cabal, Shake
    ▪ CI Server ⟶ Bake
    ▪ Configuration Management ⟶ Propellor
    8

    View full-size slide

  9. Functional Programmers Paris - 2015-04-01
    For the rest…
    ▪ Web Front-end ⟶ Om/Clojurescript
    ▪ Version Control ⟶ Git (what else?)
    ▪ Packaging & Deployment ⟶ Docker (because
    we can)
    ▪ Infrastructure ⟶ DigitalOcean / S3
    ▪ Monitoring ⟶ Riemann, collectd (WIP)
    9

    View full-size slide

  10. Functional Programmers Paris - 2015-04-01
    Emacs Dev. Envt.
    10
    Compilation FlyCheck
    HLint
    Autocompletion

    View full-size slide

  11. Functional Programmers Paris - 2015-04-01
    Scotty: REST Endpoints
    11

    View full-size slide

  12. Functional Programmers Paris - 2015-04-01
    Scotty: Middleware
    12

    View full-size slide

  13. Functional Programmers Paris - 2015-04-01
    Blaze: Template HTML
    13

    View full-size slide

  14. Functional Programmers Paris - 2015-04-01
    HSpec: Integration Tests
    14

    View full-size slide

  15. Functional Programmers Paris - 2015-04-01
    QuickCheck
    15

    View full-size slide

  16. Functional Programmers Paris - 2015-04-01
    hs-webdriver: ETE Testing
    16

    View full-size slide

  17. Functional Programmers Paris - 2015-04-01
    Shake: Better make
    17

    View full-size slide

  18. Functional Programmers Paris - 2015-04-01
    Bake: CI
    18

    View full-size slide

  19. Functional Programmers Paris - 2015-04-01
    Propellor: Config Mgt.
    19

    View full-size slide

  20. Functional Programmers Paris - 2015-04-01
    The Good, the Bad and the Ugly
    20

    View full-size slide

  21. Functional Programmers Paris - 2015-04-01
    The Good
    ▪ Safer programming (shines in comparison with
    front-end dev) thanks to typing and compilation
    ▪ Types really help a lot: Documentation,
    intention, design, checking…
    ▪ Libraries and tools are most often good or very
    good even when in “beta" or “alpha" (e.g. bake)
    ▪ Nice and supportive maintainers and
    community
    ▪ We feel productive and confident to ship haskell
    code: Static Typing + Tests Rock!
    21

    View full-size slide

  22. Functional Programmers Paris - 2015-04-01
    The Good (contd.)
    ▪ Refactoring is easier: Change a type and fix
    compiler’s errors
    ▪ Good for hiring: Haskell attracts “interesting"
    people
    ▪ Very easy to replace clunky scripts with
    typesafe and compiled DSL
    22

    View full-size slide

  23. Functional Programmers Paris - 2015-04-01
    The Bad
    ▪ Cabal
    – but does its job, no binary packages possible
    and there is Shake for funky stuff
    ▪ Dev. Env. is still not on par with Eclipse/IntelliJ/
    VS
    – but FPComplete and others are making
    progress fast and tooling improves
    ▪ Compilation typing errors
    – but you get accustomed to it once your code
    base is stable
    23

    View full-size slide

  24. Functional Programmers Paris - 2015-04-01
    The Bad (contd.)
    ▪ Hiring: Hard to do if you require local people,
    Haskell communities are usually small. Be
    prepared to work remotely
    ▪ Can get pretty abstract pretty quickly…
    – pair programming and peer reviews to the
    rescue!
    24

    View full-size slide

  25. Functional Programmers Paris - 2015-04-01
    The Ugly
    ▪ String vs. Data.Text vs. Data.Text.Lazy vs.
    – ⟶ Oh My! Haskell is Old!
    ▪ Runtime error reporting
    – ⟶ No Stack Traces!
    ▪ Aeson deserialization errors
    – ⟶ Cryptic No Parse
    ▪ Conflicting GHC versions/Libs requirements
    ▪ Lazy I/O can bite you
    25

    View full-size slide

  26. Functional Programmers Paris - 2015-04-01
    Future Work
    26

    View full-size slide

  27. Functional Programmers Paris - 2015-04-01
    Platform
    ▪ Replace clojurescript with Haskell based React
    bindings ⟶ ghcjs
    ▪ Generate CSS ⟶ Clay
    ▪ Replace Scotty with Servant for typesafe routes
    ▪ Improve End-to-End testing
    ▪ Performance and resilience testing ⟶ jepsen
    ▪ Distributed micro-services ⟶ Raft, Cloud
    Haskell
    27

    View full-size slide

  28. Functional Programmers Paris - 2015-04-01
    Tooling
    ▪ Improve CI:
    – handle multiple branches, parallel builds,
    better reporting
    ▪ Improve configuration management
    – replace scripts w/ Haskell code for
    provisioning, better propellor configs
    ▪ Better containers builds and orchestration
    28

    View full-size slide

  29. Functional Programmers Paris - 2015-04-01
    Credit Risk Analysis
    ▪ Build a database and inference engine to better
    automate Credit Risk Assessment process
    – NLP, ML, Big Data…
    29

    View full-size slide

  30. Functional Programmers Paris - 2015-04-01 30
    We are hiring!
    \
    http://functionaljobs.com/jobs/8802-full-stack-software-engineer-at-capital-match

    View full-size slide

  31. Functional Programmers Paris - 2015-04-01
    Questions?
    31

    View full-size slide