OCaml, Batteries Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures OCaml, Batteries Included I/O From Channels to I/O Composability OCaml Meeting 2009 Extensibility Text 1 2 From string to. . . David Teller , Edgar Friendly, Stefano Zacchiroli , Gabriel Features Scherer, Jérémie Dimino . . . Conclusion

1LIFO, Université d'Orléans ⇒ MLState

2PPS, Université Paris 7

February 4th, 2009 OCaml, Batteries Before we start Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion OCaml, Batteries Included

David Teller et al. Introduction Introduction Manipulating data From loops to enumerations Other data structures Manipulating data I/O From Channels to I/O From loops to enumerations Composability Other data structures Extensibility Text From string to. . . Features Conclusion I/O From Channels to I/O Composability Extensibility

Text From string to. . . Features

Conclusion OCaml, Batteries What makes a good language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Safety Text From string to. . . Expressivity Features Conclusion Composability Syntax Simplicity Fun factor OCaml, Batteries What makes a good language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability √ Extensibility Safety OCaml Text From string to. . . Expressivity Features Conclusion Composability Syntax Simplicity Fun factor OCaml, Batteries What makes a good language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability √ Extensibility Safety OCaml Text √ From string to. . . Expressivity OCaml Features Conclusion Composability Syntax Simplicity Fun factor OCaml, Batteries What makes a good language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability √ Extensibility Safety OCaml Text √ From string to. . . Expressivity OCaml Features √ Conclusion Composability OCaml Syntax Simplicity Fun factor OCaml, Batteries What makes a good language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability √ Extensibility Safety OCaml Text √ From string to. . . Expressivity OCaml Features √ Conclusion Composability OCaml √ Syntax OCaml Simplicity Fun factor OCaml, Batteries What makes a good language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability √ Extensibility Safety OCaml Text √ From string to. . . Expressivity OCaml Features √ Conclusion Composability OCaml √ Syntax OCaml √ Simplicity OCaml Fun factor OCaml, Batteries What makes a good language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability √ Extensibility Safety OCaml Text √ From string to. . . Expressivity OCaml Features √ Conclusion Composability OCaml √ Syntax OCaml √ Simplicity OCaml √ Fun factor OCaml Safe Expressive Composable Syntax Fun ok ugly bad ugly ugly ok bad →ok ok bad ok bad bad bad ugly ugly bad ok good good good bad bad →ok ok bad good

Good < Popular OCaml ∈/ Popular (yet)

OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Extensibility Text Java From string to. . . C# Features Conclusion VB Python JS Expressive Composable Syntax Fun ugly bad ugly ugly bad →ok ok bad ok bad bad ugly ugly ok good good good bad →ok ok bad good

Good < Popular OCaml ∈/ Popular (yet)

OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Safe Extensibility Text Java ok From string to. . . C# ok Features Conclusion VB bad Python bad JS bad Composable Syntax Fun bad ugly ugly ok bad ok bad ugly ugly good good good ok bad good

Good < Popular OCaml ∈/ Popular (yet)

OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Safe Expressive Extensibility Text Java ok ugly From string to. . . C# ok bad ok Features → Conclusion VB bad bad Python bad ok JS bad bad →ok Syntax Fun ugly ugly bad ok ugly ugly good good bad good

Good < Popular OCaml ∈/ Popular (yet)

OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Safe Expressive Composable Extensibility Text Java ok ugly bad From string to. . . C# ok bad ok ok Features → Conclusion VB bad bad bad Python bad ok good JS bad bad →ok ok Fun ugly ok ugly good good

Good < Popular OCaml ∈/ Popular (yet)

OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Safe Expressive Composable Syntax Extensibility Text Java ok ugly bad ugly From string to. . . C# ok bad ok ok bad Features → Conclusion VB bad bad bad ugly Python bad ok good good JS bad bad →ok ok bad Good < Popular OCaml ∈/ Popular (yet)

OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Safe Expressive Composable Syntax Fun Extensibility Text Java ok ugly bad ugly ugly From string to. . . C# ok bad ok ok bad ok Features → Conclusion VB bad bad bad ugly ugly Python bad ok good good good JS bad bad →ok ok bad good OCaml ∈/ Popular (yet)

OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Safe Expressive Composable Syntax Fun Extensibility Text Java ok ugly bad ugly ugly From string to. . . C# ok bad ok ok bad ok Features → Conclusion VB bad bad bad ugly ugly Python bad ok good good good JS bad bad →ok ok bad good

Good < Popular OCaml, Batteries Popular languages Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O What about: Composability Safe Expressive Composable Syntax Fun Extensibility Text Java ok ugly bad ugly ugly From string to. . . C# ok bad ok ok bad ok Features → Conclusion VB bad bad bad ugly ugly Python bad ok good good good JS bad bad →ok ok bad good

Good < Popular OCaml ∈/ Popular (yet) Consistent/composable library (only one string type, only one iteration type, only one exception hierarchy. . . ) Extensibility (new kinds of streams may be created, virtual le system. . . ) Tutorials (which should be trivial to nd) either Fun factor or Public relations (either a company or open-source buzz)

OCaml, Batteries What makes a successful language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Maybe something like: I/O From Channels to I/O Well-suited library (sometimes the only available library) Composability Extensibility Text From string to. . . Features Conclusion either Fun factor or Public relations (either a company or open-source buzz)

OCaml, Batteries What makes a successful language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Maybe something like: I/O From Channels to I/O Well-suited library (sometimes the only available library) Composability Extensibility Consistent/composable library (only one string type, only one Text From string to. . . iteration type, only one exception hierarchy. . . ) Features Conclusion Extensibility (new kinds of streams may be created, virtual le system. . . ) Tutorials (which should be trivial to nd) OCaml, Batteries What makes a successful language? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Maybe something like: I/O From Channels to I/O Well-suited library (sometimes the only available library) Composability Extensibility Consistent/composable library (only one string type, only one Text From string to. . . iteration type, only one exception hierarchy. . . ) Features Conclusion Extensibility (new kinds of streams may be created, virtual le system. . . ) Tutorials (which should be trivial to nd) either Fun factor or Public relations (either a company or open-source buzz) Well-suited library Low-level library in a high-level language. Minimal library sucient for testing, not necessarily for development. Consistent/composable library How do I convert a stream to a list? How do I map a stream or an I/O or a hashtable? How should I represent Unicode strings? Extensibility Camlp4/Camlp5 ok. But how do I add new kinds of I/O? How do I create new streams? Tutorials Whole-language tutorials ok. Task-specic languages not so ok. Plus newbies need to nd them. Fun factor Oh, yeah. Despite competition with Haskell. Public relations Insucient. Despite competition with Haskell.

