[Caml-list] Ques from a beginner: how to access a type defined in one .ml file in another .ml file
Hi, I m very new to ocaml and I am not sure if this the right forum to ask a beginner level question. I have tried reading tutorials and the manual but no help. Please help me on the problem below, In a.ml a record type t is defined and is also defined transparently in a.mli, i.e. in d interface so that the type definition is available to all other files. a.ml also has a function, func, which returns a list of t. Now in another file, b.ml i m calling func, now obviously ocaml compiler wud nt be able to infer d type of objects stored in d list, for compiler its just a list. so in b.ml, i hav something like dis, let tlist = A.func in let vart = List.hd tlist in printf %s\n vart.name (*name is a field in record t*) Now here i get a compiler error sayin Unbound record field label name which makes sense as compiler can't infer d type of vart. my first question: how do I explicitly provide d type of vart as t here? i tried doing let vart:A.t = but got the same error. I also tried creating another function to fetch the first element of d list and mentioning return type as A.t, but then i got the Unbound value A.t. I did this: let firstt = function [] - 0 | x :: _ - A.t x ;; The problem is compiler is unable to recognize A.t (a type) in b.ml but is able to recognize function A.func. If I remove A.t from the b.ml, i don'get any compiler errors. Please help, its urgent work. Thanks in advance! ~Tarun ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Ques from a beginner: how to access a type defined in one .ml file in another .ml file
On Wed, May 12, 2010 at 12:30 PM, Tarun Sethi tarunseth...@gmail.com wrote: Hi, I m very new to ocaml and I am not sure if this the right forum to ask a beginner level question. I have tried reading tutorials and the manual but no help. Please help me on the problem below, In a.ml a record type t is defined and is also defined transparently in a.mli, i.e. in d interface so that the type definition is available to all other files. a.ml also has a function, func, which returns a list of t. Now in another file, b.ml i m calling func, now obviously ocaml compiler wud nt be able to infer d type of objects stored in d list, for compiler its just a list. so in b.ml, i hav something like dis, let tlist = A.func in let vart = List.hd tlist in printf %s\n vart.name (*name is a field in record t*) Now here i get a compiler error sayin Unbound record field label name which makes sense as compiler can't infer d type of vart. my first question: how do I explicitly provide d type of vart as t here? i tried doing let vart:A.t = but got the same error. I also tried creating another function to fetch the first element of d list and mentioning return type as A.t, but then i got the Unbound value A.t. I did this: let firstt = function [] - 0 | x :: _ - A.t x ;; The problem is compiler is unable to recognize A.t (a type) in b.ml but is able to recognize function A.func. If I remove A.t from the b.ml, i don'get any compiler errors. Please help, its urgent work. Thanks in advance! ~Tarun I guess this is not the right place to ask such a question... There is a beginners' list. However, this should answer your question : write instead : variable_name.Module_name.field_name If variable_name has been defined in yet another module, you may write YetAnotherModule.variable_name.Module_name.field_name If you want to avoid module name prefixes, you may want to use open : open Module_name;; let foo = variable_namefield_name ;; However (from my personal point of view) open should be avoided because it often makes maintenance very tough. About type constraints, the syntax is rather this : (variable : type_name) with parentheses most of the time. -- Philippe Wang m...@philippewang.info ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] [ANN] Camomile 0.7.3
I'm pleased to announce Camomile 0.7.3, a new version of Camomile, a comprehensive Unicode library for OCaml. This is a bug fix release. It fixes the following bugs and Camomile now works on Windows. - Aliases of character encodings containing : are removed, to support Windows platform. - Buffering bugs in CharEncoding and OOChannel modules. - Tree-merging bugs of ISet and IMap. - Locale data are properly loaded by binary channels. (Windows related) - make depend properly generates .depend file. - cpp is no longer required to build from the distribution. The license documentation for locales/*.txt files is added. (locales/license.html) The package is tested on Windows (MinGW-port of OCaml 3.11.0 + Cygwin on Vista SP1) and Linux (Ubuntu 8.04 + godi version of OCaml 3.11.2). You can download the package from https://sourceforge.net/projects/camomile/ For more information on Camomile, see the project web page http://camomile.sourceforge.net/. I would appreciate your comments or/and opinions. In particular, I'd like to know whether you can successfully operate Camomile in your platform. I have complaints on Mac and MinGW environments, and although I believe that the problems are fixed, I'm too lazy to find spare Mac around and test the package :-) Also, I would like to hear about a success ( /failure ) story of Camomile. Do you use Camomile? What for? This is important since I have to convince my boss to allow me to invest some spare time to Camomile project. Regards, -- Yoriyuki Yamagata yoriyuk...@gmail.com ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
RE: [Caml-list] about OcamIL
Ben Kuin wrote: A little off topic, but how is Mono/Unix these days? Still leaks memory, you refer to your examinations? (http://flyingfrogblog.blogspot.com/2009/01/mono-22-still-leaks- memory.html?showComment=1233522107493#c7872630239059031867) where you say yes and the mono devs are say no to memory leaking? Yes. has broken TCO Again, I think other people do not have the same opion on this ( http://flyingfrogblog.blogspot.com/2009/01/mono-does-not-support-tail- calls.html) Yes. They are wrong. I've introduced the post with some license related concerns, maybe I should take a step back and think about what I want: 1. - programming in a ML like language ( especially the caml family since I really like those lightweigt type definitions and the pattern matching that can be applied on those) 2. - high performance runtime, preferably a jit based vm, no problems with TCO 3. - a true open source license (approved by Open Source Initiative or by Free Software Foundation) I think this 3 point are REASONABLE but the combination of those 3 items is INEXISTENT. I'm afraid the situation is far worse. Even if you relax your conditions from ML-like to any functional language and even allow broken TCO, there are not only no language implementations satisfying those weaker conditions but nobody is even trying to create such a language implementation. Ocaml on HLVM: I would appreciate if Jon could make a clear statement if this is something serious or just a little toy. HLVM is not yet ready for serious use and it may well never compile OCaml but at least it is now compiling code like this: http://flyingfrogblog.blogspot.com/2010/04/variant-types-and-pattern-matchin g-in.html A last idea: What do you think about libjit? They claim that a jvm/clr like runtime could be built in weeks. Wouldn't it be nice to have a fast vm for Ocaml (ocamljit) ? Does someone has experience with this, I think writing a fast vm is hard, but a fast vm for a functional language is nearly impossible? Maybe OcamIL could then be used as a model for a jit backend, since its MSIL output already runs on libjit (DotGnu, alias pnet) I think LLVM is a much better choice than libjit. Once you've got that kind of solid foundation to build upon and a decent language like OCaml to write in, you can write a decent FPL implementation in a few man-months. The problem is finding the time... Cheers, Jon. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
RE: [Caml-list] about OcamIL
Jon Harrop jonathandeanhar...@googlemail.com a écrit : Ben Kuin wrote: I've introduced the post with some license related concerns, maybe I should take a step back and think about what I want: 1. - programming in a ML like language ( especially the caml family since I really like those lightweigt type definitions and the pattern matching that can be applied on those) 2. - high performance runtime, preferably a jit based vm, no problems with TCO 3. - a true open source license (approved by Open Source Initiative or by Free Software Foundation) I think this 3 point are REASONABLE but the combination of those 3 items is INEXISTENT. I'm afraid the situation is far worse. Even if you relax your conditions from ML-like to any functional language and even allow broken TCO, there are not only no language implementations satisfying those weaker conditions but nobody is even trying to create such a language implementation. Putting aside an answer I posted this morning on a parallel thread, I will just present some counter examples to this claim. Limiting myself to the JVM, and not even trying to be exhaustive, I can find... ... in the LISP family : - Clojure - http://clojure.org/ - Eclipse Public License ... in the Scheme family : - Bigloo - http://www-sop.inria.fr/indes/fp/Bigloo/ - GPL / LGPL - Kawa - http://www.gnu.org/software/kawa/ - X11 / MIT license - SISC - http://sisc-scheme.org/ - GPL ... in the ML family: - Yeti - http://mth.github.com/yeti/ ... in the Haskell family: - CAL - http://openquark.org/Open_Quark/Welcome.html - BSD-like license ... in its own family: - Scala - http://www.scala-lang.org Moreover, at least Scala and Bigloo deliver excellent performances. Regards, Xavier Clerc ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] [ANN] Camomile 0.7.3
Hi ! Le mercredi 12 mai 2010 07:13:17, Yoriyuki Yamagata a écrit : Also, I would like to hear about a success ( /failure ) story of Camomile. Do you use Camomile? What for? This is important since I have to convince my boss to allow me to invest some spare time to Camomile project. Thanks for your work in camomile ! We have been using and enjoying it with liquidsoap [1] for probably almost 3 years now. We are using camomile to convert implicitely the various metadata tags into unicode. I am personally impressed by how good the module works. As far as I can tell we have had no issues with character encoding since we are using camomile ! Romain [1]: http://savonet.sf.net/ ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] [ANN] Camomile 0.7.3
Hi ! Le mercredi 12 mai 2010 07:13:17, Yoriyuki Yamagata a écrit : Also, I would like to hear about a success ( /failure ) story of Camomile. Do you use Camomile? What for? This is important since I have to convince my boss to allow me to invest some spare time to Camomile project. Thanks for your work in camomile ! We have been using and enjoying it with liquidsoap [1] for probably almost 3 years now. We are using camomile to convert implicitely the various metadata tags into unicode. I am personally impressed by how good the module works. As far as I can tell we have had no issues with character encoding since we are using camomile ! Romain [1]: http://savonet.sf.net/ ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] OCaml S3 Library?
Has anyone written a library to interact with amazon web services (specifically, S3)? I started writing one, but something about the authentication is not working properly, and I thought I'd check to see if anyone had already done this before I try to figure out what is going wrong. Sample code follows, as if there does not already exist a library, I'd be curious if anyone else sees what is wrong with the authentication signature (what I assume is not working), as now it 403's every time. open Netencoding.Base64 open Cryptokit open Cryptokit.MAC open Http_client let id = ___PUT_YOUR_ID_HERE let key = __PUT_YOUR_SECRET_KEY_HERE let sign verb content_type date bucket url = let hash = hmac_sha1 key in let str_to_sign = verb ^ \n\n ^ content_type ^ \n ^ date ^ \n ^ / ^ bucket ^ url in begin Printf.printf -\n%s\n-\n str_to_sign; AWS ^ id ^ : ^ encode (hash_string hash str_to_sign) end let date () = Netdate.mk_mail_date (Unix.time ()) let text_put_s3 bucket url contents = let uri = http://; ^ bucket ^ .s3.amazonaws.com ^ url in let req = new put uri contents in let head = req#request_header `Base in let content_type = text/plain in let now = date () in let pipeline = new pipeline in begin pipeline#set_options {pipeline#get_options with verbose_status=true; verbose_request_header=true; verbose_response_header=true; verbose_request_contents=true; verbose_response_contents=true; verbose_connection=true}; head#set_fields [(Date, now); (Content-Type, content_type); (Authentication, sign PUT content_type now bucket url)]; req#set_request_header head; pipeline#add req; pipeline#run (); (req#response_status_code, req#response_status_text) end let _ = text_put_s3 __BUCKET_NAME__ /test This is a Test. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Re: [ANN] Camomile 0.7.3
2010/5/13 Sylvain Le Gall sylv...@le-gall.net ps: as asked on the BTS, a way to be able to relocate the .mar file would be something great -- this actually prevents me to distribute my projects built with camomile. (relocate - remove the hardcoded path) Hmm... you should be able to relocate .mar file by providing the location of .mar files through the functor CamomileLibrary.Main.Make. If you do not link CamomileLibrary.Default, Camomile won't load the data from the hardcoded path. If it does, then I regards it as a bug. -- Yoriyuki Yamagata yoriyuk...@gmail.com ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs