[Haskell-cafe] What are Kind errors and how do you fix them?

MR K P SCHUPKE k.schupke at imperial.ac.uk
Wed Mar 24 08:31:19 EST 2004


I dont understand what you are trying to do:

	type ReverseType a string = (string ->(string,a))

takes a string an returns a string and another value (looks like the
state monad with state=String.

	data Reverse a string = Reverse (ReverseType a string)

this just declares a type wrapper... why have both of the above, you only
need:

	data Reverse a s = Reverse (s -> (s,a))

NOw for your class definition:

	return x = Reverse (\text -> (text,x))

this is the standard return from a state monad.

	(Reverse p) >>= k = Reverse p3
                where
                p3 s0 = p2 s1
                        where
                        (Reverse p2) = k a
                        (s1,a)=p s0

the second parameter (k) needs the state passed as well
after unwrapping like:

	p2 = (\(Reverse x) -> x) (k a) s1

	Regards,
	Keean.


More information about the Haskell-Cafe mailing list