OCaml, Batteries And in OCaml? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion Consistent/composable library How do I convert a stream to a list? How do I map a stream or an I/O or a hashtable? How should I represent Unicode strings? Extensibility Camlp4/Camlp5 ok. But how do I add new kinds of I/O? How do I create new streams? Tutorials Whole-language tutorials ok. Task-specic languages not so ok. Plus newbies need to nd them. Fun factor Oh, yeah. Despite competition with Haskell. Public relations Insucient. Despite competition with Haskell.

OCaml, Batteries And in OCaml? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Well-suited library Low-level library in a high-level language. I/O From Channels to I/O Minimal library sucient for testing, not necessarily for Composability development. Extensibility Text From string to. . . Features Conclusion Extensibility Camlp4/Camlp5 ok. But how do I add new kinds of I/O? How do I create new streams? Tutorials Whole-language tutorials ok. Task-specic languages not so ok. Plus newbies need to nd them. Fun factor Oh, yeah. Despite competition with Haskell. Public relations Insucient. Despite competition with Haskell.

OCaml, Batteries And in OCaml? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Well-suited library Low-level library in a high-level language. I/O From Channels to I/O Minimal library sucient for testing, not necessarily for Composability development. Extensibility Text From string to. . . Consistent/composable library How do I convert a stream to a Features list? How do I map a stream or an I/O or a hashtable? Conclusion How should I represent Unicode strings? Tutorials Whole-language tutorials ok. Task-specic languages not so ok. Plus newbies need to nd them. Fun factor Oh, yeah. Despite competition with Haskell. Public relations Insucient. Despite competition with Haskell.

OCaml, Batteries And in OCaml? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Well-suited library Low-level library in a high-level language. I/O From Channels to I/O Minimal library sucient for testing, not necessarily for Composability development. Extensibility Text From string to. . . Consistent/composable library How do I convert a stream to a Features list? How do I map a stream or an I/O or a hashtable? Conclusion How should I represent Unicode strings? Extensibility Camlp4/Camlp5 ok. But how do I add new kinds of I/O? How do I create new streams? Fun factor Oh, yeah. Despite competition with Haskell. Public relations Insucient. Despite competition with Haskell.

OCaml, Batteries And in OCaml? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Well-suited library Low-level library in a high-level language. I/O From Channels to I/O Minimal library sucient for testing, not necessarily for Composability development. Extensibility Text From string to. . . Consistent/composable library How do I convert a stream to a Features list? How do I map a stream or an I/O or a hashtable? Conclusion How should I represent Unicode strings? Extensibility Camlp4/Camlp5 ok. But how do I add new kinds of I/O? How do I create new streams? Tutorials Whole-language tutorials ok. Task-specic languages not so ok. Plus newbies need to nd them. Public relations Insucient. Despite competition with Haskell.

OCaml, Batteries And in OCaml? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Well-suited library Low-level library in a high-level language. I/O From Channels to I/O Minimal library sucient for testing, not necessarily for Composability development. Extensibility Text From string to. . . Consistent/composable library How do I convert a stream to a Features list? How do I map a stream or an I/O or a hashtable? Conclusion How should I represent Unicode strings? Extensibility Camlp4/Camlp5 ok. But how do I add new kinds of I/O? How do I create new streams? Tutorials Whole-language tutorials ok. Task-specic languages not so ok. Plus newbies need to nd them. Fun factor Oh, yeah. Despite competition with Haskell. OCaml, Batteries And in OCaml? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Well-suited library Low-level library in a high-level language. I/O From Channels to I/O Minimal library sucient for testing, not necessarily for Composability development. Extensibility Text From string to. . . Consistent/composable library How do I convert a stream to a Features list? How do I map a stream or an I/O or a hashtable? Conclusion How should I represent Unicode strings? Extensibility Camlp4/Camlp5 ok. But how do I add new kinds of I/O? How do I create new streams? Tutorials Whole-language tutorials ok. Task-specic languages not so ok. Plus newbies need to nd them. Fun factor Oh, yeah. Despite competition with Haskell. Public relations Insucient. Despite competition with Haskell. Consistent/composable library Add base abstractions & data structures, uniformize interfaces. Extensibility Liberate the base data structures! Tutorials Improve documentation. Fun factor Can always be improved. Cabal? Public relations OCaml Developer Days, OCamlCore.org, books, teaching, etc.

OCaml, Batteries What can we improve? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Well-suited library Build a high-level library. Extensibility Text From string to. . . Features Conclusion Extensibility Liberate the base data structures! Tutorials Improve documentation. Fun factor Can always be improved. Cabal? Public relations OCaml Developer Days, OCamlCore.org, books, teaching, etc.

OCaml, Batteries What can we improve? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Well-suited library Build a high-level library. Extensibility Text Consistent/composable library Add base abstractions & data From string to. . . structures, uniformize interfaces. Features Conclusion Tutorials Improve documentation. Fun factor Can always be improved. Cabal? Public relations OCaml Developer Days, OCamlCore.org, books, teaching, etc.

OCaml, Batteries What can we improve? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Well-suited library Build a high-level library. Extensibility Text Consistent/composable library Add base abstractions & data From string to. . . structures, uniformize interfaces. Features Conclusion Extensibility Liberate the base data structures! Fun factor Can always be improved. Cabal? Public relations OCaml Developer Days, OCamlCore.org, books, teaching, etc.

OCaml, Batteries What can we improve? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Well-suited library Build a high-level library. Extensibility Text Consistent/composable library Add base abstractions & data From string to. . . structures, uniformize interfaces. Features Conclusion Extensibility Liberate the base data structures! Tutorials Improve documentation. Public relations OCaml Developer Days, OCamlCore.org, books, teaching, etc.

