# Notes from Compose 2017

**URL:** https://discuss.ocaml.org/t/notes-from-compose-2017/240
**Category:** Community
**Tags:** event, bucklescript
**Created:** [May 21, 2017, 5:54pm UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240 "2017-05-21T17:54:03Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![armish](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/armish/32/105_2.png) [@armish](https://discuss.ocaml.org/u/armish)
#### Post date: [May 21, 2017, 5:54pm UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/1 "2017-05-21T17:54:03Z")

</div>

Here are my take-away points from this year’s conference (I am pretty new to the FP world so excuse the oversimplification here):

* * *

# Compose 2017 - NYC

[http://www.composeconference.org/2017/](http://www.composeconference.org/2017/)

## Day 1 (May 18)

#### KEYNOTE: A categorical view of computational effects

- Presenter: Dr. Emily Riehl
  - Website: [http://www.math.jhu.edu/~eriehl/](http://www.math.jhu.edu/~eriehl/)
  - Twitter: [https://twitter.com/emilyriehl](https://twitter.com/emilyriehl)

- Slides: [http://www.math.jhu.edu/~eriehl/compose.pdf](http://www.math.jhu.edu/~eriehl/compose.pdf)
- Concept: Lawvere theory
  - Wikipedia: [https://ncatlab.org/nlab/show/Lawvere+theory](https://ncatlab.org/nlab/show/Lawvere+theory)
  - Blog: [https://ncatlab.org/nlab/show/Lawvere+theory](https://ncatlab.org/nlab/show/Lawvere+theory)

- Concept: Moggi’s Monad:
  - Paper: Notions of computation and monads - [https://core.ac.uk/download/pdf/21173011.pdf](https://core.ac.uk/download/pdf/21173011.pdf)
  - Paper: The Category Theoretic Understanding of Universal Algebra: Lawvere Theories and Monads - [http://www.sciencedirect.com/science/article/pii/S1571066107000874](http://www.sciencedirect.com/science/article/pii/S1571066107000874)

### `choose` Your Own Derivative

- Presenter: Kenneth Foner - [http://very.science/](http://very.science/)
- Slides/repo\* : [https://github.com/antalsz/choose-your-own-derivative](https://github.com/antalsz/choose-your-own-derivative)
- How to abstract event based methods where you have to wait for the results:
  - Concept: Zipper Structures
    - [https://stackoverflow.com/questions/380438/what-is-the-zipper-data-structure-and-should-i-be-using-it](https://stackoverflow.com/questions/380438/what-is-the-zipper-data-structure-and-should-i-be-using-it)
    - Paper: Functional Pearls - [http://gallium.inria.fr/~huet/PUBLIC/zip.pdf](http://gallium.inria.fr/~huet/PUBLIC/zip.pdf)
    - Wikipedia: [https://en.wikipedia.org/wiki/Zipper\_(data\_structure)](https://en.wikipedia.org/wiki/Zipper_(data_structure))

  - Concept: Zippers -\> Derivative
    - Paper: The Derivative of a Regular Type is its Type of One-Hole Contexts - [http://strictlypositive.org/diff.pdf](http://strictlypositive.org/diff.pdf)
    - Blog: [http://strictlypositive.org/calculus/](http://strictlypositive.org/calculus/)

### Reactive Sheets: an intuitive approach to functional‑reactive computing

- Presenter: Enzo Alda -
- Concept: Reactive Programming: [https://en.wikipedia.org/wiki/Reactive\_programming](https://en.wikipedia.org/wiki/Reactive_programming)
- Concept: Functional Reactive Programming: [https://en.wikipedia.org/wiki/Functional\_reactive\_programming](https://en.wikipedia.org/wiki/Functional_reactive_programming)
- Concept: Incremental Computation: [https://en.wikipedia.org/wiki/Incremental\_computing](https://en.wikipedia.org/wiki/Incremental_computing)

### Typed-Tagless Final Bioinformatics

- Presenter: Seb Mondet
  - Website: [http://seb.mondet.org](http://seb.mondet.org)
  - Twitter: [https://twitter.com/smondet](https://twitter.com/smondet)

- Slides: [http://wr.mondet.org/slides/Compose2017-BioTTFI/#/](http://wr.mondet.org/slides/Compose2017-BioTTFI/#/)
- Concept: use of modules for EDSL: QueΛ
  - Course: [http://okmij.org/ftp/tagless-final/course/](http://okmij.org/ftp/tagless-final/course/)
  - Paper: [https://dl.acm.org/citation.cfm?doid=2847538.2847542](https://dl.acm.org/citation.cfm?doid=2847538.2847542)

- Code:
  - Ketrew: [https://github.com/hammerlab/ketrew](https://github.com/hammerlab/ketrew)
  - Biokepi: [https://github.com/hammerlab/biokepi](https://github.com/hammerlab/biokepi)
  - Epidisco: [https://github.com/hammerlab/epidisco](https://github.com/hammerlab/epidisco)

### The Probability Monad

- Presenter: Tikhon Jelvis
  - Website: [http://jelv.is](http://jelv.is)
  - Twitter: [https://twitter.com/tikhonjelvis](https://twitter.com/tikhonjelvis)

- Modeling probability models as monads would simplify quite a lot of things:
  - Combining distributions to get joint distributions
  - Assigning weights, normalizing, and transformations
  - Sampling for joint expectations
  - Building more complex distribution combinations (e.g. decision tree like ones)

- Paper: Functional Pearls - [http://gallium.inria.fr/~huet/PUBLIC/zip.pdf](http://gallium.inria.fr/~huet/PUBLIC/zip.pdf)
- Implementation options:
  - Exhaustive: each possible element is listed with assigned weights
    - Makes it easy to transform
    - Not feasible for all distributions

- Upsides: expressive, intuitive, and fits into Haskell
- Downsides: slow and issues with normalization
- Use case: basic examples implemented at Target to optimize distribution networks to reduce costs
- Paper: Practical probabilistic programming with monads - [http://mlg.eng.cam.ac.uk/pub/pdf/SciGhaGor15.pdf](http://mlg.eng.cam.ac.uk/pub/pdf/SciGhaGor15.pdf)
- Paper: Probabilistic Functional Programming in Haskell - [https://web.engr.oregonstate.edu/~erwig/pfp/](https://web.engr.oregonstate.edu/~erwig/pfp/)

### Lock-step simulation is child’s play

- Presenter: Joachim Breitner
  - Website: [https://www.joachim-breitner.de/](https://www.joachim-breitner.de/)
  - Twitter: [https://twitter.com/nomeata](https://twitter.com/nomeata)

- Slides: [https://github.com/nomeata/codeworld-talk](https://github.com/nomeata/codeworld-talk)
- Case studies from [https://code.world/](https://code.world/)
  - Interactive, fun, and gamified teaching platform for programming (e.g. Haskell)
  - Single-user player implementation is trivial but easily gets boring for the learner
  - Multi-user player implementation is challenging
    - Need to generalize for different types of games
    - Which user is responsible for computation and which for visualization
      - If all: redundancy, need to handle conflicts, delays, …
      - If one: hard to provide interactivity and engagement (if one cannot interact with the game, it gets boring)

    - Potential solution #1: everybody keeps track of their own local state but broadcast changes to others. This works fine with basic games (e.g. tic-tac-toe) but even minor network delays cause state divergences across clients when the game is more complex (e.g. pong)
    - Potential solution #2: use local states but broadcast more information that enable prediction of the next state on the other agent’s side

### TUTORIAL: Learning F#: Case study with branch and bound

- Presenter: David Rhodes - [http://www.opcoast.com/about.html](http://www.opcoast.com/about.html)
- Slide materials: [http://www.opcoast.com/demos/fsharp/index.html](http://www.opcoast.com/demos/fsharp/index.html)

### QuickFuzz Testing for Fun and Profit

- Presenters: Martín Ceresa and Gustavo Grieco
  - Website/Project: [http://quickfuzz.org/#authors](http://quickfuzz.org/#authors)
  - Paper: QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs - [http://www.eecs.northwestern.edu/~robby/courses/395-495-2009-fall/quick.pdf](http://www.eecs.northwestern.edu/~robby/courses/395-495-2009-fall/quick.pdf)
  - Long long list of target programming languages and file formats to be used as an input: [http://quickfuzz.org/#list-of-file-types-to-generate](http://quickfuzz.org/#list-of-file-types-to-generate)

### Working with Monads in OCaml

- Presenter: Stephen Compall
  - Twitter: [https://twitter.com/s11001001](https://twitter.com/s11001001)

- Slides: [https://bazaar.launchpad.net/~scompall/working-with-monads-in-ocaml/trunk/files](https://bazaar.launchpad.net/~scompall/working-with-monads-in-ocaml/trunk/files)
- Myth: ML doesn’t support higher kinds

## Day 2 (May 19)

### Teaching Haskell

- Presenter: Barry Burd
  - Website: [https://users.drew.edu/bburd/](https://users.drew.edu/bburd/)
  - Twitter: [https://twitter.com/allmycode](https://twitter.com/allmycode)

- To better teach the concepts of the functional programming
  - Common practice (doesn’t work well)
    - Analogies (cars, engines, burritos)
    - Pute math explanations (good for theory but too abstract)

  - What we need to do:
    - Explain everything in three ways
    - Don’t fear redundancy in the material
    - Lots and lots of various and interesting exercises
      - We don’t have enough

- Recommended resources:
  - Monad Challenges - [https://github.com/mightybyte/monad-challenges](https://github.com/mightybyte/monad-challenges)
  - Brain Beckman: Don’t Fear the Monad
    - [https://www.youtube.com/watch?v=ZhuHCtR3xq8](https://www.youtube.com/watch?v=ZhuHCtR3xq8)

  - Barry’s Introduction to Functional Programming course on O’Reilly
    - [http://shop.oreilly.com/product/0636920052463.do](http://shop.oreilly.com/product/0636920052463.do)

  - Real World Haskell - [http://book.realworldhaskell.org/](http://book.realworldhaskell.org/)
    - Great book but the exercises are not enough

- Open call for people who can contribute new exercises!

### Distrest - REST access to distributed services

- Presenters: Hezekiah Carty and Chris Donaher
  - Endgame: [https://www.endgame.com/](https://www.endgame.com/)

- Motivation
  - Data science and malware research need to happen quick at Endgame
    - Limited time and resources for developers and researchers

  - People want to use already existing domain-specific tools and libraries spanning multiple languages and hardware requirements

- Goal
  - Minimal intervention with the code to be used
  - Scale (in an easy way; e.g. adding a new computation node to the system)
  - Take tools and turn them into services
  - Ease experimentation

- Distrest
  - Handles and routes RPC-like REST requests to tool services
  - Supports multiple languages via a broker/proxy implementation in OCaml
  - Implements basic workflow engine needs (e.g. dependency graph)
  - Facilitates parallelization of service runs
  - Soon to be open-sourced ☹

- Use case
  - Collect information about the binary, extract features (via machine learning), and learn features to be used for classification of the binary (e.g. malware or not?)
  - Aggregate binaries and allow proxy requests for others interested in analyzing the archived binaries

- Practical consideration
  - Versioning, deployment/scaling, and routing
  - Kubernetes to rescue!

### Implementing an Event-Driven Microservices Architecture in F#: A case study of [Jet.com](http://Jet.com)

- Presenter: Nikhil Barthwal
  - Twitter: [https://twitter.com/nikhilbarthwal](https://twitter.com/nikhilbarthwal)
  - Website: [https://tech.jet.com/blog/author/nikhiljet-com/](https://tech.jet.com/blog/author/nikhiljet-com/)

- About [Jet.com](http://Jet.com)’s infrastructure
  - Microsoft Azure for servers and F# for implementation (back- and front-end)

### BuckleScript: Making functional programming accessible to JavaScript developers

- Presenter: Hongbo Zhang
  - Twitter: [https://twitter.com/bobzhang1988](https://twitter.com/bobzhang1988)
  - BuckleScript: [https://bloomberg.github.io/bucklescript/](https://bloomberg.github.io/bucklescript/)

- BuckleScript: A platform that features an optimizing OCaml compiler to readable JS. Optimization and readable JS code are the killer features.
- Support all OCaml except C FFI and also Facebook’s ReasonML
- Allows propagation of annotations on the OCaml level to the JS level
- No way around using JS in web-technologies so BuckleScript addresses an important need for proper programming and is not meant to become yet-another-framework
- Migration from JS to BuckleScript does not necessarily require a complete rewrite. Can be done in an incremental manner
- Supports commonly used JS module systems; e.g. AmdJS, CommonJS, ES6, Google modules
- MariOcaml comparison:
  - JSCCO (original): [https://github.com/mahsu/MariOCaml](https://github.com/mahsu/MariOCaml)
  - BuckleScript: [https://github.com/chenglou/MariOCaml](https://github.com/chenglou/MariOCaml)
  - PureScript/Fable: [https://github.com/stweb/MariOCaml](https://github.com/stweb/MariOCaml)

- Adoption: React bindings/libraries/types, WebAssembly support, …

### Android programming in Froid

- Presenter: Michael Chavinda
  - Twitter: [https://twitter.com/\_mchav](https://twitter.com/_mchav)
  - Website: [https://mchav.github.io/](https://mchav.github.io/)

- Motivation
  - For a beginner, it is really hard to get started with developing GUIs
  - There are many GUI libraries but setting up the infrastructure takes much more time than the coding itself
  - Android GUI space was essentially lacking a reliable solution
  - Choice of language: Frege - because it provides a nice intermediate stepping stone for people who are making the transition from Java to Haskell or the other way around

- Extensive documentation and guidelines are available on the Froid Wiki: [https://github.com/mchav/froid/wiki](https://github.com/mchav/froid/wiki)
- Basic setup to try Froid: [https://github.com/mchav/try-frege-android](https://github.com/mchav/try-frege-android)

### Data Driven UIs, Incrementally

- Presenter: Yaron Minsky
  - Website: [https://blogs.janestreet.com/author/yminsky/](https://blogs.janestreet.com/author/yminsky/)
  - Twitter: [https://twitter.com/yminsky](https://twitter.com/yminsky)

- When you are dealing with long lists or huge tables of data, UIs are the best; but how do you build a UI that is fast, reactive (responds to the data), and typed? Inspiration from React-\* framework
  - Structure UIs as functions of a model, action, and virtual DOM
    - Apply: applies an action on the model
    - View: mutates the virtual dom based on the expected effect of the action on the UI

  - Consider UIs as online algorithms
    - Instead of rendering the actual DOM every time the virtual one changes, instead figure out actions that are needed when all the actions are combined by incremental computing tricks: [https://en.wikipedia.org/wiki/Incremental\_computing](https://en.wikipedia.org/wiki/Incremental_computing)
    - Jane St develop a general purpose incremental computing framework, called `Incremental`:
      - Introduction: [https://blogs.janestreet.com/introducing-incremental/](https://blogs.janestreet.com/introducing-incremental/)
      - Code: [https://github.com/janestreet/incremental](https://github.com/janestreet/incremental)

  - Make use of `diff` and `patch` tools/ideas
    - Even if you are making use of a really good incremental computing framework, it is still hard to find/replace the elements that are changed for actual manipulation
    - Diff algorithms provide a nice way to reduce two versions of the model down to a minimal work to be done to convert one to another (e.g. `Table.symmetric_diff` in `Incremental`) and by making use of `patch` to fire methods required, the problem becomes easier to deal with
    - When the view itself is dynamic, the problem is a nested incremental problem.

- Useful Incremental tricks to simplify the problem: filtering, partial rendering, and focus management
- Upsides of using Incremental
  - The semantics of the code easier to understand
  - Significant performance boost
  - Sharing code is also made easy
  - Debugging becomes easier (thanks to JS)

- Demo reactive table: [https://github.com/janestreet/incr\_dom](https://github.com/janestreet/incr_dom)

* * *

Sorry, had to leave at this point. No notes from now on ☹

* * *

### Multiplying by 1 - an important form of computation and how it reveals distinctions between kleislis

- Presenter: Edmund Cape

### Smart Contracts and Formal Verification with Z3 with Pact

- Presenter: Stuart Popejoy

### New Hasql - a simpler, safer and faster Postgres client

- Presenter: Nikita Volkov

---

<div class="post-metadata">

### Author: ![avsm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/avsm/32/6_2.png) [@avsm](https://discuss.ocaml.org/u/avsm)
#### Post date: [May 22, 2017, 8:59am UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/2 "2017-05-22T08:59:08Z")

</div>

Thanks for the really useful notes, @armish! I’ve bumped your trust level up so you should be able to edit and post as many links as you like, if you want to edit the markdown.

---

<div class="post-metadata">

### Author: ![Bob\_Fang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bob_fang/32/84_2.png) [@Bob\_Fang](https://discuss.ocaml.org/u/Bob_Fang)
#### Post date: [May 22, 2017, 9:31am UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/3 "2017-05-22T09:31:19Z")

</div>

Thanks Amish, if we can have rendered markdown it would be better.

---

<div class="post-metadata">

### Author: ![armish](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/armish/32/105_2.png) [@armish](https://discuss.ocaml.org/u/armish)
#### Post date: [May 22, 2017, 5:29pm UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/4 "2017-05-22T17:29:15Z")

</div>

Thank you so much, @avsm and @Bob_fang. Thanks to the new trust level, I can now post the markdown version so I updated the post accordingly. Looks/reads much better now 🎉

---

<div class="post-metadata">

### Author: ![yomimono](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yomimono/32/192_2.png) [@yomimono](https://discuss.ocaml.org/u/yomimono)
#### Post date: [May 22, 2017, 5:49pm UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/5 "2017-05-22T17:49:58Z")

</div>

Thanks a lot for writing this up, armish! I couldn’t make Compose this year and it’s great to get pointers to what I missed.

---

<div class="post-metadata">

### Author: ![gasche](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/gasche/32/4_2.png) [@gasche](https://discuss.ocaml.org/u/gasche)
#### Post date: [May 26, 2017, 1:36am UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/6 "2017-05-26T01:36:52Z")

</div>

I just looked at the slides on [Working with Monads in OCaml](https://bazaar.launchpad.net/~scompall/working-with-monads-in-ocaml/trunk/files). Slide 15/17 mentions that “you can’t pass functors to functors”, and that this is an issue to implement

```
traverse :: Applicative f => (a -> f b) -> t a -> t (f b)

```

Would anyone know what exactly was being meant? Because you can in fact take functors are arguments to functors, and you can do `traverse` this way:

```ocaml
module type Functor = sig
  type 'a t
  val map : ('a -> 'b) -> 'a t -> 'b t
end

module type Applicative = sig
  type 'a t
  include Functor with type 'a t := 'a t
  val pure : 'a -> 'a t
  val app : ('a -> 'b) t -> 'a t -> 'b t
end

module type Monad = sig
  type 'a t
  include Functor with type 'a t := 'a t
  val return : 'a -> 'a t
  val bind : 'a t -> ('a -> 'b t) -> 'b t
end

module type Traversal = sig
  type 'a t
  module Traverse : functor (F : Applicative) -> sig
    val traverse : ('a -> 'b F.t) -> 'a t -> 'b t F.t
  end
end

module List = struct
  type 'a t = 'a list
  let map = List.map
  let pure x = [x]
  let rec app fs xs = match fs, xs with
    | [], [] -> []
    | f::fs, x::xs ->
      let y = f x in y :: app fs xs
    | (_::_), [] | [], (_::_) -> invalid_arg "List.app"
  let return = pure
  let join = List.flatten 
  let bind m f = List.map f m |> join
  module Traverse (F : Applicative) = struct
    let rec traverse f = function
      | [] -> F.pure []
      | x::xs ->
        let y = f x in
        let ys = traverse f xs in
        let ($) = F.app in
        F.pure (fun y ys -> y::ys) $ y $ ys
  end
end

module Option = struct
  type 'a t = 'a option

  let map f = function
    | None -> None
    | Some x -> Some (f x)

  let pure x = Some x
  let app f m = match f, m with
    | Some f, Some x -> Some (f x)
    | None, _ | _, None -> None

  let return = pure
  let bind m f = match m with
    | None -> None
    | Some x -> f x
end

let () =
  let module T = List.Traverse(Option) in
  let open T in
  assert
    (traverse (function true -> Some 1 | false -> Some 2) [true; false; true]
     = Some [1; 2; 1]);
  assert
    (traverse (function true -> Some 1 | false -> None) [true; false; true]
     = None);
  ()

```

---

<div class="post-metadata">

### Author: ![S11001001](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/s11001001/32/156_2.png) [@S11001001](https://discuss.ocaml.org/u/S11001001)
#### Post date: [May 26, 2017, 5:05am UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/7 "2017-05-26T05:05:49Z")

</div>

@gasche In that case I was talking about, in terms of your example

```ocaml
module Twice(F : Traversal) = struct
  let twice a b =
    let module FO = F.Traverse(Option) in
    (FO.traverse (fun a -> Some a) a,
     FO.traverse (fun a -> Some a) b)
end

```

And hey! That works. Neat!

This is surprising to me because slide 65 of [@chrisamaphone’s presentation from 2 years ago](https://speakerdeck.com/chrisamaphone/modularity-and-abstraction-in-functional-programming) mentions that higher-order functors are disallowed. Does this just mean, then, that it is merely that functor types can’t be directly used as functor arguments, but if said functors are module members it’s always fine?

---

<div class="post-metadata">

### Author: ![lpw25](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lpw25/32/144_2.png) [@lpw25](https://discuss.ocaml.org/u/lpw25)
#### Post date: [May 26, 2017, 6:33am UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/8 "2017-05-26T06:33:19Z")

</div>

> This is surprising to me because …

That talk was about SML.

---

<div class="post-metadata">

### Author: ![S11001001](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/s11001001/32/156_2.png) [@S11001001](https://discuss.ocaml.org/u/S11001001)
#### Post date: [May 31, 2017, 11:53pm UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/9 "2017-05-31T23:53:48Z")

</div>

The talk in general is about SML, but the part I pointed to refers to OCaml explicitly, comparing its functor behavior with SML and MoscowML.

---

<div class="post-metadata">

### Author: ![Drup](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/drup/32/35_2.png) [@Drup](https://discuss.ocaml.org/u/Drup)
#### Post date: [June 1, 2017, 9:54am UTC](https://discuss.ocaml.org/t/notes-from-compose-2017/240/10 "2017-06-01T09:54:38Z")

</div>

No, it just means that slide 65 is wrong:

```ocaml
module AppApp
    (F : functor (X : Set.OrderedType) -> Set.S)
    (A : Set.OrderedType)
  = F (F (A))
module SetSet = AppApp (Set.Make)
module SetSetString = SetSet (String)

```

If you want a demonstration of high order functors in action, look at the internals of ocamlgraph and ctypes.
