Recently I decided to learn the basics of OCaml and I spent yesterday installing the compiler and some basic tools. On my machine at work I have a Debian 7 installation, while on my home laptop I have openSUSE 11.4. Both systems are quite dated and ship with OCaml 3.x compiler, which is five years old. Obviously, I wanted to have the latest version of the language. I could have compiled OCaml from sources – and in fact I have done that in the past to compile the latest version of Coq – but luckily there is a tool called OPAM (OCaml Package manager). OPAM can be used to easily download and install desired version of OCaml compiler. As the name implies, OPAM can be also used for managing packages installed for a particular compiler version.
The installation process went very smooth on my Debian machine, but on openSUSE I have run into problems. After getting the latest compiler I wanted to install ocamlfind, a tool required by a project I wanted to play with. To my disappointment installation ended with an error:[ERROR] The compilation of conf-ncurses failed at "pkg-config ncurses". This package relies on external (system) dependencies that may be missing. `opam depext conf-ncurses.1' may help you find the correct installation for your system.
I verified that I indeed have installed development files for the ncurses library as well as the pkg-config tool. Running the suggested opam command also didn’t find any missing dependencies, and the log files from the installation turned out to be completely empty, so I was left clueless. Googling revealed that I am not the first to encounter this problem, but offered no solution. I did some more reading on pkg-config and learned that: a) it is a tool that provides meta-information about installed libraries, and b) in order to recognize that a library is installed it requires extra configuration files (aka *.pc files) provided by the library. Running pkg-config --list-all revealed that ncurses is not recognized as installed on my system, which suggested that the relevant *.pc files are missing. Some more googling revealed that ncurses library can be configured and then compiled with --enable-pc-files switch, which should build the files needed by pkg-config. I got the sources for the ncurses version installed on my system (5.7) only to learn that this build option is unsupported. This explains why the files are missing on my system. I got the sources for the latest version of ncurses (6.0), configured them with --enable-pc-files and compiled, only to learn that the *.pc files were not built. After several minutes of debugging I realized that for some unexplained reasons the configure-generated script which should build the *.pc files (located at misc/gen-pkgconfig) did not receive +x (executable) permission. After adding this permission manually I ran the script and got five *.pc files for the ncurses 6.0 library. Then I had to edit the files to match the version of ncurses of my system – relevant information can be obtained by running ncurses5-config --version. The only remaining thing was to place the five *.pc files in a place where pkg-config can find them. On openSUSE this was /usr/local/pkgconfig, but this can differ between various Linux flavours.
After all these magical incantations the installation of ocamlfind went through fine and I can enjoy a working OCaml installation on both of my machines. Now I’m waiting for the “Real-world OCaml” book ordered from Amazon (orders shipped from UK Amazon to Poland tend to take around two weeks to arrive).
A colleague characterised her talk as "full of anti-Semitic and aggressive material from sources in the Middle East". I watched the video, and heard nothing anti-Semitic. It is a word that should be used with care.
Speaker's Trust has released a statement regarding the matter:
“There are two fundamental rules that are made explicit during the training: the speech must have a positive and uplifting message – in fact this is one of the core terms of the agreement with the Jack Petchey Foundation [and] a speaker should never inflame or offend the audience or insult others and this, by definition, means that propaganda is ruled out absolutely from the outset… Speakers Trust and Jack Petchey Foundation judging panel decided unanimously against sending Leanne Mohamad through to the next stage and she will not be speaking at the Grand Final. These were precisely our concerns.”And another:
Our primary duty of care is to the young people we work with and we cannot tolerate any form of insult or abuse. We are concerned and saddened that Leanne’s experience has been less than positive.
Leanne Mohamad is the Redbridge Regional Final winner and there has never been any suggestion that she should be disqualified. Almost 190,000 young people have spoken out over the years on any topic which they feel passionately about and none has ever been banned from the process or silenced.
We are, however, a small charity without the capacity to moderate comments 24 hours a day and it was considered essential to protect Leanne by temporarily suspending the regional video over the bank holiday, until we were able to consult with her school and family.
Of 37 talented regional Champions only fifteen can be voted through to the Grand Final. This selection process took place on Saturday 21st May based on standard judging criteria and without any external influence or input.
The general “rules” of effective public speaking are guidelines to help speakers to create a speech that will connect with a large and diverse audience and every speech was judged on its own merits. At the heart of what we do lies the determination that all of our young speakers, irrespective of background, race or creed, should be able to speak out in a safe and supportive environment.
Despite having lived in Israel for 22 years with no criminal record of any kind, Omar Barghouti (above) was this week denied the right to travel outside the country. As one of the pioneers of the increasingly powerful movement to impose boycotts, sanctions, and divestment measures (BDS) on Israel, Barghouti, an articulate, English-speaking activist, has frequently traveled around the world advocating his position. The Israeli government’s refusal to allow him to travel is obviously intended to suppress his speech and activism. Prime Minister Benjamin Netanyahu was one of the world leaders who traveled last year to Paris to participate in that city’s “free speech rally.” ...
Sarah Leah Whitson of Human Rights Watch told the Electronic Intifada that “Israel’s refusal to renew Barghouti’s travel document appears to be an effort to punish him for exercising his right to engage in peaceful, political activism, using its arsenal of bureaucratic control over Palestinian lives.” She added: “Israel has used this sort of control to arbitrarily ban many Palestinians from traveling, as well as to ban international human rights monitors, journalists, and activists from entering Israel and the occupied Palestinian territories.” ...
Barghouti: Many people are realizing that Israel is a regime of occupation, settler colonialism, and apartheid and are therefore taking action to hold it to account to international law. Israel is realizing that companies are abandoning their projects in Israel that violate international law, pension funds are doing the same, major artists are refusing to play Tel Aviv, as Sun City was boycotted during apartheid South Africa. ...
We live in a country where racism and racial incitement against indigenous Palestinians has grown tremendously into the Israeli mainstream. It has really become mainstream today to be very openly racist against Palestinians. Many settlers and hard-right-wing Israelis are taking matters into their own hands – completely supported by the state – and attacking Palestinians.
Officially, HSOC projects start from the 13th June. This provides time to do some research. Today I decided to take a look at Blockly.
Following the advice on the README I created a new codeworld Linux user account and went on to set up CodeWorld. The current build script for CodeWorld covers the zypper, apt-get and yum package managers. Running Arch I’ve got pacman. I already had most the required packages (git, zlib, ncurses, gcc, gmp, patch, autoconf, automake, openssl).
What I was missing waspacman -S npm nodejs
I also had GHC 7.10.3 and cabal already installed.
Installing GHCJS:git clone https://github.com/ghcjs/ghcjs.git cabal install ./ghcjs ghcjs-boot
and also ghcjs-domcabal install ghcjs-dom
I don’t have the cabal bin in my PATH so I needed:export PATH=/home/codeworld/.cabal/bin:$PATH
before running the standard CodeWorld build script. After running build.sh, run.sh started up the web server. Everything ran fine, minus saving projects, which I did not set up.GHCJS
I wanted to play around with GHCJS as well, having never used it before. Documentation was rather scarce but I managed to put together a simple hello world application; with a compiled js file of about 43KLOC.
A lot of the sample programs found were using an old version of GHCJS-DOM. I will return to GHCJS when I start programming on the project.Testing, testing
My goal today was to quickly set a simple page containing Blockly and a CodeWorld application as a simple test.
I created a simple HTML file with Bootstrap for minimal styling, added Blockly and an iframe for running a standard CodeWorld application.
Setting up the example Snap site comprises of:module Main where import Control.Applicative import Snap.Core import Snap.Http.Server import Snap.Util.FileServe import Snap.Util.FileUploads import System.Directory import System.FilePath main :: IO () main = quickHttpServe site site :: Snap () site = ifTop (writeBS "hello world") <|> route [ ("foo", writeBS "bar") ,("echo/:echoparam", echoHandler) ] <|> serveDirectory "web" echoHandler :: Snap () echoHandler = do param <- getParam "echoparam" maybe (writeBS "must specify echoparam in URL") writeBS param
With the server looking for a page to serve from “web” if it does not match any of the routes.
I originally wanted to send a code sample from the FunBlocks page to the locally hosted CodeWorld server with a XMLHttpRequest, however, this I could not do as the FunBlocks site and CodeWorld server were on different ports, thus I ended up receivingXMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access
as an error.
Not wanting to mess around with headers I decided to just copy over the codeworld-server files and serve the same resources, with the new index page as an addition.
I actually only wanted the compile and run features for this simple test. So currently the server is exactly the same as the codeworld-server with a modified codeworld.js and custom index. This makes things easy as FunBlocks can be hosted together with CodeWorld later, just on a different page. I would enjoy having a solid implementation for the language.
Any thoughts on a good approach to take with this are welcome.Type checking and an intermediate form.
The flow of the language will be something similar to:
Blocks -> Intermediate code representation -> CodeGen
The intermediate code representation should cover a basic set of features of Haskell, enough to be able to generate valid CodeWorld applications. User friendliness is also a concern, since the project is educationally focussed.
Blocks should snap properly and maybe display suitable error messages otherwise. For this to occur however, some form of type checking will have to be implemented.
I gathered some resources which I will look at later:
- Typing Haskell in Haskell - Haskell type checking
- Hint - Type-check and evaluate strings with Haskell expressions and even coerce them into values.
- Programming languages - covers Racket, contains a chapter on type checking
- The Implementation of Functional Programming Languages - Contains a chapter on Polymorphic type checking
- Baskell - A small functional language featuring type inference.
The easiest might be to rely on Hint to type check Haskell expressions and do some backtracing, this avoids having to implement type inference. Though if time allows I might be tempted to do a proper implementation.
Most CodeWorld functions are monomorphic and have concrete types, with some exceptions (simulations). So some part of CodeWorld can be implemented without worrying too much about type checking, however, I would enjoy having a solid implementation for the language.
Any thoughts on a good approach to take with this are welcome.