I Use This!
Low Activity


Analyzed 17 days ago. based on code collected 17 days ago.
Posted 28 days ago
Last October, I announced servant-template, a cookiecutter template for creating production-ready Haskell web services. Almost immediately after making it, I wished I had something for building command-line tools quickly. I know stack comes with a ... [More] heap of them, but: it’s hard to predict what they’ll do adding a new template requires submitting a PR cookiecutter has existed for ages and is pretty much better in every way So I made haskell-cli-template. It’s very simple, it just makes a Haskell command-line project with some tests, command-line parsing, and a CircleCI build. I wanted to integrate logging-effect, but after a few months away from it my tired little brain wasn’t able to figure it out. I like command-line tools with logging controls, so I suspect I’ll add it again in the future. Let me know if you use haskell-cli-template to make anything cool, and please feel free to fork and extend. [Less]
Posted 29 days ago
Late last year, my friend Tom tried to convince me that writing REST APIs was boring and repetitive and that I should give this thing called GraphQL a try. I was initially sceptical. servant, the REST library that I’m most familiar with, is lovely. ... [More] Its clever use of Haskell’s type system means that all the boring boilerplate I’d have to write in other languages just goes away. However, after watching Lee Byron’s Strange Loop talk on GraphQL I began to see his point. Being able to get many resources with the same request is very useful, and as someone who writes & runs servers, I very much want clients to ask only for the data that they need. The only problem is that there isn’t really a way to write GraphQL servers in Haskell—until now. Introducing graphql-api Tom and I put together a proof-of-concept GraphQL server implementation called graphql-api, which we released to Hackage today. It lets you take a GraphQL schema and translate it into a Haskell type that represents the schema. You can then write handlers that accept and return native Haskell types. graphql-api will take care of parsing and validating your user queries, and Haskell’s type system will make sure that your handlers handle the right thing. Using graphql-api Say you have a simple GraphQL schema, like this: type Hello { greeting(who: String!): String! } which defines a single top-level type Hello that contains a single field, greeting, that takes a single, required argument who. A user would query it with something like this: { greeting("World") } And expect to see an answer like: { "data": { "greeting": "Hello World!" } } To do this in Haskell with GraphQL, first we’d define the type: type Hello = Object "Hello" '[] '[ Argument "who" Text :> Field "greeting" Text ] And then a handler for that type: hello :: Handler IO Hello hello = pure greeting where greeting who = pure ("Hello " <> who <> "!") We can then run a query like so: queryHello :: IO Response queryHello = interpretAnonymousQuery @Hello hello "{ greeting(who: \"World\") }" And get the output we expect. There’s a lot going on in this example, so I encourage you to check out our tutorial to get the full story. graphql-api’s future Tom and I put graphql-api together over a couple of months in our spare time because we wanted to actually use it. However, as we dug deeper into the implementation, we found we really enjoyed it and want to make a library that’s genuinely good and helps other people do cool stuff. The only way to do that, however, is to release it and get feedback from our users, and that’s what we’ve done. So please use graphql-api and tell us what you think. If you build something cool with it, let us know. For our part, we want to improve the error messages, make sure our handling for recursive data types is spot on, and smooth down a few rough edges. Thanks Tom and I want to thank J. Daniel Navarro for his great GraphQL parser and encoder, which forms the basis for what we built here. About the implementation graphql-api is more-or-less a GraphQL compiler hooked up to type-based executing (aka “resolving”) engine that’s heavily inspired by Servant and uses various arcane type tricks from GHC 8. We tried to stick to implementing the GraphQL specification. The spec is very well written, but implementing it has taught us that GraphQL is not at all as simple as it looks at first. I can’t speak very well to the type chicanery, except to point you at the code and at the Servant paper. The compiler mostly lives in the GraphQL.Internal.Validation module. The main idea is that it takes the AST and translates it into a value that cannot possibly be wrong. All the syntax stuff is from the original graphql-haskell, with a few fixes, and a tweak to guarantee that Name values are guaranteed to be correct. [Less]
Posted about 2 months ago
Late last year, as part of my work at Weaveworks, I published grafanalib, a Python DSL for building Grafana dashboards. We use it a lot, and it’s made our dashboards much nicer to maintain. I’ve written a blog post about it that you can find it on the Weaveworks blog.
Posted 2 months ago
Another morning run, and more dolphin. Wish there was a way to identify them. Got a picture of the sailboat named floating point. Can't remember the name of this typeface.
Posted 2 months ago
There was some extra time before Darcy had to leave for the day, so we jumped in the boat a few minutes after sunrise. Best day yet for dolphin viewing, several dolphins were chasing fish toward us in the intersection of several canals. Darcy got ... [More] some great photos of the dolphins playing, and observed how great it is to be able to enjoy your food. [Less]
Posted 2 months ago
Notified a client about an impeding outage that I noticed during an audit today, and did some studying on the Elm language. After the rainstorm finished I took a break from studying and hopped in the boat. Full moon, and it was bright enough to read. ... [More] The river was a black mirror. Dolphins were out hunting fish with barely a ripple. Saw the largest shooting star I've ever seen, and the clouds over the barrier island in the Atlantic were full of heat lightning. [Less]
Posted 3 months ago
Headed out shortly after sunup today. Water was absolutely glassy, the winds from the weekend were gone. Dodged half a dozen large coconuts as we headed out. Went past Sampson island into the main river because it was so calm. After clearing the ... [More] mangroves could see straight to the bottom. On the way back in the water was so smooth you could see a distinct V ahead on the surface as if some invisible boat. I guessed more dolphins, and sure enough there were two more herding fish back into the docks, lazily circling and diving. [Less]
Posted 3 months ago
Another late night run after spending a fun afternoon at the zoo. Headed to the end of the canal and was delighted by a couple of Atlantic bottlenose dolphins chasing fish.
Posted 3 months ago
Tonight I headed through the west canal,and it turned out to run the length of the next island. Saw a couple of amusing boat names. A ketch named "floating point" with a legacy computer typeface, and another sailboat named "satellite office".
Posted 3 months ago
Woke up with energy today, and dressed quickly for the day. Even though I had to wear a suit for today, decided to risk a quick inspection of the island during the early morning light to assess whether we could bring anyone over. Heading back I saw ... [More] Darcy sitting outside enjoying her morning coffee substitute, and I can't think of a nicer sight. In the afternoon most of the family took naps, and then I pleaded with everyone to go for a quick island visit before dusk. We all piled on, including the two dogs. Some dogs on the canal bank started barking at some ducks, and daisy hopped in the water to join in. Cut the motor, the boat went over the dog, everyone stayed calm and we got turned around. Daisy was paddling in circles and we made it over and got her back in the boat. Arriving at the island everyone enjoyed walking around on the trails and seeing the mangroves and pines and campsites. Daisy dried off by rolling in the white sand. [Less]