gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
jaxtr has joined #ocaml
Xizor has quit []
Tobu has quit [Ping timeout: 272 seconds]
iago has joined #ocaml
dsheets has quit [Ping timeout: 244 seconds]
dsheets has joined #ocaml
iago has quit [Quit: Leaving]
emmanuel__ has quit [Read error: Connection reset by peer]
oriba has quit [Quit: oriba]
Pacane has joined #ocaml
<Pacane> Hi, what's the standard way of doing a pattern match with a tuple composed by something and a list reference ? I tried doing things like match a with | x, ref [] -> ... or ![]... the only way I found was to do match a with | x, l -> match !l with | > ...
<Pacane> is there a cleaner way of doing this ?
ulfdoz has joined #ocaml
ulfdoz has quit [Ping timeout: 265 seconds]
<flux> well, how about match !(snd a) with (c, n) :: t -> ..
<flux> but if you need to do other matches, the represented way is probably the way. there is also: match fst a, !(snd a) with ..
tufisi has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
pango is now known as pangoafk
ankit9 has joined #ocaml
thomasga has joined #ocaml
ftrvxmtrx has joined #ocaml
rzys has joined #ocaml
roha has joined #ocaml
munga has joined #ocaml
cago has joined #ocaml
djcoin has joined #ocaml
maufred has quit [Ping timeout: 246 seconds]
maufred has joined #ocaml
Cyanure has joined #ocaml
munga has quit [Ping timeout: 244 seconds]
roha has quit [Ping timeout: 240 seconds]
<f[x]> mrvn, yes, thought of that too, looks good
rzys has quit [Ping timeout: 252 seconds]
silver has joined #ocaml
maufred_ has joined #ocaml
maufred has quit [Ping timeout: 252 seconds]
ankit9 has quit [Ping timeout: 260 seconds]
ankit9 has joined #ocaml
djcoin has quit [Ping timeout: 244 seconds]
djcoin has joined #ocaml
djcoin has quit [Ping timeout: 252 seconds]
djcoin has joined #ocaml
Tianon has quit [Ping timeout: 260 seconds]
nick33 has joined #ocaml
Hussaind has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
munga has joined #ocaml
ski has quit [Ping timeout: 265 seconds]
tmaedaZ has quit [Ping timeout: 260 seconds]
ski has joined #ocaml
tmaedaZ has joined #ocaml
munga has quit [Ping timeout: 240 seconds]
avsm has joined #ocaml
testcocoon has quit [Quit: Coyote finally caught me]
testcocoon has joined #ocaml
rzys has joined #ocaml
roha has joined #ocaml
ankit9 has quit [Read error: Operation timed out]
ankit9 has joined #ocaml
nick33 has quit [Ping timeout: 245 seconds]
avsm has quit [Ping timeout: 244 seconds]
avsm has joined #ocaml
roha has quit [Ping timeout: 248 seconds]
rzys has quit [Ping timeout: 248 seconds]
rzys has joined #ocaml
roha has joined #ocaml
bjorkintosh has joined #ocaml
munga has joined #ocaml
eni has joined #ocaml
_andre has joined #ocaml
cyphase has quit [Ping timeout: 246 seconds]
caligula has quit [Ping timeout: 240 seconds]
emmanuel__ has joined #ocaml
caligula has joined #ocaml
cyphase has joined #ocaml
roha has quit [Quit: Leaving]
rzys has quit [Quit: Leaving]
larhat has joined #ocaml
yroeht has quit [Ping timeout: 245 seconds]
yroeht has joined #ocaml
mmajchrzak has joined #ocaml
mort___ has joined #ocaml
mort___ has left #ocaml []
Cyanure has quit [Quit: Quitte]
fraggle_ has quit [Read error: Connection reset by peer]
fraggle_ has joined #ocaml
NaCl has quit [Ping timeout: 272 seconds]
emmanuel__ has quit [Read error: No route to host]
ankit9 has quit [Remote host closed the connection]
rly has quit [Read error: Connection reset by peer]
svenl has quit [Ping timeout: 245 seconds]
svenl has joined #ocaml
libertas has joined #ocaml
BiDOrD has joined #ocaml
BiDOrD_ has quit [Ping timeout: 265 seconds]
NaCl has joined #ocaml
NaCl has quit [Changing host]
NaCl has joined #ocaml
mmajchrzak has quit [Remote host closed the connection]
roha has joined #ocaml
Znudzon has joined #ocaml
emmanuelux has joined #ocaml
larhat has quit [Quit: Leaving.]
reynir has quit [Changing host]
reynir has joined #ocaml
Znudzon has quit [Read error: Operation timed out]
thomasga has quit [Quit: Leaving.]
ftrvxmtrx has quit [Quit: Leaving]
j2d2j2d2 has joined #ocaml
Znudzon has joined #ocaml
cago has quit [Quit: Leaving.]
iago has joined #ocaml
Znudzon has quit [Ping timeout: 252 seconds]
tmaedaZ is now known as tmaeda
munga has quit [Ping timeout: 265 seconds]
thomasga has joined #ocaml
thomasga has quit [Client Quit]
<pippijn> why do I have to list the parameter name twice in named parameters with default values?
<pippijn> class virtual widget ?x:(x=0) ?y:(y=0) ?width:(width=0) ?height:(height=0) ~parent = object (self)
<thelema> pippijn: you don't have to ?(x=0) should work
<pippijn> ah
<pippijn> better
<thelema> if you wanted to call the parameter one thing while the bound variable in the function was something else, you'd use your syntax
<pippijn> ok
<pippijn> I just glanced at the manual and they seem to want that
tmaeda is now known as tmaedaZ
tmaedaZ is now known as tmaeda
Snark has joined #ocaml
<flux> hmm, what benefit does that pippijn's syntax give?
<_habnabit> 16:23:40 < thelema> if you wanted to call the parameter one thing while the bound variable in the function was something else, you'd use your syntax
smondet has joined #ocaml
<flux> somehow I missed that. right, I've sometimes thought about that..
<pippijn> I'm making a curses widget kit
<pippijn> trying to make it as immutable as possible
<jonafan> sounds like a fun recipe for monads
<pippijn> the problem is that curses is in C and inherently mutable
pangoafk is now known as pango
<pippijn> I think I'm going to need to reduce the C dependency
<pippijn> and only use low level cursor movement functions from curses
<flux> shouldn't you use the termcap library for that, then?
<flux> and not depend on ncurses at all
<pippijn> is there an ocaml binding?
<flux> I think some curses bingins comes with termcap binding..
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
<pippijn> ok, I know what I will do
<pippijn> I'm going to make my widget library independent of the output
<pippijn> just have an abstract representation of the widgets along with painting functionality
<pippijn> and then pass some drawing function in that the painting functionality uses to actually perform the drawing operations
avsm1 has joined #ocaml
<pippijn> hmm
<pippijn> {< geometry.position = position >} would be nice
<pippijn> {< geometry = { geometry with position } >} is also ok
avsm1 has quit [Client Quit]
avsm has quit [Ping timeout: 260 seconds]
<mrvn> pippijn: the later even works
<pippijn> I know
<pippijn> I use it
<mrvn> geometry.position <- position; if it is mutable.
<pippijn> it's not
<pippijn> I want all my widgets to be immutable
<pippijn> if possible
<pippijn> it's probably not feasible for all widgets
<mrvn> With GUIs I found that it generally fits best to handle widgets as objects with mutables.
<pippijn> mrvn: I want to experiment :)
<mrvn> So you have a base widgets that has position and size and inherit that in your button widget and so on
<pippijn> sure
<pippijn> I will have that, too
<mrvn> If you make it purely functional then changing the button from normal to pressed state will involve going through your full widgets hierachy.
<pippijn> hmm
<pippijn> that's true
<adrien> which might be needed if pressing the button change the size of the button
<pippijn> so maybe I can make "children" mutable
<adrien> that one example might sound bad but there are so many possible widgets
<mrvn> adrien: only if that change propagates through to the top. Also most buttons don't change size when pressed
<pippijn> or children will be widget ref list
<mrvn> pippijn: don't use ref in records. waste of an indirection.
<pippijn> or children will be widget array
<mrvn> pippijn: yeah, instant mutable
<pippijn> yes
<pippijn> but the rest of my widget can still be immutable
<pippijn> geometry, etc.
<mrvn> I also like the button to have a pointer to its parent. And then you get cycles and purely functional becomes ugly.
<pippijn> I don't think my widgets are going to reparent
Zedrikov has joined #ocaml
<pippijn> actually that parent thing is a problem
<pippijn> or could become one
<pippijn> oh well
<pippijn> I'll see where it goes :)
<pippijn> mrvn: what problems do you foresee?
zuymanto has joined #ocaml
<flux> such problems that it's best to avoid pointers to parent :)
<flux> try constructing a pure functional tree where child nodes have pointers to parent nodes
<flux> unless you don't have actual pointers but ids
<flux> which is the solution, but introduces O(log n) overhead
<flux> probably not too bad for a text-based UI.
<Zedrikov> Sorry, I missed the discussion, but when you have problems with parents in a tree, isn't it a good idea to use a zipper?
<jonafan> ui updates are never going to be pure unless you do an IO monad type thing
<jonafan> then it's debatable
<mrvn> flux: you can use a hashtabl to get O(1)
<flux> mrvn, but hashtables aren't pure
<jonafan> ocaml has got great capabilities for things other than pure functional programming
<mrvn> well, we aren't fanatics.
<flux> I suppose you could leave that part, associating ids to nodes, impure
<flux> but then you would need to have a way to garbage collect those entries
<flux> so you would actually need to use some boxed integers in a weak hashtable
<mrvn> flux: weak
<pippijn> I wonder if I even need parent relationships
<pippijn> hm.. I probably do
<mrvn> I used it to follow the mouse. I kept a reference to the widget the mouse is currently in and where input should go. Then on mouse move I only need to check if the mouse left that one widget. if so drop to the parent until the mouse is inside again and then rise to the leaf widget the mouse is in.
<pippijn> right
<pippijn> but for a text ui?
<mrvn> yeah. You can probably even use a flat array of widgets without tree hierachy at all.
<pippijn> widgets can overlap, though
<pippijn> and hide others
<pippijn> so I need at least a stack of active widgets
<flux> btw, if you want to neatly layout widgets by each other, seriously consider implementing (or taking into use) a constraint solver
<pippijn> :)
<flux> actually, maybe you should take a look how QtQuick/QML is used, I think it is easily the best GUI toolkit concept out there :)
<pippijn> yes, I've briefly thought about it
<pippijn> and yes, I've used QML
<flux> well, you should be on the right track then :)
<pippijn> and I'm considering to do something similar
<mrvn> where is the fun in reinventing the wheel in that?
<pippijn> reinventing the wheel?
<pippijn> where is the wheel?
<mrvn> writing yet another gui toolkit, writing yet another editor, ...
<pippijn> I don't know any proper TUI toolkit
<pippijn> let alone one for ocaml
<mrvn> suse wrote one 2 years ago that supports tui and X11
munga has joined #ocaml
<pippijn> there is fun in learning ocaml, though
<pippijn> I'm new to ocaml and this seems like a good way to get to know the object system
<mrvn> and some things you have to try yourself to understand the problems. Hence reinventing the wheel.
<flux> you're probably in for a ride if you want to implement a TUI toolkit with functional ocaml objects :)
<mrvn> That just adds a log(n) term to the runtime.
mfp has quit [Ping timeout: 246 seconds]
roha has quit [Ping timeout: 252 seconds]
Tobu has joined #ocaml
<mrvn> My game has a map. But I can't put the map related stuff in module Map, obviously. So whats a good alternative name for it?
<pippijn> Game_map?
<Hodapp> Map_
<pippijn> World_map?
<mrvn> didn't I say "good"? Yep, I did. :)
<pippijn> I have the same problem
<pippijn> my game also has a map
<pippijn> if you come up with a good name, let me know
<mrvn> In other games I've used Board
<pippijn> yeah.. in my game it's not a board, it's a map, like yours
<mrvn> maybe Game.Map or {Client,Server,Common}.Map
<mrvn> Idea from another channel: World
<pippijn> yes
<pippijn> World or World_map
<pippijn> in my game, it's not necessarily the world
<pippijn> because there is a world map, but there are also houses you can go into
<thelema> terrain
<mrvn> type terrain = Border | Ocean | Beach | Grass | Rock | Snow
<thelema> earth? (or if not on earth, "planet" or specific planet name)
<mrvn> a tile has a terrain. would be confusing to have terrain -> tile -> terrain'
<mrvn> thelema: pippijn can go into houses
eni has quit [Quit: Leaving]
<thelema> "ground", although not meant as "what's beneath you", but in the sense of figure vs. ground
<mrvn> If I have module Game = struct module Map = struct ... end let map = Map.Make .... end how do I make the last Map use ocamls Map module?
<hcarty> mrvn: module Stdlib_map = Map ...
<mrvn> do I need to insert a module OcamlMap = Map before defining my own?
djcoin has quit [Quit: WeeChat 0.3.2]
<mrvn> hcarty: hehe, greate minds and all :)
<hcarty> mrvn: :-)
<pippijn> is Map a functional map?
<pippijn> All operations over maps are purely applicative (no side-effects).
<pippijn> it is :) nice
<mrvn> all functors in ocamls stdlib are
nick33 has joined #ocaml
<hcarty> mrvn: Is that true of Hashtbl.Make?
<pippijn> I'm thinking about my TUI toolkit
<thelema> hashtbl is not applicative
<pippijn> I could have a pure data structure for the UI structure and then another one for state
<mrvn> hmm, maybe I'm wrong. I thought it was but: val add : 'a t -> key -> 'a -> unit
<mrvn> pippijn: I would give each widget an id and use a weak hashtbl for lookups of ids.
<pippijn> I will have ids
ftrvxmtrx has joined #ocaml
<pippijn> I need them for position relation expressions
<pippijn> "2 characters right of widget 'id'"
<mrvn> _crash: Ich kann das Map modul an was anderes binden aber ich denke das waer verwirrend.
<mrvn> ups
<mrvn> EWIN
<mrvn> pippijn: How about Plan or Blueprint?
<pippijn> have you seen my screenshot?
<mrvn> yes, looks like a plan to me.
<pippijn> Plan lets me think it's a plan..
<pippijn> like
<pippijn> thinking abotu something, making a plan, then doing it
Hussaind has quit [Remote host closed the connection]
<pippijn> it could be related to AI planning
<pippijn> blueprint maybe.. but it's all not really nice
<mrvn> blueprint works for inside houses
<pippijn> yeah
<pippijn> but the map contains monsters
<mrvn> Map really is the only good word for it.
<pippijn> it is
<mrvn> I think I will go with World because the World contains everything in the World for me.
<pippijn> for me, it's currently called Game_map
<pippijn> http://paste.xinu.at/nyelp/ my character died
Snark has quit [Quit: Quitte]
<mrvn> what is %?
<pippijn> the floor in that room
<pippijn> it is whatever the server sends for that tile
<pippijn> there is no movement, yet, so I can't get out of that room to show other things, now
ulfdoz has joined #ocaml
avsm has joined #ocaml
<mrvn> I've been thinking of RSR (Rectangular Symmetry Reduction) a bit more. If I consider all obstacles on the map as nodes and build a Delaunay triangulation then I know a GOTO will have to cross the edges and can go straight between edges. Then I just need to add some extra nodes in there where the terrain changes so different movement costs are considered.
pango has quit [Ping timeout: 265 seconds]
<mrvn> And since obstacles can be bigger than one tile the edges would be kind of thick lines and I only need to consider the boundary tiles of each.
<thelema> mrvn: sounds good to me.
<mrvn> iregular empty regions (where 2 points may not be connectable with a straight line) would have to be artificially divided but that is not that hard.
<mrvn> The other idea I had this morning was to use Voronoi polygons and precompute the cost for traveling along each edge. Then find the shortest path along the edges and smooth it out as you move.
<mrvn> That would work for any terrain and wouldn't rely on equal move
<mrvn> movement costs
pango has joined #ocaml
nick33 has quit [Ping timeout: 245 seconds]
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
<mrvn> One thing bugs me with my game design. I'm keeping everything generic. So a building has some shape of tiles it covers, some input points where it accepts items and output points where it produces items. And it can send out its occumpant(s) for jobs like plant a tree or sow some corn. Again generic: find a place with free tiles, create item (tree or corn) there. So once I have implemented the farm with sowing and reaping a
nick33 has joined #ocaml
<flux> cut off at "reaping a"
<mrvn> and reaping all the other buildings are just some more data. The game is fully functional. Till then nothing works at all. No implementing one building and playing a mini version first.
<jonafan> you're writing a game in ocaml?
<mrvn> jonafan: yes. Had to try it sometime.
<jonafan> what library do you use for drawing stuff?
<jonafan> i don't know game development but i want to learn some day
<mrvn> jonafan: http://mrvn.homeip.net/map/foo.gif, sdl currently.
<jonafan> hexagons!
<mrvn> The Tux is now animated though. Just haven't caputerd it yet.
<mrvn> I'm thinking of trying out lablgl instead though. That way I can include height for each tile.
<jonafan> wow, if i was making the OcamlSDL logo? i would have done a lot of things differently
<mrvn> no grinning joystick?
<jonafan> yeah
<jonafan> at least make the cord come out on the right side there
<jonafan> or no cord
zuymanto has quit [Quit: zuymanto]
<jonafan> i doubt people are going to look at it and go "hey where's the cord??? is this supposed to be some kind of joke???"
tautologico has joined #ocaml
eni has joined #ocaml
<jaxtr> koolachoopa
larhat has joined #ocaml
hyperboreean has quit [Ping timeout: 265 seconds]
larhat1 has joined #ocaml
larhat has quit [Read error: Connection reset by peer]
hyperboreean has joined #ocaml
eni has quit [Quit: Leaving]
nick33 has quit [Ping timeout: 245 seconds]
ggherdov has joined #ocaml
ulfdoz has quit [Ping timeout: 265 seconds]
<pippijn> for ocaml classes, is it recommended to name the class after the module it is in?
<pippijn> I have a module Pen with a class pen and a module Buffer_pen with a class.. buffer_pen? or pen?
<flux> if you are going to have one class per module, you could call it 't'
<flux> (or 'mostly' one)
<pippijn> ah
<flux> t is usually the name of the central type of a module
<pippijn> right
Cyanure has joined #ocaml
_andre has quit [Quit: leaving]
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
zaltekk has left #ocaml []
munga has quit [Ping timeout: 246 seconds]
tufisi has quit [Ping timeout: 265 seconds]
sgnb has quit [Ping timeout: 246 seconds]
Zedrikov has quit [Quit: Bye all, see you next time!]
zuymanto has joined #ocaml
ggherdov has quit [Ping timeout: 252 seconds]
libertas has quit [Ping timeout: 260 seconds]
libertas has joined #ocaml
tmaeda is now known as tmaedaZ
tmaedaZ is now known as tmaeda
tmaeda is now known as tmaedaZ
<pippijn> method frame viewport = ({< viewport = viewport >} :> Pen.t)
<pippijn> is there a way to declare frame so I don't need to coerce it?
libertas has quit [Ping timeout: 252 seconds]
<pippijn> some sort of "open" object type?
<pippijn> method virtual frame : geometry -> < Pen.t; .. > something like this
<pippijn> I basically want to put typeof (self) there
<pippijn> in the mli, it's called 'a
<pippijn> object ('a) method ... -> 'a
<_habnabit> why do you have to coerce it at all?
<pippijn> because it's in a derived class
<pippijn> but an expression was expected of type Pen.t
<pippijn> Self type cannot be unified with a closed object type
<_habnabit> can you give an example of code that fails to compile?
<thelema> pippijn: in this case, you need the coercion
<pippijn> ok
<thelema> ocaml does much less coercion of objects than all other OO languages
<thelema> the alternative is to not define foo and to just let the types work themselves out (you don't need inheritance for interchangeable classes)