OCaml, Batteries What can we improve? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Well-suited library Build a high-level library. Extensibility Text Consistent/composable library Add base abstractions & data From string to. . . structures, uniformize interfaces. Features Conclusion Extensibility Liberate the base data structures! Tutorials Improve documentation. Fun factor Can always be improved. Cabal? OCaml, Batteries What can we improve? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Well-suited library Build a high-level library. Extensibility Text Consistent/composable library Add base abstractions & data From string to. . . structures, uniformize interfaces. Features Conclusion Extensibility Liberate the base data structures! Tutorials Improve documentation. Fun factor Can always be improved. Cabal? Public relations OCaml Developer Days, OCamlCore.org, books, teaching, etc. OCaml, Batteries Introducing Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion

OCaml Batteries Included I More fun!

OCaml, Batteries Our objectives Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability A distribution of OCaml with Extensibility Text From string to. . . Features I Newbie-oriented documentation. Conclusion I More comfortable syntax.

I Consistent and high-level API.

I Extensible data structures. OCaml, Batteries Our objectives Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability A distribution of OCaml with Extensibility Text From string to. . . Features I Newbie-oriented documentation. Conclusion I More comfortable syntax.

I Consistent and high-level API.

I Extensible data structures.

I More fun! Improve the user experience, don't reinvent the wheel! Don't turn OCaml into Java! Built on top of the Base library and ExtLib.

OCaml, Batteries How? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability API Existing libraries + uniformization glue layer. Extensibility Text From string to. . . Language Syntax extensions, auto-loaded. Features Toolchain Existing tools + transparent shell scripts. Conclusion Documentation Largely rewritten + new doclet. Built on top of the Base library and ExtLib.

OCaml, Batteries How? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability API Existing libraries + uniformization glue layer. Extensibility Text From string to. . . Language Syntax extensions, auto-loaded. Features Toolchain Existing tools + transparent shell scripts. Conclusion Documentation Largely rewritten + new doclet. Improve the user experience, don't reinvent the wheel! Don't turn OCaml into Java! OCaml, Batteries How? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability API Existing libraries + uniformization glue layer. Extensibility Text From string to. . . Language Syntax extensions, auto-loaded. Features Toolchain Existing tools + transparent shell scripts. Conclusion Documentation Largely rewritten + new doclet. Improve the user experience, don't reinvent the wheel! Don't turn OCaml into Java! Built on top of the Base library and ExtLib. OCaml, Batteries Included Introduction David Teller et al.

Introduction Manipulating data Manipulating data From loops to enumerations Other data structures From loops to enumerations I/O From Channels to I/O Other data structures Composability Extensibility Text From string to. . . I/O Features From Channels to I/O Conclusion Composability Extensibility

Text From string to. . . Features

Conclusion OCaml, Batteries Step 1 Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Objective Simplify and uniformize access. Conclusion Objective Decrease need for multi-paradigm for simple tasks. OCaml, Batteries What is this for? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text OCaml has From string to. . . Features built-in specialized loops for, while Conclusion data structure-based loops List.iter, List.fold_left, List.fold_right, List.map... built-in general loops let rec OCaml, Batteries What is this for? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility OCaml has Text From string to. . . built-in specialized loops for, while (very specialized, very Features optimized) Conclusion data structure-based loops List.iter, List.fold_left, List.fold_right, List.map... built-in general loops let rec OCaml, Batteries What is this for? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability OCaml has Extensibility Text From string to. . . built-in specialized loops for, while (very specialized, very Features optimized) Conclusion data structure-based loops List.iter, List.fold_left, List.fold_right, List.map. . . (requires data structure, not homogeneous among structures) built-in general loops let rec OCaml, Batteries What is this for? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability OCaml has Extensibility Text built-in specialized loops for, while (very specialized, very From string to. . . optimized) Features Conclusion data structure-based loops List.iter, List.fold_left, List.fold_right, List.map. . . (requires data structure, not homogeneous among structures) built-in general loops let rec (general mechanism for implementing loops) OCaml, Batteries What is this for? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O OCaml has From Channels to I/O Composability built-in specialized loops for, while (very specialized, very Extensibility Text optimized) From string to. . . Features data structure-based loops List.iter, List.fold_left, Conclusion List.fold_right, List.map. . . (requires data structure, not homogeneous among structures) built-in general loops let rec (general mechanism for implementing loops)

I Specialized loops are optimizations.

I let rec is (among other things) an extension mechanism. Operations foreach/iter, map, fold, scanl, filter, flatten Conversion List.enum/List.backwards/ Array.enum/Array.backwards/ Hashtbl.enum/Hashtbl.keys/Hashtbl.values/ String.enum/String.backwards/... Construction (  ), ( - ) , ( ∼∼∼ ), unfold, etc. Source ExtLib, SDFlow, new stu

OCaml, Batteries Enter enumerations Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Overview Lightweight iterators, aka like Stream.t, but From Channels to I/O Composability open. Extensibility Text From string to. . . Features Conclusion Conversion List.enum/List.backwards/ Array.enum/Array.backwards/ Hashtbl.enum/Hashtbl.keys/Hashtbl.values/ String.enum/String.backwards/... Construction (  ), ( - ) , ( ∼∼∼ ), unfold, etc. Source ExtLib, SDFlow, new stu

OCaml, Batteries Enter enumerations Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Overview Lightweight iterators, aka like Stream.t, but From Channels to I/O Composability open. Extensibility Text From string to. . . Operations foreach/iter, map, fold, scanl, filter, Features flatten Conclusion OCaml, Batteries Enter enumerations Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Overview Lightweight iterators, aka like Stream.t, but From Channels to I/O Composability open. Extensibility Text From string to. . . Operations foreach/iter, map, fold, scanl, filter, Features flatten Conclusion Conversion List.enum/List.backwards/ Array.enum/Array.backwards/ Hashtbl.enum/Hashtbl.keys/Hashtbl.values/ String.enum/String.backwards/... Construction (  ), ( - ) , ( ∼∼∼ ), unfold, etc. Source ExtLib, SDFlow, new stu 1 -- 10

Exercise Print all elements between 1 to 10. let print_intln x = print_int x; print_newline ();; foreach ( 1 -- 10 ) print_intln

OCaml, Batteries Examples Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Exercise Count from 1 to 10. Extensibility Text From string to. . . Features Conclusion Exercise Print all elements between 1 to 10. let print_intln x = print_int x; print_newline ();; foreach ( 1 -- 10 ) print_intln

OCaml, Batteries Examples Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Exercise Count from 1 to 10. Extensibility Text 1 -- 10 From string to. . . Features Conclusion let print_intln x = print_int x; print_newline ();; foreach ( 1 -- 10 ) print_intln

OCaml, Batteries Examples Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Exercise Count from 1 to 10. Extensibility Text 1 -- 10 From string to. . . Features Conclusion Exercise Print all elements between 1 to 10. OCaml, Batteries Examples Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Exercise Count from 1 to 10. Extensibility Text 1 -- 10 From string to. . . Features Conclusion Exercise Print all elements between 1 to 10. let print_intln x = print_int x; print_newline ();; foreach ( 1 -- 10 ) print_intln let square x = x * x andodd x=xmod2=1 in foreach ( map square ( ( 100 --- 1 ) // odd) ) print_intln Did I mention syntax extensions? foreach [? x*x | x <- ( 100 --- 1 ); x mod 2 = 1] print_intln

OCaml, Batteries Examples (2) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Exercise Print the square numbers of all odd numbers between From Channels to I/O Composability 1 and 100, by decreasing order. Extensibility Text From string to. . . Features Conclusion Did I mention syntax extensions? foreach [? x*x | x <- ( 100 --- 1 ); x mod 2 = 1] print_intln

OCaml, Batteries Examples (2) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Exercise Print the square numbers of all odd numbers between From Channels to I/O Composability 1 and 100, by decreasing order. Extensibility Text let square x = x * x From string to. . . Features andodd x=xmod2=1 Conclusion in foreach ( map square ( ( 100 --- 1 ) // odd) ) print_intln OCaml, Batteries Examples (2) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Exercise Print the square numbers of all odd numbers between From Channels to I/O Composability 1 and 100, by decreasing order. Extensibility Text let square x = x * x From string to. . . Features andodd x=xmod2=1 Conclusion in foreach ( map square ( ( 100 --- 1 ) // odd) ) print_intln Did I mention syntax extensions? foreach [? x*x | x <- ( 100 --- 1 ); x mod 2 = 1] print_intln let too_cool = "OCaml is too cool for school" in String.of_enum( (String.enum too_cool) // (function 'a'|'e'|'i'|'o'|'u' |'A'|'E'|'I'|'O'|'U' -> true |_ ->false))

Syntax extensions, again: [? String : x | x <- String : too_cool ; vowel x] where vowel = function 'a'|'e'|'i'|'o'|'u' |'A'|'E'|'I'|'O'|'U' -> true | _ -> false

OCaml, Batteries Examples (3) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Exercise Keep only the vowels of OCaml is too cool for Other data structures I/O school. From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion Syntax extensions, again: [? String : x | x <- String : too_cool ; vowel x] where vowel = function 'a'|'e'|'i'|'o'|'u' |'A'|'E'|'I'|'O'|'U' -> true | _ -> false

OCaml, Batteries Examples (3) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Exercise Keep only the vowels of OCaml is too cool for Other data structures I/O school. From Channels to I/O Composability let too_cool = "OCaml is too cool for school" in Extensibility String.of_enum( Text From string to. . . (String.enum too_cool) // Features (function 'a'|'e'|'i'|'o'|'u' Conclusion |'A'|'E'|'I'|'O'|'U' -> true |_ ->false)) OCaml, Batteries Examples (3) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Exercise Keep only the vowels of OCaml is too cool for Other data structures I/O school. From Channels to I/O Composability let too_cool = "OCaml is too cool for school" in Extensibility String.of_enum( Text From string to. . . (String.enum too_cool) // Features (function 'a'|'e'|'i'|'o'|'u' Conclusion |'A'|'E'|'I'|'O'|'U' -> true |_ ->false))

Syntax extensions, again: [? String : x | x <- String : too_cool ; vowel x] where vowel = function 'a'|'e'|'i'|'o'|'u' |'A'|'E'|'I'|'O'|'U' -> true | _ -> false I Upgraded lists, arrays, big arrays, hashtables, queues, stacks, maps, sets.

I Everything supports Sexplib, printing, enumerations, etc.

I Most things support comprehension.

OCaml, Batteries Other data structures Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility I Doubly-linked lists, defunctorized polymorphic maps, Text From string to. . . multi-maps, dynamic arrays, lazy lists, defunctorized Features polymorphic sets, ... Conclusion I Everything supports Sexplib, printing, enumerations, etc.

I Most things support comprehension.

OCaml, Batteries Other data structures Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility I Doubly-linked lists, defunctorized polymorphic maps, Text From string to. . . multi-maps, dynamic arrays, lazy lists, defunctorized Features polymorphic sets, ... Conclusion

I Upgraded lists, arrays, big arrays, hashtables, queues, stacks, maps, sets. I Most things support comprehension.

OCaml, Batteries Other data structures Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility I Doubly-linked lists, defunctorized polymorphic maps, Text From string to. . . multi-maps, dynamic arrays, lazy lists, defunctorized Features polymorphic sets, ... Conclusion

I Upgraded lists, arrays, big arrays, hashtables, queues, stacks, maps, sets.

I Everything supports Sexplib, printing, enumerations, etc. OCaml, Batteries Other data structures Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility I Doubly-linked lists, defunctorized polymorphic maps, Text From string to. . . multi-maps, dynamic arrays, lazy lists, defunctorized Features polymorphic sets, ... Conclusion

I Upgraded lists, arrays, big arrays, hashtables, queues, stacks, maps, sets.

I Everything supports Sexplib, printing, enumerations, etc.

I Most things support comprehension. OCaml, Batteries Included Introduction David Teller et al.

Introduction Manipulating data Manipulating data From loops to enumerations Other data structures From loops to enumerations I/O From Channels to I/O Other data structures Composability Extensibility Text From string to. . . I/O Features From Channels to I/O Conclusion Composability Extensibility

Text From string to. . . Features

Conclusion Also, can't lter/map/... on channels. Shameless plug #2: channel # is open, though.

OCaml, Batteries Channels are closed Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Jan 30 00:50:25 Is there a way to make an output_channel that just Extensibility accepts output and doesn't do anything? Text Jan 30 00:51:23 open_out "/dev/null" ? From string to. . . Jan 30 00:54:00 brendan: I am looking for something that won't require Features a file/any specified location. Jan 30 00:54:47 Shameless plug: with Batteries, it's possible. Conclusion Jan 30 00:55:14 (other than that, you could trick it with a pipe, but that's much more complicated than /dev/null) Jan 30 00:55:50 Yoric[DT]: I am hoping for something nice and system agnostic so I can run the same code on linux/unix/ mac OSx/cygwin...

... Shameless plug #2: channel #ocaml is open, though.

OCaml, Batteries Channels are closed Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Jan 30 00:50:25 Is there a way to make an output_channel that just Extensibility accepts output and doesn't do anything? Text Jan 30 00:51:23 open_out "/dev/null" ? From string to. . . Jan 30 00:54:00 brendan: I am looking for something that won't require Features a file/any specified location. Jan 30 00:54:47 Shameless plug: with Batteries, it's possible. Conclusion Jan 30 00:55:14 (other than that, you could trick it with a pipe, but that's much more complicated than /dev/null) Jan 30 00:55:50 Yoric[DT]: I am hoping for something nice and system agnostic so I can run the same code on linux/unix/ mac OSx/cygwin...

... Also, can't lter/map/... on channels. OCaml, Batteries Channels are closed Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Jan 30 00:50:25 Is there a way to make an output_channel that just Extensibility accepts output and doesn't do anything? Text Jan 30 00:51:23 open_out "/dev/null" ? From string to. . . Jan 30 00:54:00 brendan: I am looking for something that won't require Features a file/any specified location. Jan 30 00:54:47 Shameless plug: with Batteries, it's possible. Conclusion Jan 30 00:55:14 (other than that, you could trick it with a pipe, but that's much more complicated than /dev/null) Jan 30 00:55:50 Yoric[DT]: I am hoping for something nice and system agnostic so I can run the same code on linux/unix/ mac OSx/cygwin...

... Also, can't lter/map/... on channels. Shameless plug #2: channel #ocaml is open, though. OCaml, Batteries What's going on? Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . OCaml's in_channel/out_channel are Features Conclusion I operating system-level

I tied to the Unix model

I closed. Operations All the usual operations, plus i/o lters, position, callbacks, Unicode, auto-ushing. . . Conversion To/from enumerations, strings, le names, sockets, processes. . . Construction File.open_in/open_out, wrap_in/wrap_out... Source ExtLib, OCamlNet, Camomile, more stu

OCaml, Batteries Enter input/output Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Overview Drop-in replacement for in_channel/out_channel Composability Extensibility operations. Text From string to. . . Features Conclusion Conversion To/from enumerations, strings, le names, sockets, processes. . . Construction File.open_in/open_out, wrap_in/wrap_out... Source ExtLib, OCamlNet, Camomile, more stu

OCaml, Batteries Enter input/output Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Overview Drop-in replacement for in_channel/out_channel Composability Extensibility operations. Text From string to. . . Operations All the usual operations, plus i/o lters, position, Features callbacks, Unicode, auto-ushing. . . Conclusion OCaml, Batteries Enter input/output Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Overview Drop-in replacement for in_channel/out_channel Composability Extensibility operations. Text From string to. . . Operations All the usual operations, plus i/o lters, position, Features callbacks, Unicode, auto-ushing. . . Conclusion Conversion To/from enumerations, strings, le names, sockets, processes. . . Construction File.open_in/open_out, wrap_in/wrap_out... Source ExtLib, OCamlNet, Camomile, more stu open IO, File foreach (args ()) (fun s -> copy (open_in s) stdout) or foreach (args ()) **> fun s -> copy (open_in s) stdout

OCaml, Batteries Let's do it with Batteries Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Exercise Let's implement cat with Batteries. Extensibility Text From string to. . . Features Conclusion or foreach (args ()) **> fun s -> copy (open_in s) stdout

OCaml, Batteries Let's do it with Batteries Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Exercise Let's implement cat with Batteries. Extensibility Text From string to. . . open IO, File Features foreach (args ()) Conclusion (fun s -> copy (open_in s) stdout) OCaml, Batteries Let's do it with Batteries Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Exercise Let's implement cat with Batteries. Extensibility Text From string to. . . open IO, File Features foreach (args ()) Conclusion (fun s -> copy (open_in s) stdout) or foreach (args ()) **> fun s -> copy (open_in s) stdout open IO foreach (args ()) (fun s -> Enum . iteri (Printf.printf "%d %s\n") (File.lines_of s) ) In this last version, a le was automatically opened, read (lazily), split into lines and closed.

OCaml, Batteries Let's do it with Batteries (2) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Exercise Now, let's implement a version of cat which prints Composability line numbers along with line contents. Extensibility Text From string to. . . Features Conclusion In this last version, a le was automatically opened, read (lazily), split into lines and closed.

OCaml, Batteries Let's do it with Batteries (2) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Exercise Now, let's implement a version of cat which prints Composability line numbers along with line contents. Extensibility Text From string to. . . open IO Features foreach (args ()) (fun s -> Conclusion Enum . iteri (Printf.printf "%d %s\n") (File.lines_of s) ) OCaml, Batteries Let's do it with Batteries (2) Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Exercise Now, let's implement a version of cat which prints Composability line numbers along with line contents. Extensibility Text From string to. . . open IO Features foreach (args ()) (fun s -> Conclusion Enum . iteri (Printf.printf "%d %s\n") (File.lines_of s) ) In this last version, a le was automatically opened, read (lazily), split into lines and closed. open IO foreach (args ()) (fun s -> Enum . iteri (Printf.printf "%d %s\n") (lines_of (GZip.uncompress (File.open_in s))) ) Exercise Count number of bytes read. foreach (args ()) (fun s -> let (inp, pos) = pos_in (File.open_in s) in Enum . iteri (Printf.printf "%d %s\n") (lines_of (GZip.uncompress inp)); Printf.printf "\tRead %d bytes\n" ( pos ()) ) etc.

OCaml, Batteries Going further Included

David Teller et al.

Introduction Exercise Add gzip-decompression. Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion Exercise Count number of bytes read. foreach (args ()) (fun s -> let (inp, pos) = pos_in (File.open_in s) in Enum . iteri (Printf.printf "%d %s\n") (lines_of (GZip.uncompress inp)); Printf.printf "\tRead %d bytes\n" ( pos ()) ) etc.

OCaml, Batteries Going further Included

David Teller et al.

Introduction Exercise Add gzip-decompression. Manipulating data From loops to enumerations open IO Other data structures I/O foreach (args ()) (fun s -> From Channels to I/O Composability Enum . iteri Extensibility (Printf.printf "%d %s\n") Text From string to. . . (lines_of (GZip.uncompress (File.open_in s))) Features ) Conclusion foreach (args ()) (fun s -> let (inp, pos) = pos_in (File.open_in s) in Enum . iteri (Printf.printf "%d %s\n") (lines_of (GZip.uncompress inp)); Printf.printf "\tRead %d bytes\n" ( pos ()) ) etc.

OCaml, Batteries Going further Included

David Teller et al.

Introduction Exercise Add gzip-decompression. Manipulating data From loops to enumerations open IO Other data structures I/O foreach (args ()) (fun s -> From Channels to I/O Composability Enum . iteri Extensibility (Printf.printf "%d %s\n") Text From string to. . . (lines_of (GZip.uncompress (File.open_in s))) Features ) Conclusion Exercise Count number of bytes read. etc.

OCaml, Batteries Going further Included

David Teller et al.

Introduction Exercise Add gzip-decompression. Manipulating data From loops to enumerations open IO Other data structures I/O foreach (args ()) (fun s -> From Channels to I/O Composability Enum . iteri Extensibility (Printf.printf "%d %s\n") Text From string to. . . (lines_of (GZip.uncompress (File.open_in s))) Features ) Conclusion Exercise Count number of bytes read. foreach (args ()) (fun s -> let (inp, pos) = pos_in (File.open_in s) in Enum . iteri (Printf.printf "%d %s\n") (lines_of (GZip.uncompress inp)); Printf.printf "\tRead %d bytes\n" ( pos ()) ) OCaml, Batteries Going further Included

David Teller et al.

Introduction Exercise Add gzip-decompression. Manipulating data From loops to enumerations open IO Other data structures I/O foreach (args ()) (fun s -> From Channels to I/O Composability Enum . iteri Extensibility (Printf.printf "%d %s\n") Text From string to. . . (lines_of (GZip.uncompress (File.open_in s))) Features ) Conclusion Exercise Count number of bytes read. foreach (args ()) (fun s -> let (inp, pos) = pos_in (File.open_in s) in Enum . iteri (Printf.printf "%d %s\n") (lines_of (GZip.uncompress inp)); Printf.printf "\tRead %d bytes\n" ( pos ()) ) etc. Writing new inputs/outputs is easy. val create_in: read:(unit -> char) -> input:(string -> int -> int -> int) -> close:(unit -> unit) -> input val wrap_in: read:(unit -> char) -> input:(string -> int -> int -> int) -> close:(unit -> unit) -> underlying:(input list) -> input

OCaml, Batteries I/O is open Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Want to read from a string, a socket, an http connexion, etc? I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion OCaml, Batteries I/O is open Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures Want to read from a string, a socket, an http connexion, etc? I/O From Channels to I/O Writing new inputs/outputs is easy. Composability Extensibility val create_in: Text From string to. . . read:(unit -> char) -> Features input:(string -> int -> int -> int) -> Conclusion close:(unit -> unit) -> input val wrap_in: read:(unit -> char) -> input:(string -> int -> int -> int) -> close:(unit -> unit) -> underlying:(input list) -> input OCaml, Batteries Included Introduction David Teller et al.

Introduction Manipulating data Manipulating data From loops to enumerations Other data structures From loops to enumerations I/O From Channels to I/O Other data structures Composability Extensibility Text From string to. . . I/O Features From Channels to I/O Conclusion Composability Extensibility

Text From string to. . . Features

Conclusion Strings are arrays of char, hence: confuse characters and bytes have no clear notion of encoding.

OCaml, Batteries The problem with strings Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Strings are mutable, hence: Text From string to. . . dicult to trust Features Conclusion slooow to append. OCaml, Batteries The problem with strings Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Strings are mutable, hence: Text From string to. . . dicult to trust Features Conclusion slooow to append. Strings are arrays of char, hence: confuse characters and bytes have no clear notion of encoding. Operations All the operations of String except mutability. Conversion Rope.of_latin1, Rope.of_uchar, ... Notes Allocation optimized (with Camlp4!), immutable implementation.

OCaml, Batteries Introducing ropes Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O r"This is a UTF-8 encoded rope" Composability Extensibility Text From string to. . . Overview Functional UTF-8 encoded text with O(ln(n)) Features concatenation but slower get. Conclusion Limitations About 700Mb in 32-bit, about 220Gb in 64-bit. Conversion Rope.of_latin1, Rope.of_uchar, ... Notes Allocation optimized (with Camlp4!), immutable implementation.

OCaml, Batteries Introducing ropes Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O r"This is a UTF-8 encoded rope" Composability Extensibility Text From string to. . . Overview Functional UTF-8 encoded text with O(ln(n)) Features concatenation but slower get. Conclusion Limitations About 700Mb in 32-bit, about 220Gb in 64-bit. Operations All the operations of String except mutability. Notes Allocation optimized (with Camlp4!), immutable implementation.

OCaml, Batteries Introducing ropes Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O r"This is a UTF-8 encoded rope" Composability Extensibility Text From string to. . . Overview Functional UTF-8 encoded text with O(ln(n)) Features concatenation but slower get. Conclusion Limitations About 700Mb in 32-bit, about 220Gb in 64-bit. Operations All the operations of String except mutability. Conversion Rope.of_latin1, Rope.of_uchar, ... OCaml, Batteries Introducing ropes Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O r"This is a UTF-8 encoded rope" Composability Extensibility Text From string to. . . Overview Functional UTF-8 encoded text with O(ln(n)) Features concatenation but slower get. Conclusion Limitations About 700Mb in 32-bit, about 220Gb in 64-bit. Operations All the operations of String except mutability. Conversion Rope.of_latin1, Rope.of_uchar, ... Notes Allocation optimized (with Camlp4!), immutable implementation. Operations All the operations of String. Notes Optimized allocation for read-only strings.

OCaml, Batteries Introducing string with capabilities Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability ro"... a read-only Latin-1 string";; Extensibility wo"... a write-only Latin-1 string";; Text From string to. . . rw"... a read-write Latin-1 string";; Features Conclusion

Overview Your usual strings, but with phantom types to ensure read-only/write-only/read-write capability. Notes Optimized allocation for read-only strings.

OCaml, Batteries Introducing string with capabilities Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability ro"... a read-only Latin-1 string";; Extensibility wo"... a write-only Latin-1 string";; Text From string to. . . rw"... a read-write Latin-1 string";; Features Conclusion

Overview Your usual strings, but with phantom types to ensure read-only/write-only/read-write capability. Operations All the operations of String. OCaml, Batteries Introducing string with capabilities Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability ro"... a read-only Latin-1 string";; Extensibility wo"... a write-only Latin-1 string";; Text From string to. . . rw"... a read-write Latin-1 string";; Features Conclusion

Overview Your usual strings, but with phantom types to ensure read-only/write-only/read-write capability. Operations All the operations of String. Notes Optimized allocation for read-only strings. let hairsplit s = open String in let e = enum s in [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]] Exercise Same thing, but with Unicode. let hairsplit s = open Rope in let e = enum s in [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]]

OCaml, Batteries Exercise Included

David Teller et al.

Introduction Manipulating data Exercise From a string s, return the rst 5 characters, skip the From loops to enumerations Other data structures next 3, then return the next 5 characters, the next 5 characters I/O From Channels to I/O and the rest of the string. Composability Extensibility Text From string to. . . Features Conclusion Exercise Same thing, but with Unicode. let hairsplit s = open Rope in let e = enum s in [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]]

OCaml, Batteries Exercise Included

David Teller et al.

Introduction Manipulating data Exercise From a string s, return the rst 5 characters, skip the From loops to enumerations Other data structures next 3, then return the next 5 characters, the next 5 characters I/O From Channels to I/O and the rest of the string. Composability Extensibility let hairsplit s = Text From string to. . . open String in Features let e = enum s in Conclusion [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]] let hairsplit s = open Rope in let e = enum s in [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]]

