Re: [Haskell-cafe] More documentation: how to create a Haskell project

2006-10-30 Thread Ketil Malde
[EMAIL PROTECTED] (Donald Bruce Stewart) writes:

 But we could do with more information on:
   [...]

How to make cabal projects into distribution-specific (.deb, .rpm, and
so on) packages? 

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] mapAccumL - find max in-sequence subsequence

2006-10-30 Thread Ross Paterson
It's a pity that groupBy isn't defined a little differently:

-- @'groupBy' rel xs@ returns the shortest list of lists such that
--
-- * the concatenation of the lists is @xs@, and
--
-- * @rel@ is 'True' for each consecutive pair of elements in a sublist.
--
groupBy :: (a - a - Bool) - [a] - [[a]]
groupBy rel []  =  []
groupBy rel (x:xs)  =  (x:ys) : groupBy rel zs
  where (ys,zs) = groupByAux x xs
groupByAux x0 (x:xs) | rel x0 x = (x:ys, zs)
  where (ys,zs) = groupByAux x xs
groupByAux y xs = ([], xs)

That's equivalent to the existing definition if rel is symmetric and
transitive, but also useful in other cases, e.g. groupBy (=) would
generate a list of runs, and the solution to the problem here would be

longestInSequence :: (Enum a, Eq a) = [a] - Int
longestInSequence = maximum . map length . groupBy adjacent
  where adjacent x y = succ x == y

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Deriving class instances using DrIFT

2006-10-30 Thread Einar Karttunen
On 29.10 19:56, John Meacham wrote:
 Since DrIFT can only understand haskell source code, it can't derive
 instances for anything you don't have the original source to. such as
 things in the pre-compiled libraries that come with ghc. you will likely
 have to write out those instances by hand. 
 
 Another possibility is that you could replicate just the data
 declarations by hand, and use DrIFT -r to just spit out the derivations
 and put those in a file on their own.

How about using Template Haskell for getting the definition and then
giving that to DrIFT?

- Einar Karttunen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] More documentation: how to create a Haskell project

2006-10-30 Thread Antti-Juhani Kaijanaho
Ketil Malde wrote:
 How to make cabal projects into distribution-specific (.deb, .rpm, and
 so on) packages? 

The answer for .debs is: ask a Debian developer (or a prospective
developer) to package it for you.

The reason is that to make a good .deb, one needs to be familiar with a lot
of Debian-specific policies and technologies.  If one is willing to invest
the time and effort to learn this, then it makes sense for one to apply to
become a Debian developer.  If not, then packaging is best left for someone
else.

-- 
Antti-Juhani Kaijanaho, Debian developer
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] More documentation: how to create a Haskell project

2006-10-30 Thread Andrea Rossato
On Mon, Oct 30, 2006 at 09:54:08AM +0100, Ketil Malde wrote:
 How to make cabal projects into distribution-specific (.deb, .rpm, and
 so on) packages? 

for slackware you can have a look to this slackBuild script:
http://gorgias.mine.nu/repos/slackBuild/hxt/hxt/hxt.SlackBuild

regards,
andrea
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] More documentation: how to create a Haskell project

2006-10-30 Thread David House

On 30/10/06, Tony Morris [EMAIL PROTECTED] wrote:

4) If you want links to base libraries in your haddock output, do such
and such (how do you do that anyway?)


I believe you need a local copy of the library sources, whose path you
give to haddock with some flag.

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] More documentation: how to create a Haskell project

2006-10-30 Thread Bulat Ziganshin
Hello Tony,

Monday, October 30, 2006, 6:22:31 AM, you wrote:

 My suggestion:
 The steps of reasoning as you start with a blank directory.
 For example:

great idea! i'm sure that such sort of manual will be very helpful for
anyone starting his first haskell project

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Simple GADT parser for the eval example

2006-10-30 Thread Greg Buchholz
I'm trying to create a simple parser for the GADT evaluator from the
wobbly types paper, and I need a little help.  Here's the GADT and the
evaluator...

 data Term a where
 Lit  :: Int - Term Int
 Inc  :: Term Int - Term Int
 IsZ  :: Term Int - Term Bool
 If   :: Term Bool - Term a - Term a - Term a
 Pair :: Term a - Term b - Term (a,b)
 Fst  :: Term (a,b) - Term a
 Snd  :: Term (a,b) - Term b 
   
 eval :: Term a - a
 eval (Lit i)= i
 eval (Inc t)= eval t + 1
 eval (IsZ t)= eval t == 0
 eval (If b t e) = if eval b then eval t else eval e
 eval (Pair a b) = (eval a, eval b)
 eval (Fst t)= fst (eval t)
 eval (Snd t)= snd (eval t)
 

...and instead of writing my own read instance, I thought I'd take a
shortcut and just try converting a regular data type to our generalized
one...

 data Expr = ELit Int
   | EInc Expr
   | EIsZ Expr 
   | EPair Expr Expr
   | EIf Expr Expr Expr
   | EFst Expr
   | ESnd Expr
 deriving (Read,Show)
 
 my_read' :: Expr - Term a 
 my_read' (ELit a) = Lit a
 my_read' (EInc a) = Inc (my_read' a)
 my_read' (EIsZ a) = IsZ (my_read' a)
 my_read' (EPair a b) = Pair (my_read' a) (my_read' b)
 my_read' (EIf p t e) = If (my_read' p) (my_read' t) (my_read' e)
 my_read' (EFst a) = Fst (my_read' a)
 my_read' (ESnd a) = Snd (my_read' a)

...That looks nice and simple, but it doesn't type check.  GHCi-6.6
complains...

Couldn't match expected type `a' (a rigid variable)
   against inferred type `Int'
  `a' is bound by the type signature for `my_read'
at eval_gadt_wobbly.hs:45:24
  Expected type: Term a
  Inferred type: Term Int
In the expression: Lit a
In the definition of `my_read': my_read (ELit a) = Lit a

...No surprise there, since there is no way to fail in the event of a
maltyped Expr.  The next thing to try is a type class solution... 

 class MyRead a where
 my_read :: Expr - Term a 
 
 instance MyRead Int where
 my_read (ELit a) = Lit a
 my_read (EInc a) = Inc (my_read a)
 my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e)
 my_read (EFst a) = Fst (my_read a :: MyRead b = Term (Int,b))
 --my_read (ESnd a) = Snd (my_read a) 
 instance MyRead Bool where
 my_read (EIsZ a) = IsZ (my_read a)
 my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e)
 --my_read (EFst a) = Fst (my_read a)
 --my_read (ESnd a) = Snd (my_read a)
 instance (MyRead a, MyRead b) = MyRead (a,b) where
 my_read (EPair a b) = Pair (my_read a) (my_read b)
 my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e)
 --my_read (EFst a) = Fst (my_read a)
 --my_read (ESnd a) = Snd (my_read a)

This just about works, except for the definitions for the Fst and
Snd constructors.  The compiler complains...

Ambiguous type variable `b' in the constraint:
  `MyRead b'
arising from use of `my_read' at eval_gadt_wobbly.hs:65:28-36
Probable fix: add a type signature that fixes these type variable(s)

...Of course, that makes perfect sense, since, if we're applying Fst
to a term, then we don't care about the other branch of the Pair.  You
can get it accepted by the type checker by making the types more
concrete...

my_read (EFst a) = Fst (my_read a :: Term (Int,Int))
...or...
my_read (EFst a) = Fst (my_read a :: Term (Int,Bool))

...but how does a person fix this to work in the more general case?  Or
is this even the right way to build a parser for the GADT evaluator
example?  Notice the repetition needed: the If, Fst, and Snd
defintions have to be copied to all three instances.  Also, feel free to
comment on this example, and the fact that it will evaluate with no
problems.

 static_vs_laziness = eval (my_read (EIf (EIsZ (ELit 0))
(ELit 9)
(EIsZ (ELit 42)))::Term Int)


Thanks,

Greg Buchholz

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] monadic performance

2006-10-30 Thread Chad Scherrer

On 10/28/06, Tomasz Zielonka [EMAIL PROTECTED] wrote:

On Fri, Oct 27, 2006 at 06:28:58AM -0700, Chad Scherrer wrote:
 Should I expect a monadic version to take a performance hit? What if I
 use some SPECIALIZE pragmas or somesuch? Is it more efficient to write
 one from scratch, or do specific type annotations give me the same
 thing anyway?


That's good to hear, thanks!

At this point my biggest concern is whether the strict parts and lazy
parts will play nice. Everything about my data structure is strict,
and thinking about how a Writer monad would interact with that just
makes me confused, so far.

-Chad
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Deriving class instances using DrIFT

2006-10-30 Thread Daniel McAllansmith
On Monday 30 October 2006 22:18, Einar Karttunen wrote:
 On 29.10 19:56, John Meacham wrote:
  Since DrIFT can only understand haskell source code, it can't derive
  instances for anything you don't have the original source to. 

Ahhh, ok.

  such as 
  things in the pre-compiled libraries that come with ghc. you will likely
  have to write out those instances by hand.

Hmmm, seems strange that it can successfully derive for the Data.Maybe type 
but not the Data.Word32 type.  I didn't think it would have access to any 
original source from my ghc install, there only seems to be hi files.

 
  Another possibility is that you could replicate just the data
  declarations by hand, and use DrIFT -r to just spit out the derivations
  and put those in a file on their own.

 How about using Template Haskell for getting the definition and then
 giving that to DrIFT?


Thanks for the suggestions.
Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Accumulating related XML nodes using HXT

2006-10-30 Thread Daniel McAllansmith
Hello.

I have some html from which I want to extract records.  
Each record is represented within a number of tr nodes, and all records tr 
nodes are contained by the same parent node.

The things I've tried so far end up giving me the cartesian product of record 
fields, so for the html fragment included below I'd end up with:

[ Prod Television 17 /prod17 A very nice telly.
, Prod Television 17 /prod17 Mind your fillings.
, Prod Cyclotron 24 /prod24 A very nice telly.
, Prod Cyclotron 24 /prod24 Mind your fillings.
]

instead of:

[ Prod Television 17 /prod17 A very nice telly.
, Prod Cyclotron 24 /prod24 Mind your fillings.
]


How should I go about accumulating related tr nodes into individual records?


Thanks
Daniel


HTML fragment follows:

...
tr
  tr
tdstrongProduct:/strong/td
tdstronga href=/prod17Television/a/strong (code: 17)/td
  /tr
  tr
tdstrongDescription:/strong/td
tdA very nice telly./td
  /tr

  tr
tdhr color=#0/td
  /tr

  tr
tdstrongProduct:/strong/td
tdstronga href=/prod24Cyclotron/a/strong (code: 24)/td
  /tr
  tr
tdstrongDescription:/strong/td
tdMind your fillings./td
  /tr

  tr
tdhr color=#0/td
  /tr
/tr
...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Deriving class instances using DrIFT

2006-10-30 Thread John Meacham
On Tue, Oct 31, 2006 at 07:46:05AM +1300, Daniel McAllansmith wrote:
 Hmmm, seems strange that it can successfully derive for the Data.Maybe type 
 but not the Data.Word32 type.  I didn't think it would have access to any 
 original source from my ghc install, there only seems to be hi files.

It has a few data definitions built into it. Bool,Maybe,Either, and
Ordering. 

see src/PreludData.hs for how that is done. 

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Simple GADT parser for the eval example

2006-10-30 Thread John Meacham
I don't have an answer, but would be extremely interested in knowing
one!

one of my first attempts to use GADTs was to do something similar,
implemening the simple polymorphic lambda calculus in a way that
transformations could be guarenteed typesafe statically, but then when I
went and tried to write an interpreter, I couldn't figure out how to
read in programs to interpret.

it seems you would want something like first class existentials 'Exp
(exists a . a)' or something like that.

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Simple GADT parser for the eval example

2006-10-30 Thread Joost Visser

Hi Greg,

We've built some GADT parsers recently to fit our two-level  
transformation library with front-ends for for XML Schema and SQL.  
See Coupled Schema Transformation and Data Conversion For XML and  
SQL (PADL 2007) if you're interested. The trick is to use a  
constructor in which the a variable of Term a is existentially  
quantified. For example:



data DynTerm where
  DynTerm :: Type a - Term a - DynTerm


(I'm using GADT notation here, but normal ADT syntax would do just  
fine as well.)

The first argument is the folklore GADT for representing types:


data Type a where
  Int :: Type Int
  Bool :: Type Bool
  Prod :: Type a - Type b - Type (a,b)


Then you can write your parser function with the following type:


my_read' :: Expr - DynTerm


Or, more likely:


my_read' :: Expr - Maybe DynTerm


with:


my_read' (ELit a)= return $ DynTerm Int (Lit a)
my_read' (EInc a)= do
  DynTerm Int a' - my_read' a
  return (DynTerm Int (Inc a'))


Then you call eval something like:


test :: Expr - Maybe Dynamic
test expr = do
  DynTerm t a - my_read' expr
  return (Dyn t (eval a))


The Dynamic is defined as:


data Dynamic where
  Dyn :: Type a - a - Dynamic


The dynamic typing trick here is due to Swierstra and Baars.
For further processing of the Dynamic result, you'll need to write  
functions with a type like:



f :: Type a - a - X


A typical example:


gshow :: Type a - a - String
gshow Int i = show i
gshow Bool b = show b
gshow (Prod a b) (x,y) = (++gshow a x++,++gshow b y++)


Hope this helps.

Source code is attached.

Best,
Joost


On Oct 30, 2006, at 5:00 PM, Greg Buchholz wrote:

I'm trying to create a simple parser for the GADT evaluator  
from the

wobbly types paper, and I need a little help.  Here's the GADT and the
evaluator...



data Term a where
Lit  :: Int - Term Int
Inc  :: Term Int - Term Int
IsZ  :: Term Int - Term Bool
If   :: Term Bool - Term a - Term a - Term a
Pair :: Term a - Term b - Term (a,b)
Fst  :: Term (a,b) - Term a
Snd  :: Term (a,b) - Term b

eval :: Term a - a
eval (Lit i)= i
eval (Inc t)= eval t + 1
eval (IsZ t)= eval t == 0
eval (If b t e) = if eval b then eval t else eval e
eval (Pair a b) = (eval a, eval b)
eval (Fst t)= fst (eval t)
eval (Snd t)= snd (eval t)




...and instead of writing my own read instance, I thought I'd take a
shortcut and just try converting a regular data type to our  
generalized

one...



data Expr = ELit Int
  | EInc Expr
  | EIsZ Expr
  | EPair Expr Expr
  | EIf Expr Expr Expr
  | EFst Expr
  | ESnd Expr
deriving (Read,Show)

my_read' :: Expr - Term a
my_read' (ELit a) = Lit a
my_read' (EInc a) = Inc (my_read' a)
my_read' (EIsZ a) = IsZ (my_read' a)
my_read' (EPair a b) = Pair (my_read' a) (my_read' b)
my_read' (EIf p t e) = If (my_read' p) (my_read' t) (my_read' e)
my_read' (EFst a) = Fst (my_read' a)
my_read' (ESnd a) = Snd (my_read' a)



...That looks nice and simple, but it doesn't type check.  GHCi-6.6
complains...

Couldn't match expected type `a' (a rigid variable)
   against inferred type `Int'
  `a' is bound by the type signature for `my_read'
at eval_gadt_wobbly.hs:45:24
  Expected type: Term a
  Inferred type: Term Int
In the expression: Lit a
In the definition of `my_read': my_read (ELit a) = Lit a

...No surprise there, since there is no way to fail in the event of a
maltyped Expr.  The next thing to try is a type class solution...



class MyRead a where
my_read :: Expr - Term a

instance MyRead Int where
my_read (ELit a) = Lit a
my_read (EInc a) = Inc (my_read a)
my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e)
my_read (EFst a) = Fst (my_read a :: MyRead b = Term (Int,b))
--my_read (ESnd a) = Snd (my_read a)instance MyRead Bool where
my_read (EIsZ a) = IsZ (my_read a)
my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e)
--my_read (EFst a) = Fst (my_read a)
--my_read (ESnd a) = Snd (my_read a)
instance (MyRead a, MyRead b) = MyRead (a,b) where
my_read (EPair a b) = Pair (my_read a) (my_read b)
my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e)
--my_read (EFst a) = Fst (my_read a)
--my_read (ESnd a) = Snd (my_read a)



This just about works, except for the definitions for the Fst  
and

Snd constructors.  The compiler complains...

Ambiguous type variable `b' in the constraint:
  `MyRead b'
arising from use of `my_read' at eval_gadt_wobbly.hs:65:28-36
Probable fix: add a type signature that fixes these type  
variable(s)


...Of course, that makes perfect sense, since, if we're applying Fst
to a term, then we don't care about the other branch of the  
Pair.  You

can get it accepted by the type checker by making the types more
concrete...

my_read (EFst a) = Fst (my_read a :: Term (Int,Int))
...or...
my_read (EFst a) = Fst (my_read a :: 

Re: [Haskell-cafe] Simple GADT parser for the eval example

2006-10-30 Thread Dimitrios Vytiniotis

Just noticed Joost Visser's message but since I
had (essentially a very similar) response I thought I might
send it off as well ... It includes the conditional cases.

Regards,
-d


{-# OPTIONS_GHC -fglasgow-exts #-}

module Main where

data Term a where
Lit  :: Int - Term Int
Inc  :: Term Int - Term Int
IsZ  :: Term Int - Term Bool
If   :: Term Bool - Term a - Term a - Term a
Pair :: Term a - Term b - Term (a,b)
Fst  :: Term (a,b) - Term a
Snd  :: Term (a,b) - Term b

data Expr = ELit Int
  | EInc Expr
  | EIsZ Expr
  | EPair Expr Expr
  | EIf Expr Expr Expr
  | EFst Expr
  | ESnd Expr
deriving (Read,Show)

-- Give a GADT for representation types
data R a where
  Rint :: R Int
  Rbool :: R Bool
  Rpair :: R a - R b - R (a,b)

-- Give an existential type with a type representation
data TermEx where
  MkTerm :: R a - Term a - TermEx

-- we use Weirich's higher-order type-safe cast to avoid deep traversals
-- one can replace the type_cast with a more simple traversal-based
-- version.

data CL c a d = CL (c (d,a))
data CR c a d = CR (c (a,d))

type_cast :: forall a b c. R a - R b - c a - c b
type_cast Rint Rint x = x
type_cast Rbool Rbool x = x
type_cast (Rpair (ra::(R a0)) (rb::(R b0)))
(Rpair (ra'::(R a0')) (rb'::(R b0'))) x =
let g = (type_cast ra ra' :: ( (CL c b0)  a0 - (CL c b0) a0' ))
h = (type_cast rb rb' :: ( (CR c a0') b0 - (CR c a0') b0'))
in case (g (CL x)) of
 CL x' - case (h (CR x')) of
CR y' - y'
type_cast _ _ _  = error cannot cast!


-- give only the cases for Eif and Elit, the others are similar
my_read :: Expr - TermEx
my_read (ELit i) = MkTerm Rint (Lit i);
my_read (EIf p t e) =
case (my_read p) of
  MkTerm rb b -
  case rb of
Rbool -
   case (my_read t) of
 MkTerm r1 t1 -
   case (my_read e) of
 MkTerm r2 t2 -
MkTerm r2 (If b (type_cast r1 r2 t1) t2)
_ - error conditional not boolean!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] YAHT: searchAll5

2006-10-30 Thread Magnus Therning
I can't get searchAll5[1] in Yet Another Haskell Tutorial to run.  Ghci
complains that it can't find a MonadPlus that satisfies the required
type; it needs a MonadPlus.

I suspect this is due to the use of 'mzero' and 'mplus', without making
StateT a MonadPlus.  My thought for this was to push mzero into the
inner monad and have 'mplus' pass on to the inner monad:

  instance Monad m = MonadPlus (StateT state m) where
  mzero = StateT (\s - return (s, mzero))
  (StateT m1) `mplus` (StateT m2) = StateT (\s - do
  (s1, a) - m1 s
  (s2, b) - m2 s1
  return (s2, a `mplus` b))

What's above isn't accepted by ghci, and I don't even know for sure that
my thought makes sense.

/M

[1]: http://en.wikibooks.org/wiki/Haskell/YAHT/Monads#Monad_Transformers

-- 
Magnus Therning (OpenPGP: 0xAB4DFBA4)
[EMAIL PROTECTED] Jabber: [EMAIL PROTECTED]
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Finagle's Fifth Law:
Always draw your curves, then plot your readings.


pgpCi3BAvGSwu.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] YAHT: searchAll5

2006-10-30 Thread Nicolas Frisby

Disclaimer: I've never read through YAHT, so I don't know if I'm
missing any context...

Your intuition was correct: you do want to lift the MonadPlus property
through the StateT transformer. This is the key to the transformer
libraries, each transformer both contributes a computational feature
(MonadState, MonadReader, MonadPlus, MonadError, ...) as well as
maintains all features of the monad it's transforming.

You've noticed that we need an instance in order to have the StateT
monad transformer maintain the MonadPlus property of its inner monad.

Beyond the encouragement that your intuition was dead on, I would
suggest tryng to use mzero and mplus sooner than you are doing so. In
other words, your method defintions should be simpler.

Good luck!
Nick

On 10/30/06, Magnus Therning [EMAIL PROTECTED] wrote:

I can't get searchAll5[1] in Yet Another Haskell Tutorial to run.  Ghci
complains that it can't find a MonadPlus that satisfies the required
type; it needs a MonadPlus.

I suspect this is due to the use of 'mzero' and 'mplus', without making
StateT a MonadPlus.  My thought for this was to push mzero into the
inner monad and have 'mplus' pass on to the inner monad:

  instance Monad m = MonadPlus (StateT state m) where
  mzero = StateT (\s - return (s, mzero))
  (StateT m1) `mplus` (StateT m2) = StateT (\s - do
  (s1, a) - m1 s
  (s2, b) - m2 s1
  return (s2, a `mplus` b))

What's above isn't accepted by ghci, and I don't even know for sure that
my thought makes sense.

/M

[1]: http://en.wikibooks.org/wiki/Haskell/YAHT/Monads#Monad_Transformers

--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
[EMAIL PROTECTED] Jabber: [EMAIL PROTECTED]
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Finagle's Fifth Law:
Always draw your curves, then plot your readings.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe