Codemesh 2019 - Purerl and OTP talk

Published on 2019-11-5

Just a note that I'll be appearing at Codemesh on Thursday (11:25) to give a talk where I go over some of the stuff we've been working on at Work(tm) this year - with a focus on some of the implementation details and nitty gritty/etc.

I silently blogged some of this recently, basically showing off how we've now got the ability to write OTP applications in Purescript these days, and indeed are. The posts are all linked below for the majority of folk who are sensible enough not to not subscribe to this sorry excuse for a blog.

Here is a sneaky peek as to what a gen server looks like in this world, tasty no?


findByIsbn :: String -> Effect (Maybe Book)
findByIsbn isbn = 
  Gen.doCall serverName \state@{ connection } -> do
    result <- Redis.get (dbId isbn) connection
    pure $ CallReply result state

findAll :: Effect (List Book)
findAll = 
  Gen.doCall serverName \state@{ connection } -> do
    books <- Redis.findAll dbPrefix connection
    pure $ CallReply books state

-- Nothing special about this, just a function that returns a certain type
-- We can supply arbitrary arguments to this via the gensup
startLink :: BookLibraryStartArgs -> Effect StartLinkResult
startLink args =
  Gen.startLink serverName $ init args

-- And those arguments can then end up in here, which just needs to return an effect of our State type
init :: BookLibraryStartArgs -> Effect State
init args = do
  connection <- Redis.open args.connectionString
  pure $ { connection }

The blog entries

Useful links

2020 © Rob Ashton. ALL Rights Reserved.