Haskell and Elm in Production
AN UNEXPECTED JOURNEY
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3986566/The-Hobbit-An-Unexpected-Journey.jpg)
Who am I?
- Senior Web Developer at LiveView Technology
- Father of two
- FP Programmer
- Love LoL (B5 for life)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3986567/2017-07-05_17.45.44.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3986573/2017-06-11_12.22.33.jpg)
The Plan
- Setting up the context
- Picking a frontend language or framework
- Picking a backend language or framework
- Experience with Elm
- Experience with Haskell
Setting up the context
What we had
- CakePHP spaghetti mess
- Copy-Pasta of code everywhere
- Blend of JS libs meshed together
- Random jQuery
What we wanted
- Maintainability, Maintainability, Maintainability
- Multiple SPA apps to meet our different customer needs
- Unified cohesive frontend
- Properly architected backend
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3973700/developers_developers.gif)
Skills we had
- CakePHP
- CodeIgniter
- Magento
- Angular 1.x
- jQuery
- Vanilla JS
- The ability to adapt
Questions?
Picking a frontend language
What we wanted
- Something that was "better" then just regular JS
- Framework that would not get in the way
- Something with good documentation
What we tried
- Elm
- Didn't feel a need to try anything else
Questions?
Picking a Backend Language
What we Originally wanted
- Able to handle changing requirements easily
- Something we were familiar with
- Simple, non-bloated framework
- Maintainability, Maintainability, Maintainability
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3986379/pasted-from-clipboard.png)
So we chose:
PHP
But What framework?
Decided to look at micro-frameworks
- Bullet
- Slim
- Silex
and we chose ...
Bulletphp
- Functional (Elm is functional)
- Used composer
- Had a good recommended project structure
... but
- Didn't seem actively maintained
- last commit was a few years ago
- Small community
- Didn't like php for websockets
If not PHP then what?
- NodeJS
- Go
- Rust
- Haskell
- Something else?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3986374/php.jpg)
exploration
- Which had websocket support?
- Which had good mysql support?
- Which had a good community?
- Which had a "good" type system?
... and we chose?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3987813/pasted-from-clipboard.png)
Never let anyone know the truth: we write total functions in strong types because we’re not clever enough to spot all the pitfalls without them
- i-am-tom
Haskell
- Yesod has plugins for websockets
- Persistent allowed for type safe SQL
- Esqueleto allowed for type safe custom queries
- Community was very friendly, new book made learning much easier
- http://haskellbook.com/
Questions?
Experience with ELM
Elm is its own paradigm
- Thinking OOP like causes more work
- Originally design to be a UI language
- The Elm Architecture
- Use types to guide design
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3988044/pasted-from-clipboard.png)
What I Love
- No run-time exceptions
- No null
- Compiler is your friend
- Refactoring is amazing
- No "fancy" type system features
What is frustrating
-
Direct JavaScript inter-opt
- Some compiler messages
- No "fancy" type system features
Community and Tooling
- Enforced Semantic Versioning
- Helpful Slack channel
- Elm-Format
- Young, but getting better every day
Questions?
Experience with Haskell
What surprised me
- That I don't need a PhD
- Can program at low and high levels
- Debugging is different due to lazy eval
A paradigm is a mindset about how you look at your code.
- Anjanna Vakil
(Programming Across Paradigms https://www.youtube.com/watch?v=Pg3UeB-5FdA)
Yesod
- Adheres to the Web Application Interface (WAI)
- Type safe URLs
- Type safe SQL
- Like a piecemeal "Ruby on Rails" framework
What I love
- Exceptions are used exceptionally
- Type safe business logic
- No null
- Can run it "interpretted", interpreted, or compiled
- Stack
- Types become micro unit tests
What is frustrating
- The seemingly huge emphasis on Monads
- Because of advanced types, compiler message can be cryptic
- Harder to learn if you already know OOP
- Simple Made Easy - Rich Hickey
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314534/images/3987842/pasted-from-clipboard.png)
Community and Tooling
- Stack is amazing! (No more cabal hell)
- There are IRC channels and active slack channels in the Functional Programming slack
- http://fpchat-invite.herokuapp.com/
- https://www.haskell.org/irc
- Hoogle
- http://hoogle.haskell.org/
- Hackage
- https://hackage.haskell.org/
- https://www.stackage.org/
Questions?
Thank YOU!
@sbditto85
Haskell And Elm in Production
By sbditto85
Haskell And Elm in Production
- 964