
You don't need a monad instance for this. First of all, you don't even need do syntax to make something "pretty" similar to this.
hdf5 $ group "name" $ [ dataset "name1" array1 , dataset "name2" array2 , group "other-name" $ [ …
This is for now the solution I decide to keep., nevertheless thanks for the monad ;). Now I would like you opinion about a type which allows me to select a node in this tree. I need to extract a bunch of values from these hdf5 files. So I discribe a location in the tree, like this with another type quite similar to the first but with only one child per group. This way there is only one dataset extracted. (maybe later, I will discuss about extracting multiple dataset ;). data Hdf5Path sh e = H5RootPath (Hdf5Path sh e) | H5GroupPath ByteString (Hdf5Path sh e) | H5DatasetPath ByteString hdf5p $ group "name" $ group "otherName" $ dataset "myDataset" Then I need to write something like this. withDataset :: File -> Hdf5Path sh e -> (Dataset -> IO r) -> IO r BUT, I would like to express this path like this hdf5p :: group <the first encounted> :: group "otherName" $ dataset "mydataset" So should I define a type and modify the group constructor like this H5GroupPath BytString (Hdf5Path sh e) GroupDesc = ByName ByteString | ByPosition Int | etc... H5GroupPath GropDesc (Hdf5Path sh e) the only problem I see with this is that I need to encode all the strategies in this type. Is there a better way to do this sort of things. thanks Frederic