Thought Experiment:
Parent.hs
data Parent = Parent deriving (ViewId)
class HyperView Parent es where
data Action Parent = Refresh
update = do
...
...
hyper Child $ ...
Child.hs
data Child = Child deriving (ViewId)
class HyperView Child es where
data Action Child = UpdateSomething
update = do
...
...
trigger Parent $ Refresh
These are mutually recursive HyperViews.
If I want functionality like the above, I’m forced to keep both Parent and Child in the same module.
This becomes messy if I want to keep Parent and Child in separate modules.
However, this mutual recursion is unnecessary.
- The
update of Parent depends on data Child.
- The
update of Child depends on data Parent and data Action Parent.
The update functions themselves aren’t mutually recursive -
they only appear to be because both Action and update are tied to the same class.
It should be possible to split HyperView into two parts:
class HyperViewDef id es where
data Action id :: Type
type Require id :: [Type]
type Require id = '[]
class HyperViewImpl id es where
update :: Action id -> Eff (Reader id : es) (View id ())
This split provides much more flexibility in how functionality can be organized.
It also makes conceptual sense to separate definitions and relationships from implementation.
There may be better ways to approach this.
The use case described above represents a very natural way to think about UI structure and how UI elements should communicate.
Thought Experiment:
Parent.hs
Child.hs
These are mutually recursive HyperViews.
If I want functionality like the above, I’m forced to keep both
ParentandChildin the same module.This becomes messy if I want to keep
ParentandChildin separate modules.However, this mutual recursion is unnecessary.
updateofParentdepends ondata Child.updateofChilddepends ondata Parentanddata Action Parent.The
updatefunctions themselves aren’t mutually recursive -they only appear to be because both
Actionandupdateare tied to the same class.It should be possible to split
HyperViewinto two parts:This split provides much more flexibility in how functionality can be organized.
It also makes conceptual sense to separate definitions and relationships from implementation.
There may be better ways to approach this.
The use case described above represents a very natural way to think about UI structure and how UI elements should communicate.