   (let ((environments (hsenv-list-environments dir)))
     (if (null environments)
         (message "Directory %s does not contain any hsenv." dir)
-      (message "environments: %s" environments)
-      (let* ((env-name (if (= 1 (length environments))
-                           (car (car environments))
-                         (completing-read "Environment:"
-                                          (mapcar #'car environments))))
+      (let* ((env-name
+              (if (= 1 (length environments))
+                  (hsenv-env-name (car environments))
+                (completing-read "Environment:"
+                                 (mapcar #'hsenv-env-name environments))))
              (env (assoc env-name environments)))
-        (message "name= %s env = %s" env-name env)
-        (let* ((hsenv-dir-name (cdr env))
+        (let* ((hsenv-dir-name (hsenv-env-dir env))
                (hsenv-dir (file-name-as-directory hsenv-dir-name)))
           (hsenv-activate-environment hsenv-dir))))))
 
 (defun hsenv-list-environments (dir)
   (let ((hsenv-dirs (append (file-expand-wildcards (concat dir ".hsenv"))
 			    (file-expand-wildcards (concat dir ".hsenv_*")))))
-    (mapcar (lambda (hsenv-dir)
-              (let* ((env-name
-                      (if (> (length hsenv-dir) (+ 7 (length dir)))
-                          (substring hsenv-dir (+ 7 (length dir)))
-                        "(default)")))
-                (cons env-name hsenv-dir)))
-            hsenv-dirs)))
+    (mapcar #'hsenv-make-env hsenv-dirs)))
 
 (defun hsenv-activate (&optional select-dir)
   "Activate a Virtual Haskell Environment"

            (hsenv-read-file-content hsenv-dir hsenv-ghc-package-path-file))
    (message "Environment activated: %s" hsenv-dir)))

(defun hsenv-deactivate ()
  "Deactivate the Virtual Haskell Environment"
  (interactive)

(defvar hsenv-active-environment nil
  "A assoc list of (NAME . DIRECTORY) pairs.

See `hsenv-make-env' for details.")

(defconst hsenv-path-prepend-file "path_var_prependix")
(defconst hsenv-ghc-package-path-file "ghc_package_path_var")

