On Wed, Feb 20, 2008 at 11:18:51PM +0100, Ben Franksen wrote: > John Goerzen wrote: > > > On 2008-02-20, Jules Bean <[EMAIL PROTECTED]> wrote: > >> Not directly, no. > >> > >> The point about Foldable, Functor, and Monad, is that they enforce the > >> connection between container and contents. If the contents is of type > >> "a", the container is of type "f a" for a fixed type constructor 'f'. > >> This works for [], Seq, and so on, but fails for ByteString. > > > > Right. In a pure abstract sense, we humans know there is a > > relationship between container and contents: a ByteString always > > contains a Word8 (or a Char8 if we choose the alternative > > implementation). > > > > But that is not expressed in the type of ByteString. > > Hm, making a function out of a constant is easy on the value level, just use > (const x) instead of (x). So, what about wrapping ByteString in a GADT, > like this > > data ByteString' a where > BS' :: Word8 -> ByteString' Word8 > > ? I probably overlooked something important here...
The problem is that while this would change the kind of ByteString to the same as the kind expected by Functor, you still couldn't define a proper Functor instance, since only ByteString' Word8 can ever actually be created. i.e. how could you implement fmapBS :: (a -> b) -> ByteString' a -> ByteString' b -- David Roundy Department of Physics Oregon State University _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe