Practical Generic Programming in Ocaml.pdf
(
240 KB
)
Pobierz
Practical Generic Programming with OCaml
Jeremy Yallop
LFCS, University of Edinburgh
ML Workshop 2007
Instead of this . . .
type
α
tree = Node
of
α
| Branch
of
(α tree)
×
(α tree)
val
show_tree : (α
→
string)
→
(α tree
→
string)
let rec
show_tree show_a =
function
Node a -> "Node " ^ show_a a
| Branch (l, r) -> "Branch ("^ show_tree l ^ ","
^ show_tree r ^ ")"
show_list (show_pair (show_tree show_int) show_bool) t
You can write this!
type
α
tree = Node
of
α
| Branch
of
(α tree)
×
(α tree)
deriving
(Show)
Show.show<(int tree * bool) list> t
Outline
Basic idea
Customization
More customization: pickling
Conclusions
Haskell type classes as OCaml modules
1
class
Show a
where
show :: a
→
String
module type
Show =
sig
type
a
val
show : a
→
string
end
Type class as signature
1
Dreyer, Harper, Chakravarty and Keller.
Modular Type Classes
(POPL 07)
Plik z chomika:
musli_com
Inne pliki z tego folderu:
Ocaml Documentation.pdf
(1962 KB)
OCaml Practice.pdf
(2807 KB)
Design Patterns in Ocaml.pdf
(125 KB)
index.html
(6 KB)
Ocaml Unix.pdf
(1304 KB)
Inne foldery tego chomika:
3D Design - Programming
ActionScript
Actionscript - Flash - Flex - Air
Ada
ADO
Zgłoś jeśli
naruszono regulamin