Closed snowleopard closed 5 years ago
Much nicer!
@ndmitchell Thanks! :) I guess this encoding is not possible in Shake, because the universe of keys is open: you want to let users add new types of keys, and therefore cannot keep them all in one GADT.
Indeed - type families are open, GADTs are not - but GADTs are a nicer solution if they work.
I've just realised that the typed version of fetch
that I added in this PR is very similar to what Haxl has:
dataFetch :: (DataSource u r, Request r a) => r a -> GenHaxl u a
This means, we can give dataFetch
a Fetch
type:
type Fetch k f a = k a -> f a
dataFetch :: (DataSource u r, Request r a) => Fetch r (GenHaxl u) a
I think this link is pretty cool. @simonmar has been talking about writing build systems in Haxl, and perhaps we could place Haxl somewhere in our Build Systems à la Carte table?
An interesting observation: we can now rewrite the type of
Task
into...which looks like a morphism between natural transformations. I'll let category theory enthusiasts explain what this strange creature is doing here.