google / google/codeworld

Encapsulated applications

Đang mở
#492 17 bình luận 0 reaction 0 người được giao Xem trên GitHub
discussion
Ngôn ngữ chính
Haskell
Star
1.3k
Fork
201
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Definitely a speculative proposal, but it might lead somewhere.

The proposal is to create an abstract type to encapsulate and build up simulations, interactions, etc. Something like:

data Application state -- abstract

defaultApplication :: state -> Application state

withTimeStep :: (Double -> state -> state) -> Application state -> Application state
withEventHandler :: (Event -> state -> state) -> Application state -> Application state
withPicture :: (state -> Picture) -> Application state -> Application state

applicationOf :: Application state -> IO ()

The various event handlers, time steps, and visualization functions would all be run, in some defined order. Pictures would be stacked with the outermost picture on top.

Advantages:

1. No need to add a time step if it's not needed.
2. Ability to abstract different effects that span events, time, and pictures (such as UI controls).
3. Ability to incorporate more components (for example, sound?) without making the top-level entry point more complex.

The API is probably not right yet, but that's the idea.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.