A presentation at VanFP in
April 2016 in
Vancouver, BC, Canada by
WITCHCRAFT EXPERIMENTS WRITING HIGHER-ORDER ABSTRACTIONS IN ELIXIR OR: PUTTING THE “FUN” BACK IN “FUNCTOR”
FP is a set of principles and practice, rather than one monolithic thing. We should embrace different ways of achieving these aims.
Different results of FP principles Elixir Can feel (somewhat) imperative Lots of operational logic Thinks primarily in directional data “flow” (horizontal)
Haskell Largely declarative Often think in abstractions (vertical)
Different results of FP principles Crossover Haskell has pipes Elixir has Enum
I still want to try getting more “Haskell in Elixir” ¯_(
Adding a Vertical Dimension to Elixir
Witchcraft 1.Witchcraft (also called witchery or spellcraft) broadly means the practice of, and belief in, magical skills and abilities that are able to be exercised individually, by designated social groups, or by persons with the necessary esoteric secret knowledge 2. A category-inspired library for Elixir
Witchcraft Monoid, Functor(s), Monad, Arrow, and Category for Elixir Follows the Haskell Prelude and Control modules pretty closely A lot of these rely on combinators and currying
Want partial application in Elixir Elixir is an arity-based language (Automatic) partial application isn’t a thing 😱 Currying isn’t a thing foo(a) is a different function from foo(a, b) Bootstrap time! Massive detour…
Combinators for Elixir (id, flip, const, fix, SKI, &c) How does Elixir now have these in the standard lib?! Currying and (completely faked) partial application
Runtime Currying in Elixir
Compile-Time Currying in Elixir
defpartial Destroys the Elixir arity system 😅 Still really nice to use internally Will get folded back in to defcurry eventually Need to be able to specify only and except
Back to Witchcraft
Functors, monads, arrows, categories for Elixir Follows the Haskell Prelude and Control modules pretty closely A lot of these rely on combinators and currying
Just Protocols & Functions
Operators are Backwards?!
The Operators are Backwards?!
Philosophical difference in Elixir Thinking horizontally (in “flow”) == data is the primary “subject”
Witchcraft so far <|> liftA2
Want ADTs to get the most out of Witchcraft Elixir doesn’t have ADTs…
BUT ELIXIR HAS STRUCTS
Internals are the topic of another talk
View Witchcraft & Quark on Notist.
A brief discussion of my recent work on two classic FP libraries in Elixir. Presented at the Vancouver Functional Programmers meetup.