OCaml, Batteries Exercise Included

David Teller et al.

Introduction Manipulating data Exercise From a string s, return the rst 5 characters, skip the From loops to enumerations Other data structures next 3, then return the next 5 characters, the next 5 characters I/O From Channels to I/O and the rest of the string. Composability Extensibility let hairsplit s = Text From string to. . . open String in Features let e = enum s in Conclusion [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]] Exercise Same thing, but with Unicode. OCaml, Batteries Exercise Included

David Teller et al.

Introduction Manipulating data Exercise From a string s, return the rst 5 characters, skip the From loops to enumerations Other data structures next 3, then return the next 5 characters, the next 5 characters I/O From Channels to I/O and the rest of the string. Composability Extensibility let hairsplit s = Text From string to. . . open String in Features let e = enum s in Conclusion [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]] Exercise Same thing, but with Unicode. let hairsplit s = open Rope in let e = enum s in [? List : of_enum (f e) | f <- List : [take 5; skip 3 |- take 5; take 5; identity]] OCaml, Batteries Text features, too Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O All these data structures support Composability Extensibility I iteration, map, folds, lters, replacement, enumeration, Text From string to. . . construction from enumeration, searching from left to Features right, from right to left, from a given index, chopping, Conclusion trimming, stripping, upper/lowercasing, splitting, slicing, splicing, etc.

