
John Goerzen wrote:
On 2008-02-20, Jules Bean
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... Cheers Ben