
Hi, Formerly, I had IORef and some state monad to do the task of keeping states. Now in haskell 2010, I cannot find anything about it. Do I have to use ghc base package for this function? -- 竹密岂妨流水过 山高哪阻野云飞

On Wed, 08 Dec 2010 10:03:40 +0100, Magicloud Magiclouds
Hi, Formerly, I had IORef and some state monad to do the task of keeping states. Now in haskell 2010, I cannot find anything about it. Do I have to use ghc base package for this function?
These are not standard Haskell '98 or Haskell 2010. You can find IORef in the base package; the state monad is in both the mtl and the transformers package (mtl is deprecated). The state monad uses the multi-parameter type class extension and is therefore not in standard Haskell '98 or Haskell 2010 code. IORef also uses non-standard code. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --

On Wed, Dec 8, 2010 at 6:46 PM, Henk-Jan van Tuyl
On Wed, 08 Dec 2010 10:03:40 +0100, Magicloud Magiclouds
wrote: Hi, Formerly, I had IORef and some state monad to do the task of keeping states. Now in haskell 2010, I cannot find anything about it. Do I have to use ghc base package for this function?
These are not standard Haskell '98 or Haskell 2010. You can find IORef in the base package; the state monad is in both the mtl and the transformers package (mtl is deprecated). The state monad uses the multi-parameter type class extension and is therefore not in standard Haskell '98 or Haskell 2010 code. IORef also uses non-standard code.
Regards, Henk-Jan van Tuyl
-- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --
First to notice that. So standard-wise, there is no way to do state thing? -- 竹密岂妨流水过 山高哪阻野云飞

On 10 December 2010 01:40, Magicloud Magiclouds
On Wed, Dec 8, 2010 at 6:46 PM, Henk-Jan van Tuyl
wrote: On Wed, 08 Dec 2010 10:03:40 +0100, Magicloud Magiclouds
wrote: Hi, Formerly, I had IORef and some state monad to do the task of keeping states. Now in haskell 2010, I cannot find anything about it. Do I have to use ghc base package for this function?
These are not standard Haskell '98 or Haskell 2010. You can find IORef in the base package; the state monad is in both the mtl and the transformers package (mtl is deprecated). The state monad uses the multi-parameter type class extension and is therefore not in standard Haskell '98 or Haskell 2010 code. IORef also uses non-standard code.
Regards, Henk-Jan van Tuyl
-- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --
First to notice that. So standard-wise, there is no way to do state thing?
It's not hard to create your own state monad. You are right, though, that there is no standard library support for this in the Haskell2010 standard. -- Push the envelope. Watch it bend.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 12/9/10 20:40 , Magicloud Magiclouds wrote:
First to notice that. So standard-wise, there is no way to do state thing?
There seems to be a lot of confusion as to what the language standard covers. It is a bare minimum; practical libraries are not part of its purview, but only the minimum needed to make implementing practical libraries possible. This includes some baked-in assumptions: for example, the "do" construct requires that the Monad typeclass support a "fail" method, numeric literals require the Num typeclass to support a "fromIntegral" method, etc., and since you can't extend typeclasses after definition that means Num and Monad are overspecified compared to other types in the language standard. Take a look at the Haskell Platform for a practical compiler-and-libraries standard. - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0EI/IACgkQIn7hlCsL25Xc1wCgi9saZgo9h4RScI+ZAyR843sG eHoAn2J7Yfn664oaL1zAEZxQDLCat04k =SDlV -----END PGP SIGNATURE-----

Henk-Jan van Tuyl schrieb:
On Wed, 08 Dec 2010 10:03:40 +0100, Magicloud Magiclouds
wrote: Hi, Formerly, I had IORef and some state monad to do the task of keeping states. Now in haskell 2010, I cannot find anything about it. Do I have to use ghc base package for this function?
These are not standard Haskell '98 or Haskell 2010. You can find IORef in the base package; the state monad is in both the mtl and the transformers package (mtl is deprecated). The state monad uses the multi-parameter type class extension and is therefore not in standard Haskell '98 or Haskell 2010 code.
Since mtl is split into transformers (Haskell 98 compatible code) and the multi-parameter type classes in mtl-2/monad-fd, you can use the State monad in Haskell 98 and Haskell 2010 code.
participants (6)
-
Brandon S Allbery KF8NH
-
Henk-Jan van Tuyl
-
Henning Thielemann
-
Johan Tibell
-
Magicloud Magiclouds
-
Thomas Schilling