How to fix the Unbound module Graphics in an ocaml project

Image
From ~/pr/gitl/ocaml-gol In a constant effort to learn new programming languages, I'm currently trying to use ocaml , a free and open-source general-purpose, multi-paradigm programming language maintained at the Inria . It's basically an extension of Caml with object-oriented features. I'm mostly interested by its functionnal and pattern matching features but the module part of the language can be a bit difficult to understand for someone with little to none ML (Meta Language) background.   The error When trying to use the graphics module to create a graphical window and go just a little further than the simplest helloworld program, here is the result : If the project uses dune : (executable (name ocaml_project) (libraries lwt.unix graphics) ) with this code : let () = Printf.printf "Hello, world!\n";; Lwt_io.printf "Hello, world!\n";; Graphics.open_graph " 800x600";; The first times I built this project running the du

How to use syntax highlighting with Blogger

Here is a development-themed blog, so I need a way to show you code fragments. The solution I would to test is code-prettify.

Before you modify the blogger's template, go to the template tab and download a complete backup of the current one. Modify the HTML code and add this line just before the </head> tag.

You have to choose options before inserting loader code, because you'll have to change the URL. The base URL is https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js then, if you want to change the skin you have tp append ?skin=sons-of-obsidian to the URL. Please read official documentation for more informations and examples.



<script src='<final URL with options>'></script>

Now, for each code sample you want to add, you need to add the following HTML code and to escape HTML characters (this online tool can help you)  :

<pre  class='prettyprint'>
  Your code here
</pre>

You can also choose to add line numbers and this highlighter supports many programming languages. As a complete example, here is some C++ code from the RainbruRPG's logger:

#include <string>

struct LogHeader
  {
    string program_name;    //!< The program's name
    string program_version; //!< The program's version
    std::string compil_date;     //!< The compilation date
    std::string compil_time;     //!< The compilation time
    std::string exec_date;       //!< The execution date
    std::string exec_time;       //!< The execution time
  };

class LoggerOutput
  {
  public:
    /// Opens the logger, for example open the stream or the file
    virtual void open()=0;  
    /// Closes the logger
    virtual void close()=0;
    
    /** Start to log a line
      *
      * \param vLoglevel  The logging level of the line
      * \param vLogdomain The log domain
      * \param vFilename  The source filename
      * \param vLine      The source line number
      *
      */
    virtual void startLog(LogLevel vLoglevel,
                          const std::string& vLogdomain, 
            const std::string& vFilename, 
                          const std::string& vLine)=0;
 
  ...

You now have a great syntax highlighter.

Comments

Popular posts from this blog

How to make a map of variant in C++