I printing

I transcoding

I pattern-matching. OCaml, Batteries Included Introduction David Teller et al.

Introduction Manipulating data Manipulating data From loops to enumerations Other data structures From loops to enumerations I/O From Channels to I/O Other data structures Composability Extensibility Text From string to. . . I/O Features From Channels to I/O Conclusion Composability Extensibility

Text From string to. . . Features

Conclusion OCaml, Batteries Enough for one day Included

David Teller et al. Let's not detail Introduction uniform number modules for functorization Manipulating data I From loops to enumerations safe integers Other data structures I I/O enumerable signature From Channels to I/O I Composability on-line help Extensibility I Text From string to. . . I documentation by topics Features Conclusion I mostly at module-space

I overlay modules for labels or exceptionless error management

I the Future module

I printing

I marshaling

I substrings

I path management

I package management

I calling the compilers from a module

I ... Testing needed! Applications Extrapol static analyzer for C.

OCaml, Batteries Status Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Latest version Alpha 3 for OCaml 3.10/3.11 being From Channels to I/O Composability bugsquashed. Extensibility Text Site http://batteries.forge.ocamlcore.org. From string to. . . Features License Mostly LGPL + LE, bits in BSD. Conclusion Availability Tarball, GODI package. Tools ocaml, ocamlc, ocamlopt, ocamlcp, ocamlbuild. Size 27,650 loc signatures, 24,407 loc implementations. Next version Beta 1, expected ca. March. Applications Extrapol static analyzer for C.

