graninas / Hydra

Hydra is a full-fledged framework for building web services, multithreaded and concurrent applications with SQL and KV DB support.
BSD 3-Clause "New" or "Revised" License
189 stars 13 forks source link

orphan: move instance church random to same module with base type #34

Closed yaitskov closed 4 years ago

yaitskov commented 4 years ago

An attempt to avoid orphan instance warning for Random.

I see that the app tries to represent multiple ways to solve problem - Free monad or Church monad. In the real app such situation would not happen.

From one side both solution must be independent and data RandomF must copy-pasted for every case or both Random instances must reside in the same module.

I thought about wrapping RandomF with a new type.

newtype ChurchRandomF next = ChurchRandomF (RandomF next)
type RandomL = F ChurchRandomF

definition of RandomF is reused but I am not sure about the rest of dependent code base.

Besides orphan warning, trunk version is also asymmetric. Why RandomF Free instance is defined in together with type definition but F is not? I would expect to see 2 orphan warnings.

graninas commented 4 years ago

Hi, thanks!

This is acceptable for now because we don't have to make it perfect. So I'll merge your change.

But it seems the project should be restructured even more, to have a separate engines easily accessible and with a good naming. In particular, see #8 .