Shawn P. Garbett writes:
:
| What I want is something like this, so that the state transformer has a
| generic state type:
|
| newtype St a s = MkSt (s - (a, s))
|
| apply :: St a s - s - (a, s)
| apply (MkSt f) s = f s
|
| instance Monad St where
| return x = MkSt
On 2002-08-08T14:11:54-0500, Shawn P. Garbett wrote:
newtype St a s = MkSt (s - (a, s))
instance Monad St where
This line should say
instance Monad (St a) where
because it is (St a) that is a Monad, not St by itself.
--
Edit this signature at
Shawn P. Garbett [EMAIL PROTECTED] wrote:
I'm trying to modify Richard Bird's state transformer. The example
in his book (_Introduction_to_Functional_Programming_using_Haskell_)
has State defined as a explicit type.
I.e. Here's the relevant snippet:
-- State transformer definition
[Moved to Haskell-Cafe]
Hello!
Cycles sure make it difficult to transform graphs in a pure non-strict
language. Cycles in a source graph require us to devise a way to mark
traversed nodes -- however we cannot mutate nodes and cannot even
compare nodes with a generic ('derived') equality
Btw: This has already been done, in GHC: see the ST module in GHC's
library
http://www.haskell.org/ghc/docs/latest/html/base/Control.Monad.ST.html.
This list is great. The implementation in the ST module solves the problem
and I understand how it works.
Shawn
--
You're in a maze of
G'day all.
I have a large number of functions all of which use the same set
of type constraints, such as:
foo :: (Monad m, Ord t, Show t) = ...
Ideally, I'd like to combine them into one typeclass. At the moment,
I'm using the equivalent of:
class (Monad m, Ord t, Show t) =