amilner42 / code-tidbit

Share Programming Knowledge Better
GNU General Public License v3.0
9 stars 1 forks source link

Messages should have SubTypes, but functions should return SuperType for flexibility #161

Closed amilner42 closed 6 years ago

amilner42 commented 7 years ago

It's great to have:

type BaseMsg
  = InnerMsg InnerMsgType
  | OtherInnerMsg OtherMsgType

because it allows us to split up our code better and reason about things better as humans (as little distraction as possible, I hate massive files with unrelated parts).

That being said, functions (views/updates) should be returning the BaseMsg, that way they have the ability only if needed to send out other messages as well.

Should be a fairly easy refactor, lots of changing function types and then adding prefixes to return the SuperType.

(Discussed this with feldman a while back, was led to this approach by him)