
Hello, I'm trying to define a partition__ function that is like Data.Set.partition, but use State Monad:
import Data.Set import Control.Monad.State
partition__ f = do snapshot <- get let (firsts, rest) = Set.partition f snapshot put rest return firsts
When I try to infer it's type in ghci I got: $ ghci ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. Prelude> :load partition.hs [1 of 1] Compiling Main ( partition.hs, interpreted ) Ok, modules loaded: Main. *Main> :type partition__ partition__ :: (MonadState (Set a) t, Ord a) => (a -> Bool) -> t (Set a) Ok, then I add
partition__ :: (MonadState (Set a) t, Ord a) => (a -> Bool) -> t (Set a)
to the file and then: *Main> :reload [1 of 1] Compiling Main ( partition.hs, interpreted ) partition.hs:4:0: Non type-variable argument in the constraint: MonadState (Set a) t (Use -fglasgow-exts to permit this) In the type signature for `partition__': partition__ :: (MonadState (Set a) t, Ord a) => (a -> Bool) -> t (Set a) Failed, modules loaded: none. Why do I need glasgow-exts to specify a type infered by GHCi without -fglasgow-exts? Thanks. -- malebria Marco Túlio Gontijo e Silva Correio (MSN): malebria@riseup.net Jabber (GTalk): malebria@jabber.org Ekiga: malebria@ekiga.net IRC: malebria@irc.freenode.net malebria@irc.oftc.org Skype: marcotmarcot Telefone: 33346720 Celular: 98116720 Endereço: Rua Paula Cândido, 257/201 Gutierrez 30430-260 Belo Horizonte/MG Brasil