Questions tagged [ocaml-batteries]

OCaml Batteries included is a community-driven effort to standardize on a consistent, documented, and comprehensive development platform for the OCaml programming language. Use with [tag:ocaml] and optionally [tag:standard-library] if the question might be related to other standard-libraries, or the concept of standard libraries in general, as well

OCaml Batteries included (or simply "Batteries") is a community-driven effort to standardize on a consistent, documented, and comprehensive development platform for the programming language.

Useful resources

35 questions
2
votes
1 answer

ocaml batteries compiling : Unbound module Toploop

**Build mode: shared ocamlbuild -no-links syntax.otarget byte.otarget src/batteries_help.cmo META shared.otarget Finished, 0 targets (0 cached) in 00:00:00. + ocamlfind ocamlc -c -g -annot -warn-error A -package camomile,num,str -package…
Canoe
  • 347
  • 1
  • 3
  • 11
2
votes
1 answer

OCaml toplevel not interpreting comments

$ ocaml Objective Caml version 3.12.1 _________________________ [| + | | Batteries - | |_____|_|_________________| _________________________ | - Type '#help;;' | | + |] |___________________|_|___| Loading syntax…
Animesh
  • 4,926
  • 14
  • 68
  • 110
1
vote
2 answers

Use of "%identity" in mutable accumulator

To enable tail recursion, the ocaml batteries library uses a mutable accumulator in the list module: type 'a mut_list = { hd: 'a; mutable tl: 'a list } external inj : 'a mut_list -> 'a list = "%identity" module Acc = struct let dummy () = …
mushroom
  • 6,201
  • 5
  • 36
  • 63
1
vote
2 answers

Building standalone OCaml program

I'm getting crazy while trying to understand how to produce a binary in OCaml that doesn't need anything too specific (eg. having anything as OCaml build tools installed). I'm using OMake and everything seems enough cool while working on my machine,…
Jack
  • 131,802
  • 30
  • 241
  • 343
1
vote
2 answers

Lazy list of x, f x, f (f x),

Batteries.LazyList allows one to define lazy lists. I would like to define a lazy list consisting of x, f x, f (f x), f (f (f x)), etc. Based on comments in the module documentation, it appears that from_loop is the function I want: "from_loop…
Mars
  • 8,689
  • 2
  • 42
  • 70
1
vote
1 answer

Building OCaml code that uses list comprehension

From this SO question: List Comprehension in Ocaml?, I could install the comprehension package with opam install pa_comprehension, and use the package in toplevel REPL. # #require "pa_comprehension";; # open Batteries;; # [? 2 * x | x <- 0 --…
prosseek
  • 182,215
  • 215
  • 566
  • 871
1
vote
1 answer

How to use deriving and batteries at same time in OCaml?

So basically in my project I need to use batteries (for File.lines_of and other related functions) and deriving (for Show.show) at the same time. However, when I use opam to install package deriving on my Mac, it seems that it will firstly remove…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
1
vote
1 answer

integer range error in OCaml

Recently I have to read some source code written in OCaml. And I start to read the source code after reading materials about OCaml. When I compile the source code, there's something wrong. The part which the compiler says wrong is below: let b = [|…
KUN
  • 527
  • 4
  • 18
1
vote
1 answer

Can't load batteries using FindLib in Ocaml TopLevel

I successfully installed ocaml-batteries-included and findlib. I can do 'ocamlfind ocamlc -package batteries -c mycode.ml` without problems. Also, if I do ocamlfind list, I get $ ocamlfind list batteries (version:…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
1
vote
1 answer

ocaml batteries installation

There seems to be conflicting information about batteries installation. I have tried several suggestions, but none have worked for me. I first tried ocamlfind batteries/ocaml but that gave this error: ocamlfind: Cannot find command:…
0
votes
1 answer

Syntax error when using batteries in Utop

I've successfully installed Batteries and can get it work...somewhat. Any ideas why I'm getting the syntax error since Opam list this: depends: "ocaml" {>= "4.00.0" & < "4.10.0"} And, I'm at: The OCaml toplevel, version 4.07.1
0
votes
1 answer

int function error in lazy fold_right definition

I'm trying to write a modified version of Batteries.LazyList.lazy_fold_right. I want a similar function that folds on two lazy lists rather than one lazy list. However, I'm getting an error that doesn't make any sense to me. Here is the original…
Mars
  • 8,689
  • 2
  • 42
  • 70
0
votes
1 answer

ocaml batteries unbound toploop error

I am trying to install bap required for ropc https://github.com/pakt/ropc as per the instructions given in ropc/bap/INSTALL in Ubuntu 14.04 . I have run these commands successfully . sudo apt-get install ocaml ocaml-native-compilers ocaml-findlib…
G Ashwin
  • 23
  • 1
  • 6
0
votes
1 answer

Binary search inside sorted array in OCaml

let find arr word = let rec binaryserach arr word min max = let mid = (min + max) / 2 in if max < min then -1 else if (String.compare arr.(mid) word = 0) then mid else if (String.compare arr.(mid) word = 1) then (binaryserach…
sudheesh ks
  • 351
  • 1
  • 8
  • 15
0
votes
1 answer

Loading a batteries dependent file into ocamltop -- the interfaces disagree

Here is a simple ocaml file, just meant to get me to understand how to load a program that uses the Batteries library into the ocamltop. batteryassault.ml open Batteries let main = print_string "hello, world ... powered on" I compile this to…
Jonathan Gallagher
  • 2,115
  • 2
  • 17
  • 31