[Haskell-cafe] Haskell scripting system (please help me simplify
joelr1 at gmail.com
Thu Oct 27 12:26:57 EDT 2005
Something else just occurred to me... How would I represent "no
command" using the Unstuff monad? I'm returning Maybe Command right
now, would this change?
On Oct 27, 2005, at 4:59 PM, Robert Dockins wrote:
> You could consider creating a monad for the "unstuff" part of the
> operation that would hide dealing with the FastString, the tupling
> and the case analysis on Maybe.
> Your code might then look like:
> class (Eq a) => Packet a where
> unstuff :: Unstuff a
> stuff :: a -> P.FastString
> size :: a -> Int
> instance Packet BaseTableState where
> unstuff = unstuffprops baseTableStateProps >>= return .
> sutff (BaseTableState a) = stuffprops a
> size (BaseTableState a) = sizeprops a
> where Unstuff is the type constructor for your monad.
More information about the Haskell-Cafe