OCaml, Batteries Status Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Latest version Alpha 3 for OCaml 3.10/3.11 being From Channels to I/O Composability bugsquashed. Extensibility Text Site http://batteries.forge.ocamlcore.org. From string to. . . Features License Mostly LGPL + LE, bits in BSD. Conclusion Availability Tarball, GODI package. Tools ocaml, ocamlc, ocamlopt, ocamlcp, ocamlbuild. Size 27,650 loc signatures, 24,407 loc implementations. Next version Beta 1, expected ca. March. Testing needed! OCaml, Batteries Status Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O Latest version Alpha 3 for OCaml 3.10/3.11 being From Channels to I/O Composability bugsquashed. Extensibility Text Site http://batteries.forge.ocamlcore.org. From string to. . . Features License Mostly LGPL + LE, bits in BSD. Conclusion Availability Tarball, GODI package. Tools ocaml, ocamlc, ocamlopt, ocamlcp, ocamlbuild. Size 27,650 loc signatures, 24,407 loc implementations. Next version Beta 1, expected ca. March. Testing needed! Applications Extrapol static analyzer for C. Fun!

OCaml, Batteries Batteries for new apps Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text Larger standard library No more reimplementing lazy lists or From string to. . . Features standard operators or trivial list functions. Conclusion Higher-level library More composability, more extensibility, etc. Syntactic sugar More readable algorithms. OCaml, Batteries Batteries for new apps Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text Larger standard library No more reimplementing lazy lists or From string to. . . Features standard operators or trivial list functions. Conclusion Higher-level library More composability, more extensibility, etc. Syntactic sugar More readable algorithms. Fun! Fun!

