gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0 http://bit.ly/aNZBUp
ikaros_ has quit [Quit: Leave the magic to Houdini]
jm_ has quit [Remote host closed the connection]
tauntaun has joined #ocaml
gildor has quit [Ping timeout: 276 seconds]
gildor has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
ulfdoz_ has joined #ocaml
seafood has joined #ocaml
ulfdoz has quit [Ping timeout: 246 seconds]
ulfdoz_ is now known as ulfdoz
arubin has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
fraggle_ has joined #ocaml
fraggle_ has quit [Quit: -ENOBRAIN]
seafood has quit [Quit: seafood]
fraggle_ has joined #ocaml
vijayl has joined #ocaml
vijayl has left #ocaml []
boscop has quit [Ping timeout: 255 seconds]
Edward has quit []
philtor has joined #ocaml
npouillard has quit [Ping timeout: 248 seconds]
npouillard has joined #ocaml
tauntaun has quit [Quit: Ex-Chat]
sepp2k1 has quit [Quit: Leaving.]
tauntaun has joined #ocaml
tauntaun has quit [Ping timeout: 264 seconds]
lopex has quit []
smerz has quit [Quit: Ex-Chat]
arubin has quit [Ping timeout: 260 seconds]
surikator has joined #ocaml
arubin has joined #ocaml
khia0 has joined #ocaml
khia0 has left #ocaml []
dnolen has quit [Quit: dnolen]
surikator has quit [Quit: surikator]
avsm has quit [Read error: Connection reset by peer]
avsm has joined #ocaml
arubin has quit [Quit: arubin]
philtor has quit [Ping timeout: 255 seconds]
seafood has joined #ocaml
avsm has quit [Ping timeout: 255 seconds]
avsm has joined #ocaml
seafood has quit [Ping timeout: 276 seconds]
ygrek has joined #ocaml
ymasory has quit [Remote host closed the connection]
myu2 has joined #ocaml
Cyanure has joined #ocaml
yezariaely has joined #ocaml
yezariaely has left #ocaml []
wchicken3 has joined #ocaml
mo3b1us has joined #ocaml
ikaros has joined #ocaml
<wchicken3> hey guys
<wchicken3> looking to improve my ocaml-fu (again)
<wchicken3> I'd like to write the equivalent of Array.fold_right2
<wchicken3> I could rig up something with Array.iteri, but I was wondering if that would be inefficient
<wchicken3> I get the feeling that writing in imperative style limits the optimizer
edwin has joined #ocaml
Oejet has joined #ocaml
mo3b1us has quit [Quit: leaving]
spearalot has joined #ocaml
Yoric has joined #ocaml
xl0_ is now known as xl0
spearalot has quit [Quit: Get MacIrssi - http://www.sysctl.co.uk/projects/macirssi/]
ulfdoz has quit [Quit: kernel-update]
ulfdoz has joined #ocaml
Edward has joined #ocaml
papers has joined #ocaml
boscop has joined #ocaml
Edward has quit [Ping timeout: 260 seconds]
sepp2k has joined #ocaml
tauntaun has joined #ocaml
Edward has joined #ocaml
oriba has joined #ocaml
lopex has joined #ocaml
avsm has quit [Quit: Leaving.]
Edward has quit [Ping timeout: 276 seconds]
<thelema> wchicken3: in theory yes, but in practice, no. If ocaml did deforestation, imperative code could limit the optimizer. but it doesn't, and it doesn't, so don't worry about it
avsm2 has joined #ocaml
Edward has joined #ocaml
lopex has quit []
<thelema> ~.
dnolen has joined #ocaml
papers has quit [Ping timeout: 255 seconds]
<Julien_T> hi, does someone know why a functorized code use more memory than a defunctorized one ?
<Julien_T> I have a small function, which is in a module parametrized by a module encapsulating numbers and theyre operations. when I instantiate this module it seems to allocate 2 times more memory than when I use a manually defunctorized version of the function.
<Julien_T> I would expect that it use more space on the stack, but not in the Head
<Julien_T> heap
<ygrek> module is implemented as tuple of functions, maybe that could explain?
papers has joined #ocaml
iris1 has joined #ocaml
<iris1> Dear experts, I am having trouble installing Ocaml Batteries Included on my computer. I believe I have the required versions of OCaml, Findlib and Camomile installed. When I type "make", there is an error message saying stuff like "ld: warning: -read_only_relocs cannot be used with x86_64" and "ld: pointer in read-only segment not allowed in slidable image, used in .L330 from src/batteries_uni.a(batInnerIO.o)", finally "collect2: ld returned
<iris1> exit status". This is on a Mac Pro (with dual quad-core Intel Xeon processors), the operating system is Mac OS X version 10.6.6. The full output is at http://pastebin.com/wX86t0Zf.
<iris1> It seems like -read_only_relocs is causing this problem, do you agree? Unfortunately I haven't been able to find it anywhere by grepping for it in the source code.
<iris1> Please advise. Thank you very much in advance!!
<Julien_T> ygrek, by tuple you mean a kind of record ? I do not see how it can use more at call time.
<mrvn> as argument to every function
<ygrek> instantiated functor references some values and keeps them around? (just guessing. maybe you could show the code)
<Julien_T> it's purely functional
<Julien_T> the function is
<Julien_T> let heatEquationFormula dt dx gamma uI uIMinusOne uIPlusOne =
<Julien_T> Number.add
<Julien_T> (Number.mul (Number.div (Number.mul gamma dt) (Number.mul dx dx))
<Julien_T> (Number.sub (Number.sub (Number.add uIPlusOne uIMinusOne) uI) uI)) uI
<Julien_T> I instanciate it with float and operations on float
<adrien> "Iet open Number in" :P
<Julien_T> the code is extracted from Coq ;)
<Julien_T> but thx I didn't now this shorthand
<adrien> heh, "let open Module in" isn't old afaik
<adrien> afair*
<mfp> iris1: IIRC there's a problem with cmxs libs (in general) in 64-bit OSX
lopex has joined #ocaml
<adrien> Julien_T: I don't have an answer but I'm curious: how much more memory is it using?
<mfp> iris1: you can try to do BATTERIES_NATIVE_SHLIB=no make
<Julien_T> The Gc says that 2 times more mémory has been allocated
<mfp> Julien_T: which concrete type are you using for the numbers in the defunctorized version, float?
<Julien_T> yes
<mfp> ocamlopt is probably using unboxed floats in the defunctorized version
<ygrek> Julien_T, I don't observe any difference
<Julien_T> yes, looking at the assembly code it seems to use directly processors operations
<iris1> mfp: Thank you very much! "BATTERIES_NATIVE_SHLIB=false make" worked. Does this mean that I will not be able to use Batteries Included in .native compiled programs, or just that such programs will have Batteries linked in statically?
<Julien_T> ygrek, did you compile to native code ?
<ygrek> no, testing in toplevel
<ygrek> :(
<Julien_T> actually the code is in a functor which depends on other module
<mfp> iris1: just static linking
<Julien_T> I think the problem is specific to native compilation
lopex has quit [Ping timeout: 260 seconds]
<iris1> mfp: Thank you very much!
<mfp> Julien_T: there's no unboxing in bytecode, so that supports the conjecture that you're just seeing ocamlopt's unboxing at work in the defunctorized case
<ygrek> yeah, confirmed
<mfp> iris1: np
<Julien_T> oki
<Julien_T> but the difference seems huge, 2 times more memory !
tauntaun has quit [Quit: Ex-Chat]
<mfp> well, with boxed floats each op results in the allocation of IIRC 2 words + 8 bytes, so 16 bytes on 32-bit or 24 on 64-bit archs
Edward has quit []
tauntaun has joined #ocaml
<ygrek> hm, ocamldefun page seems to be gone
<Julien_T> yes the project is no more active
<mfp> so this would mean all your float ops allocate about as much as the rest of the program
<Julien_T> ok
<mfp> you defunctorize semi-manually with camlp4.macro's INCLUDE, by placing the functor body in a separate file
<mfp> then you can reuse it as in module X(A : SIGA)(B : SIGB) = struct INCLUDE "functor_body.ml" end (* and now the defunctorized one *) module A = ... module B = ... INCLUDE "functor_body.ml"
<mfp> this way you can at least reuse the code to provide a generic (functorized) version and optimized, specific ones, even if the .ml cannot be redistributed
<Julien_T> My code is extracted for Coq so I cannot use such trick, but the most important for me was to have an explanation for the difference in memory consumption.
<Julien_T> So thanks a lot :)
trch has joined #ocaml
lopex has joined #ocaml
dnolen has quit [Quit: dnolen]
<mrvn> iptables -L -v
<mrvn> ups
mlh has quit [Ping timeout: 252 seconds]
mlh has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
avsm has joined #ocaml
SoftTimur has joined #ocaml
SoftTimur has left #ocaml []
arubin has joined #ocaml
bbc has joined #ocaml
lopex has quit []
Edward has joined #ocaml
ymasory has joined #ocaml
Edward has quit [Ping timeout: 276 seconds]
Oejet has quit [Quit: Leaving.]
Oejet has joined #ocaml
eelte has quit [Quit: 0x2a]
avsm has quit [Quit: Leaving.]
tauntaun has quit [Ping timeout: 240 seconds]
Edward has joined #ocaml
<oriba> hi, I just tried simplified-dtd in hethtml the first time.
<oriba> using it changes the parse-outcome extremely
<oriba> any docs around that describe this behaviour in more detail?
<oriba> refman is not very verbose on it
<oriba> s/hethtml/nethtml/
tauntaun has joined #ocaml
boscop_ has joined #ocaml
Edward__ has joined #ocaml
boscop has quit [Ping timeout: 255 seconds]
Edward has quit [Ping timeout: 264 seconds]
<adrien> I think I need some kind of database of values to modules: find which modules provide some values, but I don't feel like rolling my own short-term solution
<adrien> ocamlbrowser provides that but it's not really fast
tauntaun has quit [Quit: Ex-Chat]
<iris1> Dear experts, I have another question for you. I am trying to do something very simple but it does not work. I must be missing something really simple. I am trying to use ocamlbuild to make a new toploop. It succeeds and seems to build all the necessary files (including a .cmi and a .cmo for the module I am trying to make available), but when I run my new toploop the module does not seem to be available. The paste http://pastebin.com/55Mn
<iris1> describes exactly what I am trying to do. The file a.ml contains the function fa I would like to integrate into my toploop. The toploop produced (x.top) does not seem to know about "A.fa". But I can still load it manually. Please advise. Thank you very much in advance!
<adrien> that reminds me of something but I can't say exactly: I think it's something quite simple, maybe a missing .cmi (I don't know much when it comes to making custom toplevels)
<adrien> try "ocaml -I ." or whatever folder has your .cmi
trch has quit [Remote host closed the connection]
coucou747 has joined #ocaml
<iris1> Ah, that does the trick!!! Thank you very much!
RyanRN has joined #ocaml
eye-scuzzy has quit [Quit: leaving]
eye-scuzzy has joined #ocaml
<adrien> =)
<kaustuv> If your platform supports #load, there is very little reason to make a new toplevel. You can just make a .cma and #load it in .ocamlinit instead.
<adrien> through ocamlfind too :-)
<iris1> Hmm, those are intriguing comments. Let me make sure I understand what you are saying...
<kaustuv> Your .ocamlinit should contain: #directory "_build";; #load "whatever.cma";;
<kaustuv> Possibly other #loads before that in case you have dependencies
<iris1> Thank you! I am just trying to figure out how to make that .cma. I thought that renaming my x.mltop to x.mllib and then doing "ocamlbuild x.lib" would do the trick, but I am having problems with it...
<kaustuv> ocamlbuild x.cma should be enough
edwin has quit [Remote host closed the connection]
edwin has joined #ocaml
coucou747 has quit [Quit: 0x2a]
edwin has quit [Client Quit]
edwin has joined #ocaml
<iris1> Yes, "ocamlbuild x.cma" totally works, thank you! I am now reading up about .ocamlinit to understand your other suggestion
lopex has joined #ocaml
<adrien> ocamlfind is something you definitely want if you want to publish and share your library: it allows me to type: < #require "lablgtk-react" > to load lablgtk2, react and lablgtk-react itself
<adrien> and for compiling, it's even more important imho
<kaustuv> In a modern OCaml (3.12+) you can use ocamlbuild -use-ocamlfind
<kaustuv> And then _tags can have: <*.ml> or <*.native>: package(batteries), package(pcre), etc.
<iris1> Thank you! I think I understand about the .ocamlinit.
<iris1> Also, super-helpful suggestions about ocamlfind. I am currently using 3.11.1 and am a bit scared about upgrading to 3.12, but this seems like a really useful new feature.
<iris1> All in all, I am a happy camper now. Dear adrien and kaustuv, thank you very much for your help!!
<adrien> and for syntax extensions: "package(lwt,lwt.syntax), syntax(camlp4o)" for instance
<adrien> there's a myocamlbuild.ml that provides similar functionnality for < 3.12
<adrien> goes like: "pkg_lwt" in the _tags file iirc
<kaustuv> 3.11 to 3.12 is mostly painless. AFAIK there is only one (annoying) regression involving quoting type applications in camlp4
<adrien> an issue with threads in ocamlbuild and ocamlfind support too actually ;-)
<kaustuv> You mean that ocamlbuild -j4 doesn't actually spawn upto 4 simultaneous subprocesses?
coucou747 has joined #ocaml
<adrien> no, the myocamlbuild.ml file supports pkg_thread(s) but there's no way to get that same functionality with 3.12.*0* 's -use-ocamlfind
<kaustuv> Ah, package(threads) doesn't automatically add -thread?
<adrien> nope
RyanRN has quit [Ping timeout: 264 seconds]
<kaustuv> nowadays I am writing a lot of Haskell code and I am continually impressed by how comparatively painless dependency management is
<adrien> don't have much complaints for my part
<kaustuv> well, it's manageable, but not as pleasant as it can be
<adrien> agreed
<kaustuv> thelema: in your new _oasis file, you have your username on github.com hardcoded. Is that necessary?
jlouis has quit [Remote host closed the connection]
<kaustuv> (for batteries, in case it wasn't obvious)
fushunpoon has joined #ocaml
<fushunpoon> hi
<fushunpoon> I've got a question
<fushunpoon> How can I write type annotations for functions as I declare them? e.g.
<fushunpoon> can I say
<fushunpoon> let x = x +1 : int -> int
<fushunpoon> actually, perhaps I should write
<fushunpoon> let x = function y -> y+1 : int -> int
<fushunpoon> or is this practise not encouraged?
<kaustuv> fushunpoon: the standard way is to put the type signatures in a corresponding .mli file.
<kaustuv> However, you can also do:
<kaustuv> let f : a -> b -> c = fun a b c -> whatever
<kaustuv> or rather, let f : a -> b -> c = fun a b -> whatever
<fushunpoon> woe be me! the code i've been given (which I must work with...) has no type annotations of any sort, and definitely no .mli files to speak of :P
<fushunpoon> but thank you kaustuv, I'll try and stick in some quick type annotations in that style I think, it could help me understand the code a bit better...
<kaustuv> it's not the end of the world. You can easily create a .mli with: ocamlc -i foo.ml > foo.mli
<kaustuv> then edit it by hand
<fushunpoon> ahhh..
<fushunpoon> so I see
<fushunpoon> lemme try that. :P
<mrvn> You only need an mli file if you want it to say something different than ocamlc -i does.
edwin has quit [Remote host closed the connection]
<fushunpoon> well, if the standard way of putting in type annotations is in an .mli, then I think an .mli file is very important... especially for other people to use your code!
<mrvn> It is also not standard to give type annotations unless they differ from what inference comes up with.
<fushunpoon> I'm surprised it isn't inlined with the code!
edwin has joined #ocaml
<fushunpoon> is there a reason why Ocamllers don't generally write type annotations though?
<kaustuv> It isn't inlined because OCaml has a much more powerful module language than Haskell/Miranda/etc.
<fushunpoon> mm :/ I haven't quite got around to using modules yet, I must admit
<mrvn> fushunpoon: what for?
<kaustuv> Also, I dispute the claim that ocamlers don't write types. They may write them at a different time from the rest of the code, but a hand crafted and documented .mli is often much more pleasant to read than inlined types and code
<mrvn> fushunpoon: you can display the infered types in your editor.
<fushunpoon> ooh... how do I do that mrvn?
<fushunpoon> because that would be great
<mrvn> depends on your editor.
<fushunpoon> I use vim :/
<fushunpoon> don't hit me :P
<mrvn> Can't help you there. Wait for some vim fanatic to wake up.
<fushunpoon> haha... so there are tools for emacs, or something?
<fushunpoon> I notice, even otags, something that generates tags for ocaml, is out of date :/
<kaustuv> Isn't there an ocaml plugin for vim? It surely has support for .annot files already
<mrvn> kaustuv: I bet there is
<fushunpoon> what are .annot files :s are they different from .mli?
<kaustuv> .annot fiels are produced when compiling with -annot (or -dtypes on older OCamls).
<kaustuv> they contain types and def/use information on a phrase-by-phrase basis so you can query for the type of an arbitrary subexpression
<fushunpoon> again, using ocamlc, is that right
<fushunpoon> ocamlc -annot <filename>.ml ...
<kaustuv> both ocamlc and ocamlopt have -annot
<fushunpoon> right
<fushunpoon> now i've tried to do ocamlc -i <somefile>.ml, but this thing imports Common
<fushunpoon> lemme dig around to make sure that isn't defined aynwhere...
<fushunpoon> when you say "open Something' in a source file, what does that mean?
<kaustuv> something.cmi should be visible to the compiler
<kaustuv> so you have to compile them in dependency order
<fushunpoon> I see :D
Cyanure has quit [Read error: Operation timed out]
<mrvn> "The expression open module-path in a signature does not specify any components. It simply affects the parsing of the following items of the signature, allowing components of the module denoted by module-path to be referred to by their simple names name instead of path accesses module-path . name. The scope of the open stops at the end of the signature expression."
<mrvn> Chapter 6.10.2 in the docs.
<fushunpoon> so it allows you to use definitions of the 'open'ed thing without qualification
<kaustuv> I think your best approach is to edit your build system to add -annot to the OCAMLCFLAGS or whatever, rebuild, then use the ocaml.vim plugin to query for types
<kaustuv> when you can then inline in the .ml or add in a comment before
<kaustuv> since you are only trying to understand someone else's code at the moment
<fushunpoon> cool :D thanks for your help- I'll try do that!
<fushunpoon> thanks mrvn too :)
<mrvn> fushunpoon: He should really have at least a mli file with comments. That is the contract of the module with the outside.
<kaustuv> I think there should be a tutorial on how to do forensic analysis of a random blob of ocaml code as it's a common question around here
<mrvn> kaustuv: well, you did most of the handholding on this one. Now write it up nicely. :)
<fushunpoon> haha... so I wasn't the first! :D
fushunpoon has left #ocaml []
mlh has quit [Ping timeout: 252 seconds]
jlouis has joined #ocaml
lopexx has joined #ocaml
lopexx has quit [Client Quit]
<adrien> I don't understand why C libraries don't have actual, hand-written, and well-maintained description of their interface
<mrvn> They have .h files and some a well commented
lopex has quit [Ping timeout: 252 seconds]
<adrien> forgot to mention "in xml/json/klingon format"
<adrien> cowboy (my project) allows me to get all the infos from .h files easily but it's still quite annoying to have to check things in the various .h files when something goes wrong
fraggle_ has quit [Ping timeout: 276 seconds]
<adrien> (also, glib libraries put their doxygen-like [ gtkdoc ] annotations in .c/.cpp files, but not in .h files ='( )
<mrvn> but then they have docs
fraggle_ has joined #ocaml
bacam_ has joined #ocaml
eelte has joined #ocaml
pheredhel has joined #ocaml
<adrien> at least they have annotations _now_, but it's still not a nice format to work with
pheredhel` has quit [Ping timeout: 250 seconds]
coucou747 has quit [Ping timeout: 250 seconds]
bacam has quit [Ping timeout: 250 seconds]
faanbj has quit [Read error: Connection reset by peer]
patronus_ has quit [Ping timeout: 250 seconds]
tauntaun has joined #ocaml
strlen has quit [Ping timeout: 250 seconds]
strlen has joined #ocaml
patronus has joined #ocaml
<kaustuv> I find doxygen pages essentially unusable.
<adrien> actually, a really though issue is that you don't know where some values come from, there's a lot of guessing involved
<mrvn> good docs are hard to write no matter what format
<kaustuv> For pure C, I generally don't have this issue as etags + M-. is enough for most cases
<mrvn> Is there a ocaml like language without dynamic allocations?
<adrien> mrvn: not for humans: something machine-readable, and properly organized
<mrvn> an ocaml subset that only uses the stack or so?
faanbj has joined #ocaml
<kaustuv> it would be a very impoverished subset
<kaustuv> unless you mean a fixed sized major heap or some such
<mrvn> no, something without GC.
<kaustuv> there is Ur/Web
<kaustuv> but it is only ML-"inspired"
RyanRN has joined #ocaml
lopex has joined #ocaml
lopexx has joined #ocaml
<mrvn> I was thinking of something where you have allocators that reserve some stack space and you pass the allocator to functions that need dynamic space. The lifetime of the return value would then be coupled with the lifetime of the allocator.
<mrvn> and the compiler would check those constraints.
<mrvn> call them stack based mini heaps.
lopex has quit [Ping timeout: 250 seconds]
<kaustuv> that sounds a lot like regions. MLKit is based on region inference -- not sure if it also allows explicit region annotations
<mrvn> will have to look into that then.
<kaustuv> you can disable the gc in mlkit, for example
Edward__ has quit []
edwin has quit [Remote host closed the connection]
bbc has quit [Quit: leaving]
lopexx has quit []
lopex has joined #ocaml
RyanRN has quit [Read error: Connection reset by peer]
RyanRN has joined #ocaml
bacam_ is now known as bacam
RyanRN has quit [Ping timeout: 276 seconds]
RyanRN has joined #ocaml
<oriba> how do I use the tag-handling DTDs in ocamlnet's Nethtml module?
<oriba> I tried around, but could not find out how it works
RyanRN has quit [Client Quit]
<oriba> is this simplified DTD intended to overwrite defaults complete, or tag-wise or what?
RyanRN has joined #ocaml
RyanRN has quit [Client Quit]
fushunpoon has joined #ocaml
<fushunpoon> hey, I'm back.
<fushunpoon> -annot works, but after being generated by ocamlc, ocamlc goes and makes me a binary. what's all that about
<mrvn> you didn't specify -c
<fushunpoon> can I not have ANY output other than the annotation file?! :S
<mrvn> ocamlc generated bytecode, ocamlopt binary
<fushunpoon> I want to stick this into a makefile, see
<fushunpoon> ya, I know that much; but I want neither bytecode nor binary
<mrvn> so? just produce the -annot files as byproduct of compiling the binary
<fushunpoon> yeah... the hacky way is to delete the binary at the end :/
<fushunpoon> the problem here is
<fushunpoon> I have a general rule that makes all .ml files
<fushunpoon> one of which is a yacc- generated parser file
<mrvn> at some point you will want to create a binary.
<fushunpoon> it makes no sense to create an annotation file for the parser, because it takes a good 2 seconds of compile time :p
<fushunpoon> I guess I can't have it all :P
<mrvn> then make a rule for that file that doesn't use -annot
<mrvn> but generally I think the time to write out the -annot during a compile is negible.
<fushunpoon> ... :/ ya. sounds like the best workaround
ulfdoz has quit [Ping timeout: 255 seconds]
lopex has quit []
krktz has left #ocaml []
pozic has quit [Quit: leaving]
Amorphous has quit [Ping timeout: 276 seconds]
<thelema> kaustuv: oops. good ctch
<fushunpoon> hey
<fushunpoon> () : unit is the unital value, and unital type; but is there something like the 'bottom' value?
<fushunpoon> i.e. undefined in haskell
Amorphous has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
<kaustuv> fushunpoon: there is no value in OCaml that inhabits all types.
lopex has joined #ocaml
<kaustuv> but if you don't need a value, you can always use: failwith "undefined"
<kaustuv> if you ever inspect it, you'll get a runtime exception
<thelema> kaustuv: you can't inspect the return value of throwing an exception because there isn't one
sepp2k has quit [Quit: Leaving.]
boscop_ has quit [Ping timeout: 255 seconds]
<oriba> there is ignore.
<oriba> ignore (expression)
<oriba> 'a -> unit
<oriba> which you could vcreate youzrself: let ign x = ();;
<thelema> oriba: kaustuv wants a type where there are no legal values
<oriba> aha
<oriba> hmhh
Yoric has quit [Quit: Yoric]
<thelema> kaustuv: maybe an empty polymorphic type?
<oriba> what is a non-legal value?
<oriba> in a typesystem, where everything must be legal....
<thelema> for example, the unit type has a single allowed value: ()
<oriba> thats legaö
<oriba> leagl
<oriba> legal
<thelema> the 'a type has all allowed values
<kaustuv> It's not me that wants it, it's fushunpoon
<thelema> kaustuv: oops, I misread
saml has joined #ocaml
<kaustuv> he wants something like Haskell's undefined, which doesn't exist in non-pointed type systems like OCaml's
<fushunpoon> oh hullo :d
<oriba> what is it good for?
<fushunpoon> thanks for the answer :D
<oriba> unit and None are good for some things where you need so,mething that is not "something"
<oriba> or for strings it's ""
<oriba> but None makes sense often
<oriba> which means 'a option
<oriba> Some x or None
<kaustuv> That's not what he wants. He wants a *value* that exists at all types.
<oriba> hmhh
<fushunpoon> I think kaustuv has a ... point :P
<kaustuv> Imagine a match case that is impossible. In Haskell you might use undefined for it
<oriba> undefined is not impossible
<oriba> it's "undefined"
<kaustuv> In OCaml the equivalent would be: failwith "unreachable"
<oriba> in C you have NULL, but only for pointers
<fushunpoon> though I don't know what it means to have a pointed type system... (possibly related to the Pointed type class in haskell?) :/
<oriba> so even there it's restricted
<oriba> and "undefined" is a defined feature
<oriba> hence not undefined
<oriba> undefined is defined
<fushunpoon> ya. clearly
<oriba> core dump would be undefined ;)
<fushunpoon> I want THAT. :P
<kaustuv> fushunpoon: sorry, that is a bit jargony. What I mean is that in a lazy language like Haskell there are many values that exist at all types
<oriba> *NULL :)
<kaustuv> These values are basically the unfoldings of the type constructors on undefined arguments. Eg, for [Int] they are: undefined, 1:undefiend,1:2:undefined, etc.
<fushunpoon> kaustuv: right - so the nearest thing would be some sort of lazy thunk in OCaml; though the thunk itself would be typed lazy, so we can't really have 'a
<kaustuv> Right. ML is strict, so laziness is marked in the types
<fushunpoon> oriba: undefined : 'a in haskell, actually
<fushunpoon> if you can give me a thing that is typed with 'a then that's the answer
<oriba> type 'a undefined_t = ???
<fushunpoon> failWith "Something" sounds like what I want
<kaustuv> There are no *values* that meet your requirement. Only computations
<fushunpoon> oh... I guess
<fushunpoon> I could write let x = x in x
<fushunpoon> and call that 'undefined' myself
<fushunpoon> hang on. :/
<kaustuv> well, that particular thing won't work
<fushunpoon> that's not right lol. :
<kaustuv> I'll let you discover why
<fushunpoon> yah well it wouldn't give me an exception, as I would like lol
<fushunpoon> oh... right
<oriba> exception?
<fushunpoon> the whole set of 'exception' functions could do the job
<oriba> you want assert?
<fushunpoon> well...... sorta.
<fushunpoon> failWith "" does it.
<kaustuv> Yes, use any computation. raise works. assert false works.
<fushunpoon> oriba: typical usage of undefined in Haskell is like this:
<fushunpoon> oriba: f n = undefined -- unimplemented!
<kaustuv> let f n = failwith "f unimpliemented"
<fushunpoon> why its it called Pervasives.... :S
<oriba> hmhmh something like that was on the Caml-list some weeks ago
<kaustuv> modulo spelling
<fushunpoon> hehe ;P
Oejet has quit [Quit: Leaving.]
<kaustuv> 'Pervasives' is a better name than 'standard prelude'
<fushunpoon> well, 'base', really. I have no idea where Prelude came from, actually
<fushunpoon> sounds a bit... musical
<kaustuv> it comes from the module named Prelude that is imported by default
<fushunpoon> looking up why they called it that in the first place...
<oriba> I sometimes use exception Not_implemnted of strinjg for such things
<kaustuv> Well, it's a "prelude" to all the definitions that come after
<oriba> of string
dnolen has joined #ocaml
<fushunpoon> kaustuv: my only comeback Pervasives sounding better is that it's a lot more syllables ;P
<kaustuv> where "lot" = 1?
<fushunpoon> indeed =]
<fushunpoon> there's a lot more phonemes to be had too... especially with the 'ives' part
<fushunpoon> one's gotta call their base library something though :P
<fushunpoon> C's one has always confused me... clib... :S
<fushunpoon> indeed! indeed :P
ftrvxmtrx_ has quit [Read error: Operation timed out]
philtor has joined #ocaml
ftrvxmtrx_ has joined #ocaml