3 ms·
So stage is some transformation of the file and a working directory data Stage = Stage (File -> File) Directory If we want to construct chains of Stages whe
by rapala 12y ago
So stage is some transformation of the file and a working directory
data Stage = Stage (File -> File) Directory
If we want to construct chains of Stages where we can still inspect any individual Stage, a monoidal composition wont cut it for the reason you stated. But this raises the question. What is the monoidal composition of Stages?
Well first of all, we must do something about the parameter Directory because the second type parameter must be a monoid too (the transformation function all ready is). But lets assume that it is, and see what we get.
mconcat (Stage f dir1) (Stage g dir2) = Stage (g . f) (mconcat dir1 dir2)
mempty = Stage id (mempty :: Directory)
So so if we can create a new directory from two directories, we can compose two Stages to a new one that uses the newly created working directory. Or if the second parameter of Stage is a list of directories, the new Stage uses two working directories. They aren't the idea of chains that you had in mind, but they still sound useful, at least to me.
- quchen 12y ago(Minor nitpick, your definition is `mappend` [1]. `mconcat` is `foldr mappend mempty` [2], i.e. concatenates a list of monoids.) [1] mappend :: Monoid m => m -> m -> m [2] mconcat :: Monoid m => [m] -> m