OCaml, Batteries Batteries for newbies Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text Documentation More examples, on-line help. From string to. . . Features Uniformity Modules follow more rigorous patterns and should Conclusion be easier to learn. Purity Going imperative is less often necessary. OCaml, Batteries Batteries for newbies Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text Documentation More examples, on-line help. From string to. . . Features Uniformity Modules follow more rigorous patterns and should Conclusion be easier to learn. Purity Going imperative is less often necessary. Fun! Better composition Fun! Essentially, please consider compatibility with Batteries for your next libraries.

OCaml, Batteries Batteries for new libraries Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Conventions Standard signatures, obsolete primitives, etc. Features Conclusion Essentially, please consider compatibility with Batteries for your next libraries.

OCaml, Batteries Batteries for new libraries Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Conventions Standard signatures, obsolete primitives, etc. Features Better composition Conclusion Fun! OCaml, Batteries Batteries for new libraries Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Conventions Standard signatures, obsolete primitives, etc. Features Better composition Conclusion Fun! Essentially, please consider compatibility with Batteries for your next libraries. OCaml, Batteries Problems to solve Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text I Huge binary size. From string to. . . Features I Toplevel pretty-printers. Conclusion

I Confusing error messages.

I Operator precedence for /, ..

I One-tarball distribution? Symbiosis? I Logging.

I Relooking the documentation with iframes.

I Locales.

I Optimizations (eg strings).

I CoThreads.

I oUnit?

I CamlGraph?

I AST/bytecode generation?

I Functional unparsing with Camlp4 support?

I Graphics? Cairo? Some UI toolkit?

I OS integration?

I Don't hesitate to use our Request for Features tracker.

I And our bug tracker, of course.

OCaml, Batteries In the future Included

David Teller et al.

I More OCamlNet (β). Introduction Manipulating data I Preferences (β). From loops to enumerations Other data structures I Pa-do (β). I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion I oUnit?

I CamlGraph?

I AST/bytecode generation?

I Functional unparsing with Camlp4 support?

I Graphics? Cairo? Some UI toolkit?

I OS integration?

I Don't hesitate to use our Request for Features tracker.

I And our bug tracker, of course.

OCaml, Batteries In the future Included

David Teller et al.

I More OCamlNet (β). Introduction Manipulating data I Preferences (β). From loops to enumerations Other data structures I Pa-do (β). I/O From Channels to I/O Logging. Composability I Extensibility Relooking the documentation with iframes. Text I From string to. . . Locales. Features I Conclusion I Optimizations (eg strings).

I CoThreads. I Don't hesitate to use our Request for Features tracker.

I And our bug tracker, of course.

OCaml, Batteries In the future Included

David Teller et al.

I More OCamlNet (β). Introduction Manipulating data I Preferences (β). From loops to enumerations Other data structures I Pa-do (β). I/O From Channels to I/O Logging. Composability I Extensibility Relooking the documentation with iframes. Text I From string to. . . Locales. Features I Conclusion I Optimizations (eg strings).

I CoThreads.

I oUnit?

I CamlGraph?

I AST/bytecode generation?

I Functional unparsing with Camlp4 support?

I Graphics? Cairo? Some UI toolkit?

I OS integration? I And our bug tracker, of course.

OCaml, Batteries In the future Included

David Teller et al.

I More OCamlNet (β). Introduction Manipulating data I Preferences (β). From loops to enumerations Other data structures I Pa-do (β). I/O From Channels to I/O Logging. Composability I Extensibility Relooking the documentation with iframes. Text I From string to. . . Locales. Features I Conclusion I Optimizations (eg strings).

I CoThreads.

I oUnit?

I CamlGraph?

I AST/bytecode generation?

I Functional unparsing with Camlp4 support?

I Graphics? Cairo? Some UI toolkit?

I OS integration?

I Don't hesitate to use our Request for Features tracker. OCaml, Batteries In the future Included

David Teller et al.

I More OCamlNet (β). Introduction Manipulating data I Preferences (β). From loops to enumerations Other data structures I Pa-do (β). I/O From Channels to I/O Logging. Composability I Extensibility Relooking the documentation with iframes. Text I From string to. . . Locales. Features I Conclusion I Optimizations (eg strings).

I CoThreads.

I oUnit?

I CamlGraph?

I AST/bytecode generation?

I Functional unparsing with Camlp4 support?

I Graphics? Cairo? Some UI toolkit?

I OS integration?

I Don't hesitate to use our Request for Features tracker.

I And our bug tracker, of course. OCaml, Batteries Thank you Included

David Teller et al.

Introduction Manipulating data From loops to enumerations Other data structures I/O From Channels to I/O Composability Extensibility Text From string to. . . Features Conclusion Questions? Contact me/us: MLState may have a job/PhD/internship for you.

OCaml, Batteries If you're. . . Included

David Teller et al.

I A PhD, a PhD student or a future PhD student.

I Into OCaml, similar languages or Coq.

I Into compilers, concurrency, distributed systems, semantics, proof of programs.

I Into language tools, language front-ends, language design.

I Interested by safe programming for the web. OCaml, Batteries If you're. . . Included

David Teller et al.

I A PhD, a PhD student or a future PhD student.

I Into OCaml, similar languages or Coq.

I Into compilers, concurrency, distributed systems, semantics, proof of programs.

I Into language tools, language front-ends, language design.

I Interested by safe programming for the web. Contact me/us: MLState may have a job/PhD/internship for you.