[Haskell-cafe] How to write a Monad instance for this type
to_br at uni-bremen.de
Tue Sep 3 09:43:40 UTC 2019
you might want to take a look at /free monads/
and the free library <http://hackage.haskell.org/package/free-5.1.1>.
On 9/2/19 9:20 PM, PICCA Frederic-Emmanuel wrote:
> Hello, I try to write a monad instance for this type which represent the content of an hdf5 file.
> This file format is similar to a filesystem, where directories are Group and files Dataset.
> I end up with this type.
> data Hdf5M a
> = H5Root (Hdf5M a)
> | H5Group ByteString [Hdf5M a] -- A group can contain other groups and/or datasets
> | forall sh b. (NativeType b, Shape sh) => H5Dataset ByteString (Array F sh b)
> type Hdf5 = Hdf5M ()
> hdf5 :: Hdf5 -> Hdf5
> hdf5 = H5Root
> group :: ByteString -> [Hdf5] -> Hdf5
> group g = H5Group g
> dataset :: (NativeType b, Shape sh) => ByteString -> (Array F sh b) -> Hdf5
> dataset = H5Dataset
> I tryed to inspire myself from the blaze-html Markup type.
> And I would like to be able to describe a contain like this
> hdf5 $ do
> group "name" $ do
> dataset "name1" array1
> dataset "name2" array2
> group "other-name" $ do
> instead of
> H5Root ( H5Group "name" [ dataset ]...)
> the final idea, is to be able to serialize object via a
> class ToHdf5 where
> toHdf5 :: a -> Hdf5
> So my question is someone can help me design this ?
> thanks for your help
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe