Duffer’s Guide to git Internals

Vaibhav Sagar

What

My Library

  • an API for git repositories
  • Pure Haskell

Demo

Code

Types

Types

Functor

Applicative

Monad (Transformers)

Bit Twiddling

Streaming

Layout

src
├── Duffer
│   ├── Loose
│   │   ├── Objects.hs
│   │   └── Parser.hs
│   ├── Loose.hs
│   ├── Misc.hs
│   ├── Pack
│   │   ├── Entries.hs
│   │   ├── File.hs
│   │   └── Parser.hs
│   ├── Pack.hs
│   ├── Plumbing.hs
│   ├── Unified.hs
│   ├── WithRepo.hs
│   └── WorkObject.hs
└── Duffer.hs

Testing

  • duffer uses its own repo to test itself.

Functional Git

Data Structures

  • Merkle trees & Merkle DAGs
  • Not too different from an efficiently implemented functional data structure.

Design

  • Append-only object store and mutable ref store
  • Separating the immutable and the mutable? Sounds like this language I know…

More

What’s next?

  • A better API
  • Multiple backends

Ideas

  • A git-based project management system
  • Using git as the backend of an application

My experience with Haskell

Advice for beginners

  • Don’t get too hung up on understanding monads before you write any code
  • Lots of support on IRC and r/haskell
  • IHaskell is a godsend and everyone should use it

Bad

  • Documentation is mostly terrible
  • Hard to find the right libraries
  • Very demanding learning curve

Some thoughts

  • I thought Haskell was pretty silly the first time I encountered it
  • Only after a couple of bad production experiences did I see the point
  • How else do we provide a compelling reason to learn it?

What can you do with this

Historical Revisionism

Git Objects as a Service

Further Reading

Better Implementations

  • https://github.com/vincenthz/hit - a pure Haskell implementation of Git objects
  • https://github.com/jwiegley/gitlib - A type-safe interface with many backends
  • http://stefan.saasen.me/articles/git-clone-in-haskell-from-the-bottom-up/

Interesting Projects

  • https://github.com/mirage/irmin - A distributed database with Git-like design

About this project

RC

https://www.recurse.com

Questions?