Q: Best way to represent a file/folder structure I want to represent a file structure to later write it to disk. What I need is to have a way to represent files, folders, their relationships and their contents. For example, represent a file structure like this:
|-one.txt -> contains "This is file 1"
|-aFolder
| |-aNestedFolder
| | |-aDoublyNestedEmptyFolder
|-anotherFolder
| |-aNestedFile -> contains "Contents of aNestedFile"
|-yetAnotherEmptyFolder

I am using this right now:
type fileTree =
  | File of (string * string)
  | Folder of (string * (fileTree list))

let example = [
  File ("one.txt", "This is file 1");
  Folder ("aFolder", 
      [Folder ("aNestedFolder", 
          [Folder ("aDoublyNestedEmptyFolder", [])])]) ;
  Folder ("anotherFolder", 
      [File ("aNestedFile", "Contents of aNestedFile")]);
  Folder ("yetAnotherEmptyFolder", []);
]

This works for now, but I'd like to know if there's a smarter way to represent a file structure like this.

A: Your representation is completely straightforward, so it's hard to think of a better one unless you have more specific requirements.
A tiny (more or less cosmetic) change would be to use:
type fileTree =
  | File of string * string
  | Folder of string * fileTree list

This isn't the same type, and is a tiny bit more effective when you don't need a direct representation of the pairs.
If you want to look files up quickly in this kind of structure, and if the structure is going to get really large, you might want to use nested maps or hashtables.
Update
There's some discussion of the difference between the two types. It has been explained very well before here at SO, but I haven't been able to find the page. Here's a session showing the difference:
$ ocaml
        OCaml version 4.02.1

# type f = A of (int * int);;
type f = A of (int * int)
# type g = B of int * int;;
type g = B of int * int
# let x = (8, 7);;
val x : int * int = (8, 7)
# A x;;
- : f = A (8, 7)
# B x;;
Error: The constructor B expects 2 argument(s),
       but is applied here to 1 argument(s)
# 

The A constructor takes one value, a pair of ints. The B constructor takes two separate int values, not a pair.
In memory, a value of type f will have a header and one field. The one field will point to a pair (a header and two fields). A value of type g will just have a header and two fields.
It's not a big deal, mostly it's just interesting (at least to me).
Update 2
Here's a good SO discussion of this issue:

int * int vs (int * int) in OCaml sum type

