Last active
August 29, 2015 14:03
-
-
Save BitPuffin/db06b00319fd0cf0f8ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## First class polymorphic modules concept | |
# export module | |
let pub Renderer = module | |
let pub render Graphics Scene s = | |
let camera = Scene.get_cam s in | |
let objects = Camera.get_vis_objects camera in | |
for obj in objects | |
Grahpics.draw_object obj | |
end | |
# Yields: | |
# val <A, B, C> | |
# mod[draw_object: (A -> ()),...] -> | |
# mod[get_cam: (B -> C),...] -> | |
# B -> | |
# () | |
# (mod[something: <stuff>,...] means it's a module that has at least something) | |
end | |
# So for example if you had | |
let openglgraphics = module | |
let draw_object o = ... | |
... | |
end | |
# or | |
let d3dgraphics = module | |
let draw_object o = ... | |
... | |
end | |
# And | |
let bspscene = module | |
... (type definitions and other funcs) | |
let get_cam s = ... | |
... (stuff) | |
end | |
# you could call: | |
Renderer.render openglgraphics bspscene somescene; | |
Renderer.render d3dgraphics bspscene somescene; | |
# And it would render the a bsp scene with opengl or d3d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment