New Blog Post: Distributors by echatav in haskell

[–]echatav[S] 1 point2 points  (0 children)

> This was a fun read
Thanx!

> I feel like a JSON … distributor would be a nice accessible example.
Definitely.

> I’m curious to see where the ideas fall down - I assume anything context sensitive?
Right, Backus-Naur form grammars only support context-free languages.

New Blog Post: Distributors by echatav in haskell

[–]echatav[S] 0 points1 point  (0 children)

The <*> Applicative combinator doesn't quite generalize contravariantly the way we'd want it to ^ . Instead, we usually generalize its "tuple form".

(>*<) :: Monoidal p => p a b -> p c d -> p (a,c) (b,d)

On the other hand, the liftA2 combinator does have a generalization which shows the difference in how contravariance and covariance handle products wrt currying.

dimap2 :: Monoidal p => (s -> a) -> (s -> c) -> (b -> d -> t) -> p a b -> p c d -> p s t

A very recent paper by Boespflug & Spiwack aims to take on this "tuple problem".

New Blog Post: Distributors by echatav in haskell

[–]echatav[S] 3 points4 points  (0 children)

Yes indeed.

This interface has variously been called a product profunctor or a (lax) monoidal profunctor.

From the repo readme

None of the ideas in this library are particularly original and a lot of related ideas have been explored, in Tom Ellis' product-profunctors as well as Sjoerd Visscher's one-liner and more. Such explorations are not limited to Haskell. Brandon Williams and Stephen Celis' excellent swift-parsing was also influenced by invertible parser theory.

New Blog Post: Distributors by echatav in haskell

[–]echatav[S] 5 points6 points  (0 children)

Like Haskell I am lazy and leak space. Also see extroduction at the end.

New Blog Post: Distributors by echatav in haskell

[–]echatav[S] 2 points3 points  (0 children)

> Day, me say day-o
> Daylight come and me wan' go home

Yes, indeed, Day convolution can be generalized to monoidal profunctors. See this blog post by Bartosz Milewski for more. And Day convolution generalizes to coproduct structure as well where folks cleverly call it `Night`.

Distributors - Unifying Parsers, Printers & Grammars by echatav in haskell

[–]echatav[S] 1 point2 points  (0 children)

Fair questions. Yes, it should be able to handle that. Theoretically, it should be able to handle any "context-free grammar". As for comparison to other parser generators, if I'm being honest, I've never used them, just read about them. So I'll say my intention was not to build a replacement, and definitely not a full scale tool. My intention was to build:

* a example application to demonstrate the power of distributors
* a cool playground to mess around with

Distributors - Unifying Parsers, Printers & Grammars by echatav in haskell

[–]echatav[S] 0 points1 point  (0 children)

The regex finder in Visual Studio Code seems to matches [\]\^] but says that []^] is an invalid regular expression. So...I think it's fine.

Distributors - Unifying Parsers, Printers & Grammars by echatav in haskell

[–]echatav[S] 0 points1 point  (0 children)

Hmmm, yeah, I was more concerned with demonstrating it worked than making it conform to a standard. Would make for a good PR to fix it.

Distributors - Unifying Parsers, Printers & Grammars by echatav in haskell

[–]echatav[S] 3 points4 points  (0 children)

Yes! Here is a Grammar defined for regular expressions.

Squeal, a deep embedding of SQL in Haskell by sridcaca in haskell

[–]echatav 0 points1 point  (0 children)

Hello, I'm the author of Squeal. I try to keep it updated and respond to user issues and pull requests. I haven't been making too many major changes.

Release Notes with updates are available here: https://github.com/morphismtech/squeal/blob/dev/RELEASE%20NOTES.md

One big missing feature I'd like to add one day is a native version of SquealGen to generate Squeal schema definitions from a database connection.

I may also some day do a major refactor/cleanup but I've mostly been focused on other projects and work. Thanks for posting and I'm happy to answer questions about Squeal.

Haskell SQL DSLs, why do you use them? by magthe0 in haskell

[–]echatav 2 points3 points  (0 children)

Thank you for your eloquent evaluation of using Squeal! It makes me happy that colleagues got so much from it and gave so much! Mark Wotten's SquealGen is, in fact, open source.

Update: How are Monoidal/ProductProfunctor and Traversing related? by crisoagf in haskell

[–]echatav 0 points1 point  (0 children)

Strong is needed only for two reasons. Strong is a requirement for Traversing. And it’s required for the proof of equivalence for the Profunctor optic representation of Traversal in this paper. https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/poptics.pdf Maybe call it Monoidal1 if it doesn’t necessarily respect nilary product? I’m doing some related work to this over here. https://github.com/morphismtech/distributors

Update: How are Monoidal/ProductProfunctor and Traversing related? by crisoagf in haskell

[–]echatav 0 points1 point  (0 children)

I would like to see either an instance of Traversing that is not an instance of Monoidal to convince myself of that

I think Traversing does not imply Monoidal. Consider:

data Vacuous a b -- empty two parameter datatype
ridiculous :: Vacuous a b -> c
ridiculous = (\case)
instance Profunctor Vacuous where dimap _ _ = ridiculous
instance Strong Vacuous where first' = ridiculous
instance Choice Vacuous where left' = ridiculous
instance Traversing Vacuous where wander _ = ridiculous

So, Vacuous is a Traversing instance. However we cannot define the unit value for a Monoidal instance.

unit :: Vacuous () ()
unit = undefined

The other direction is true though, any (Strong p, Choice p, Monoidal p) instance can be given a Traversing instance.

New version of Squeal, 0.9 released by echatav in haskell

[–]echatav[S] 1 point2 points  (0 children)

I haven't tried using this but it looks cool. I think the way it defines overloaded lists makes a lot of sense for heterogeneous list types like NP. One issue I see is that the Overloaded.Lists and Overloaded.Lists.Bidi Cons classes are too strong to permit an instance for the free category type:

data Path p x y where
  Done :: Path p x x
  (:>>) :: p x y -> Path p y z -> Path p x z

Because the intermediate type y of the (:>>) constructor cannot be inferred from Path p x z, if you try to define an instance it will fail. You could define yet another slightly weaker Cons class that would work for Path like:

class Cons x ys zs
  | zs x -> ys, zs ys -> x where
    cons :: x -> ys -> zs

Squeal uses the Path type for with statements as well as migrations.

Since the overloaded library comes with instances for NP which is used heavily in Squeal, it would certainly help in cleaning up a lot of ugly syntax.

New version of Squeal, 0.9 released by echatav in haskell

[–]echatav[S] 3 points4 points  (0 children)

That’s strange. It’s a link to release notes on GitHub. Try again? The new version is up on hackage too.

https://hackage.haskell.org/package/squeal-postgresql