Re: [Haskell-cafe] Different answers on different machines

2013-06-02 Thread Henry Laxen
Gregory Collins greg at gregorycollins.net writes:

 
 On Sat, Jun 1, 2013 at 7:55 PM,  nadine.and.henry at pobox.com wrote:
 Yesterday I decided to take a look at the most recent Euler problem,
 number 249, and give it a shot.  I have a couple of computers at home,
 a Dell laptop and a desktop.  I compiled this message with ghc -O2
 --make ex429.lhs and ran it on each machine.  On the Dell I get:
 
 Odds are good it's integer overflow. Change Int to Integer or Int64 and 
retry.G-- Gregory Collins greg at gregorycollins.net
 

Yes, that was it.  The dell was a 32 bit system, and the desktop a 64.  I 
changed everything from Int to Integer, and now both agree.  Thanks for the 
pointer.
Best wishes,
Henry Laxen


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


[Haskell-cafe] Combining State and List Monads

2012-08-24 Thread Henry Laxen
Dear Cafe,

It seems to me there should be some simple way of doing this, but thus
far it eludes me.  I am trying to combine the State and List monads to
do the following:

countCalls = do
  a - [1..2]
  b - [1..2]
  modify (+1)
  return (a,b)


where with some combination of ListT, StateT, List, State, or who
knows what would result in:

([(1,1),(1,2),(2,1),(2,2)],4)

assuming we initialize the state to 0

Is there any way to make this happen?
Thanks in advance.

Henry Laxen



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


[Haskell-cafe] Beginning Data.Lens tutorial

2011-12-10 Thread Henry Laxen
Dear Group,

If you haven't used lenses before, (as I hadn't until recently) you may find 
this helpful:

http://www.nadineloveshenry.com/haskell/lensExamples.html

Best wishes,
Henry Laxen



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


[Haskell-cafe] deepseq-1.2.0.1 missing Data.Map instance

2011-11-15 Thread Henry Laxen
Dear Group,

Today I tried to compile snap 0.6 with ghc 7.2, (using virthualenv,
which is GREAT by the way) and got the following
error somewhere along the way got a message about aeson-native
requires deepseq-1.1.0.2 but I had deepseq-1.2.0.1 installed.  So I
unpacked aeson-native-0.3.3.1 in my virthualenv and changed the
build-depends to just deepseq which caused:

Configuring aeson-native-0.3.3.1...
Preprocessing library aeson-native-0.3.3.1...
Building aeson-native-0.3.3.1...
[2 of 6] Compiling Data.Aeson.Types ( Data/Aeson/Types.hs, 
dist/build/Data/Aeson/Types.o )

Data/Aeson/Types.hs:196:22:
No instance for (NFData Object)
  arising from a use of `rnf'
Possible fix: add an instance declaration for (NFData Object)
In the expression: rnf o
In an equation for `rnf': rnf (Object o) = rnf o
In the instance declaration for `NFData Value'
cabal: Error: some packages failed to install:
aeson-native-0.3.3.1 failed during the building phase. The exception was:
ExitFailure 1


A little investigating and I discovered that

instance (NFData k, NFData a) = NFData (Data.Map.Map k a) where
rnf = rnf . Data.Map.toList


is in deepseq-1.1.0.2 but not in deepseq-1.2.0.1.  Adding it back got
aeson-native-0.3.3.1 and later snap-0.6 to compile just fine.  So I
guess my question is:  Is there a reason that the map instance was
removed from deepseq-1.2.0.1, and can we please put it back in?
Thanks.

Best wishes,
Henry Laxen



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


Re: [Haskell-cafe] deepseq-1.2.0.1 missing Data.Map instance

2011-11-15 Thread Henry Laxen
Daniel Fischer daniel.is.fischer at googlemail.com writes:

 For your unfortunate combination, consider reverting to a prior deepseq 
 version, or manually provide the instance where needed (I recommend the 
 former).
 

Thank you Daniel, for clearing that up.
Best wishes,
Henry Laxen



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


[Haskell-cafe] which tags program should I use?

2011-09-25 Thread Henry Laxen
Dear Group,

I have a simple question, that as far as I can tell, has never really
been well answered.  I would like to generate TAGS files for haskell
source.  Reading the http://www.haskell.org/haskellwiki/Tags page
suggests using :etags in GHCI or hasktags, or gasbag.  Of the three,
hasktags comes closest to working but it has (for me) a major
inconvenience, namely it finds both function definitions and type
signatures, resulting in two TAGS entries such as:

./Main.hs,63
module Main where6,7
main ::24,25
main =25,26

Now when I do an emacs find-tag (I use icicles) I will always have to
choose which tag I want to visit, and the completion buffer contains
something like:

main ::
hs/Main.hs

main =
hs/Main.hs


Granted, this is a minor (and very specialized) complaint, but if
hasktags were to select only ONE of either the type signature (my
first choice) or the function definition, (if no type signature) this
annoyance would disappear.  

I also tried using etags, which I think would work, but it seems to
have one killer bug (feature), namely that it dies if it finds an
uninterpreted import:

  when (not is_interpreted) $
let mName = GHC.moduleNameString (GHC.moduleName m) in
ghcError (CmdLineError (module ' ++ mName ++ ' is not interpreted))

I think it would work much better if it just warned you, instead of
dying.  This makes it unusable any time you import something
precompiled.

Now some looking at the README of hasktags leads me to:

In the past this tool was distributed with ghc. I forked and added some
features.  hasktags itself was moved out of the ghc repository. Then I only
verified that my fork finds at least as much tags as the one forked by
Igloo.

That makes me feel a little queasy.

A google search for hasktags igloo turns up
http://hackage.haskell.org/trac/ghc/ticket/1508 
whose title is hasktags program needs replacement
which makes me feel even more queasy.

So I guess my question is, what are us disciples of the one true
editor to do?  Thanks in advance for you sage advice.

Best wishes,
Henry Laxen




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


[Haskell-cafe] Problems installing the haskell platform

2011-01-19 Thread Henry Laxen
Dear Group,

Greetings.  I've been using haskell for about a year now, though I
will readily admit I still don't really know what I am doing when I
get error messages.  Today I decided to reset my haskell environment
from scratch, avoiding the debian packages and going straight to the
source.



1. Install ghc from http://www.haskell.org/ghc/download_ghc_6_12_3

Success!!

ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.3

cabal update
Downloading the latest package list from hackage.haskell.org

2. Next I downloaded the haskell platform and ran cabal install
Problems!!

cabal: Error: some packages failed to install:
haskell-platform-2010.2.0.0 depends on stm-2.1.2.1 which failed to
install.
stm-2.1.2.1 failed during the building phase. The exception was:
ExitFailure 1

3. So I tried installing stm manually, which for some unknown reason
worked:

runghc Setup.hs install
Installing library in /usr/local/lib/stm-2.1.2.1/ghc-6.12.3
Registering stm-2.1.2.1...

4. back to the haskell-platform directory and try again:

cabal install
Resolving dependencies...
Configuring haskell-platform-2010.2.0.0...
setup: happy version ==1.18.5 is required but the version found at
/usr/local/bin/happy is version 1.18.6
cabal: Error: some packages failed to install:
haskell-platform-2010.2.0.0 failed during the configure step. The
exception
was:
ExitFailure 1

5. Crap.  Okay, maybe it will work with version 1.18.6 after all, so I
edit the .cabal and change happy ==1.18.5 to happy =1.18.5

  -- Depending on programs does not work, they are not registered
  -- We list them to help distro packaging.
  build-tools:
cabal-install ==0.8.2,
alex  ==2.3.3,
happy =1.18.5
-- haddock   ==2.7.2 -- valid, but needs ghc-paths

6. Try again

cabal install
Resolving dependencies...
Configuring haskell-platform-2010.2.0.0...
Preprocessing library haskell-platform-2010.2.0.0...
Building haskell-platform-2010.2.0.0...
Registering haskell-platform-2010.2.0.0...
Installing library in /usr/local/lib/haskell-platform-2010.2.0.0/
ghc-6.12.3
Registering haskell-platform-2010.2.0.0...

7. Success!!

Now even though I'm not sure what I am doing, it looks like it may
have worked.  I'm worried, though, about the first time user who tries
to go through this process.  They will probably stop at the first
error, when the haskell-platform fails to install.

I know some of you will say use the debian packages.  Well I did that,
but when I tried to install snap, which is not included in the debian
packages, I wound up with conflicting dependencies, and could not find
a way out.  I hope this dialog is helpful to whomever is in charge of
the haskell platform, a wonderful resource by the way.

Best wishes,
Henry Laxen



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


Re: [Haskell-cafe] Problems installing the haskell platform

2011-01-19 Thread Henry Laxen

Dear Joachim,

Well, I got away with a lot of stuff, but as I said, when I tried to install 
snap via cabal-install, I could not break through the dependency jungle.  I 
believe the stumbling block was trying to install hint.  All of the debian 
packages installed just fine, but there is no debian package for snap, which I 
really wanted to try out.  

Best wishes,
Henry Laxen



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


[Haskell-cafe] Big Arrays

2010-10-03 Thread Henry Laxen
Dear Group,

I am trying to create a (relatively) big array, 
but it seems I cannot make anything larger 
than 2^30 or so.  Here is the code:

import Data.Word
import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Control.Exception
import Prelude hiding (catch)


t1 :: Word64 - UArray Word64 Bool
t1 size = runSTUArray 
  (do a - newArray (0,size) True
 :: ST s (STUArray s Word64 Bool)
  writeArray a 0 False
  return a)

catchArrayException x = do
  let err = show (x :: SomeException)
  putStrLn $ Exception [ ++ err ++ ]
  return ()   

main = do
  let a1 = t1 (2^30)
  a2 = t1 (2^31)
  a3 = t1 (2^32)
  catch (print $ (a1!0,a1!1)) catchArrayException
  catch (print $ (a2!0,a2!1)) catchArrayException
  catch (print $ (a3!0,a3!1)) catchArrayException
  

This results in:
*Main GOA main
(False,True)
(Exception [Negative range size]
(False,Exception [Error in array index; 1 not in range [0..1)]

It looks like array ranges can only be Ints, and not Int64 or Word64 types.  
Any pointers would be appreciated.
Best wishes,
Henry Laxen



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


[Haskell-cafe] Adding a field to a data record

2009-07-28 Thread Henry Laxen
Dear Group,

It seems to me this should be easy, but I can't quite figure out
how to do it without a lot of typing.  Here is the question:

Suppose you have a data type like:
Data Foo = Foo { a :: Int, b :: Int, 
   ... many other fields ... 
 y :: Int } deriving (Eq, Read, Show, Typeable, Data)

Now I would like to add a field z :: Int to the end of Foo.  If
I have a ton of data out on disk, which I wrote with, say
writeFile a.data (show foo) -- where foo is a [Foo] say 1000
long, I would like to get a new a.data file which has a new
z::Int field.

So far the only way I can think of is to make a new Data Foo1,
which includes the z::Int, read in a.data as a list of Foo,
write a function like:

fooTofoo1 :: Foo - Foo1
fooTofoo1 xx = Foo1 {a = a xx, ... y = y xx, z = 1}

then write the file back out, and perhaps use emacs to
query-replace all the Foo1's back to Foo's, add the z::Int field
back into Foo, and read it back.

Please tell me there is a better way.  Thanks in advance.
Best wishes, 
Henry Laxen

PS: 
I have read syb1, and syb2 a couple of times now, but so far
haven't been able to connect it with this kind of problem.




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


[Haskell-cafe] Re: Adding a field to a data record

2009-07-28 Thread Henry Laxen
Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk writes:

 
  and perhaps use emacs to
  query-replace all the Foo1's back to Foo's
 
 At least this bit can be avoided easily enough, by using
 module qualification during the conversion process.
 
  module Original (Foo(..)) where
  data Foo = Foo { ... y :: Int } deriving ...
 
  module New (Foo(..)) where
  data Foo = Foo { ... y, z :: Int } deriving ...
 
  module Convert where
  import Original as Old
  import New as New
  newFoo :: Old.Foo - New.Foo
  newFoo old{..} = New.Foo { a=a, b=b, ... z=1 }
 
 Finally rename module New.
 
 Regards,
  Malcolm
 

Thanks Malcolm, yes, that keeps me out of emacs, but the part I would really
like to avoid is writing the New.Foo { a=a, b=b, ... z=1 } part, where the field
names are many, long, and varied.  Yes, I could cut and paste, but I'm hoping
for a better way.  Thanks.
Best wishes,
Henry Laxen


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


[Haskell-cafe] Re: A Reader Monad Tutorial

2009-06-28 Thread Henry Laxen
Lee Duhem lee.duhem at gmail.com writes:

 Nice post.
 
 I didn't find how to add comments on your blog, so I post them here:
 
...


Dear Lee,

Thank you for your comments and corrections.  I have included all of them in the
new version of the article.
Best wishes,
Henry Laxen



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


[Haskell-cafe] A Reader Monad Tutorial

2009-06-27 Thread Henry Laxen
Dear Group,

If any of you are struggling with understanding monads, I've tried to put
together a pretty through explanation of what is behind the Reader monad.  If
you're interested, have a look at:

http://www.maztravel.com/haskell/readerMonad.html

Enjoy.
Henry Laxen


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


[Haskell-cafe] Hack (web) and apache configuration

2009-06-25 Thread Henry Laxen
Dear Group,

I am posting this here even though it probably belongs on the
apache list because I suspect other haskell users will be able to
find it here more easily.  I am playing around with hack, and am
having trouble with configuring apache with fastcgi to make
things work.  My understanding of the hack concept is that it
provides a stardardized interface that lets you glue together
web Applications.  It also provides several front-ends, such as
happs, and fastcgi etc.  Now based on looking at the Middleware
supplied with hack, it seems to be trying to dispatch based on
the contents of the pathInfo field of the Env record.  So, my
question is, how do we configure Apache2 with the fastcgi handler
so that something appears in the pathInfo field?

I have tried several things, the most recent being:

RewriteEngine on
RewriteRule ^/(.*)$ /hackTest?input=$1 [T=application/x-httpd-cgi]
Location /
SetHandler fastcgi-script
Options ExecCGI FollowSymLinks
/Location

but the pathInfo field is always null.  

Env {requestMethod = GET, scriptName = /lambda, pathInfo = , 
queryString = input=lambda, serverName = 127.0.0.1, serverPort = 80, 
http = [(FCGI_ROLE,RESPONDER),(SCRIPT_URL,/lambda),
(SCRIPT_URI,http://127.0.0.1/lambda;),(User-Agent,curl/7.18.2 
(x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8
libssh2/0.18),
(Host,127.0.0.1),(Accept,*/*),(PATH,/usr/local/bin:/usr/bin:/bin),
(SERVER_SIGNATURE,addressApache/2.2.9 (Debian) mod_fastcgi/2.4.6
proxy_html/3.0.0 mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0 Server at
127.0.0.1 Port 80/address\n),
(SERVER_SOFTWARE,Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 proxy_html/3.0.0
mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0),
(SERVER_NAME,127.0.0.1),(SERVER_ADDR,127.0.0.1),
(SERVER_PORT,80),(REMOTE_ADDR,127.0.0.1),
(DOCUMENT_ROOT,/home/henry/maztrave2/www/fcgi),
(SERVER_ADMIN,[no address given]),
(SCRIPT_FILENAME,/home/henry/maztrave2/www/fcgi/hackTest),
(REMOTE_PORT,44936),
(GATEWAY_INTERFACE,CGI/1.1),(SERVER_PROTOCOL,HTTP/1.1),
(REQUEST_METHOD,GET),(QUERY_STRING,input=lambda),
(REQUEST_URI,/lambda),(SCRIPT_NAME,/lambda)], 
hackVersion = [2009,5,19], hackUrlScheme = HTTP, hackInput = Empty, hackErrors =
HackErrors, hackHeaders = []}% 


I think what I want is to have all URLS, such as:

http://127.0.0.1/lambda

be dispatched though my hackTest executable, without having to go
through the rewrite, but I can't convice apache to do that.  In
the interest of completeness, my hackTest.hs file is the
following:

import Hack
import Hack.Handler.FastCGI
import Data.ByteString.Lazy.Char8 (pack)
import Hack.Contrib.Middleware.Lambda

app :: Application
app = \env -   return $ Response
{ status  = 200
, headers = [ (Content-Type, text/plain) ]
, body= pack $ show env
}

main = runFastCGIorCGI $ lambda app

--

One final comment to the authors of hack.  Would you please
consider renaming this project.  hack is such a common word that
has nothing to do with this project that it make searching the
web with google, etc. almost useless.  I realize it is a clever
respelling of the ruby version rack, but please consider naming
it something more unique, while it is still relatively new on the
web.

Thanks in advance for your help.
Best wishes,
Henry Laxen


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


[Haskell-cafe] Re: Hack (web) and apache configuration

2009-06-25 Thread Henry Laxen

Anton van Straaten anton at appsolutions.com writes:

 Path info is path-like data that directly follows the name of the 
 resource being referenced, e.g.: /myfiles/foo.html/this/is/path/info
 
 A rule that would give you path info in the case you describe would be 
 more like this:
 
RewriteRule ^/(.*)$ /hackTest/$1 [T=application/x-httpd-cgi]
 
 Whether that works depends on how /hackTest is being dispatched, but if 
 Hack expects pathinfo, then it may just work.
 
 Anton
 

Dear Anton,

Thank you, that works perfectly.  That's what I love about programming, just
change a single character, and the world goes from total chaos to perfect order.
 It reminds me of a saying I heard once.  If carpenters built houses the way
programmers write programs, you could walk into any house, remove any single
nail, and the structure would collapse into pieces no larger than toothpicks.

Thanks again.
Henry




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


[Haskell-cafe] Re: A generics question

2009-06-09 Thread Henry Laxen
Sterling Clover s.clover at gmail.com writes:

 
 Try it with the following type signature and it should work fine:
 
 convert :: (Data a) = Int - a - a
 
 Of course, as has been noted, SYB is a rather big sledgehammer for  
 the insect in question.
 
 Cheers,
 S.
 


Thank you Sterling.  That is the answer I was looking for.  I was trying out
things from the various Scrap your Boilerplate papers, and got stuck doing
something that I thought should be easy.  Now it makes sense.  Thanks again.
Best wishes,
Henry Laxen

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


[Haskell-cafe] A generics question

2009-06-08 Thread Henry Laxen
Lets suppose I have a file that has encoded things of different
types as integers, and now I would like to convert them back
into specific instances of a data type.  For example, I have a
file that contains 1,1,2,3 and I would like the output to be
[Red, Red, Green, Blue]. I also would like to do this
generically, so that if I wanted to convert the same list of
integers into say Sizes, I would get [Small, Small, Medium,
Large]  Now please have a look at the following code:

{-# LANGUAGE DeriveDataTypeable #-}
import Data.Generics
data Color = Red | Green | Blue deriving (Eq,Ord,Read,Show,Typeable,Data)
data Size  = Small | Mediaum | Large deriving (Eq,Ord,Read,Show,Typeable,Data)
g = Green

c = undefined :: Color
s = undefined :: Size

t = do
  print $   toConstr g  -- Green
  print $ dataTypeOf c  -- DataType {tycon = Main.Color, datarep = AlgRep
[Red,Green,Blue]}

convert :: (Data a, Data b) =Int -a -b
convert i x =
  let c = dataTypeConstrs (dataTypeOf x) !! (i-1)
  in fromConstr c


I would like to be able to say: x = convert 1 c and have it
assign Red to x then I would like to say: y = convert 1 s and
have it assign Small to y, however, when I try that I get:

Ambiguous type variable `b' in the constraint:
  `Data b' arising from a use of `convert' at interactive:1:8-18
Probable fix: add a type signature that fixes these type variable(s)

Of course if I say x :: Color = convert 1 c, it works, but I
would like to avoid that if possible, as all of the information
is already contained in the parameter c.  Is there any way to do
this?  Thanks in advance for your wise counsel.

Best wishes,
Henry Laxen


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


[Haskell-cafe] MySQL, CouchDB, and Haskell

2009-06-01 Thread Henry Laxen
Dear Group,

I've spent the last few days trying to convert a bunch of mysql tables into
couchdb using haskell, and I've documented my efforts, in case anyone else
intends to wander in similar waters.  The tutorial is at:

http://maztravel.com/haskell/mySqlToCouchDB.html

comments welcome here at the list or to me privately at
nadine.and.henry -AT- pobox.com

Best wishes,
Henry Laxen


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


[Haskell-cafe] Problem with prepose.lhs and ghc6.10.1

2009-04-02 Thread Henry Laxen
Dear Group,

I'm trying to read the paper:
Functional Pearl: Implicit Configurations
at http://www.cs.rutgers.edu/~ccshan/prepose/
and when running the code in prepose.lhs I get:
../haskell/prepose.lhs:707:0: Parse error in pattern
which is pointing at:
normalize a :: M s a = M (mod a (modulus (undefined :: s)))

The paper says it uses lexically scoped type variables.  I tried reading about
them at:
http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables

so I added -XScopedTypeVariables to my OPTIONS but I still get the same error
message.  I would really like to play with the code in the paper, but I'm stuck
at this point.  Any pointers would be appreciated.
Best wishes,
Henry Laxen


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


[Haskell-cafe] Confused by SYB example with zipping

2009-02-14 Thread Henry Laxen
Dear Group,

When trying to run the example at:
http://www.cs.vu.nl/boilerplate/testsuite/gzip/Main.hs
ghc 6.10.1 says

A pattern type signature cannot bind scoped type variables `a'
  unless the pattern has a rigid type context
In the pattern: f :: a - a - a
In the definition of `mkTT':
mkTT (f :: a - a - a) x y
   = case (cast x, cast y) of {
   (Just (x' :: a), Just (y' :: a)) - cast (f x' y')
   _ - Nothing }
In the definition of `main':
main = print $ gzip (mkTT maxS) genCom1 genCom2
 where
 genCom1 = everywhere (mkT (double Joost)) genCom
 genCom2 = everywhere (mkT (double Marlow)) genCom
 double x (E (p@(P y _)) (S s)) | x == y = E p (S (2 * s))
 double _ e = e
 maxS (S x) (S y) = S (max x y)
 
Failed, modules loaded: CompanyDatatypes.

-
I must admit I don't really know what to make of this.  Any insights would
be appreciated.
Thanks.
Henry Laxen

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


[Haskell-cafe] What monad am I in?

2008-09-02 Thread Henry Laxen
Dear Group,

When I fire up ghci and define:

increment x = return (x+1)

I can say:
Main increment 1

and ghci dutifully replies 2. Also as expected, the type signature of 
increment is:  (Num a, Monad m) = a - m a

However, if I say:

Main let a = increment 1

I get:

interactive:1:8:
Ambiguous type variable `m' in the constraint:
  `Monad m' arising from a use of `increment' at interactive:1:8-18
Probable fix: add a type signature that fixes these type variable(s)


Have I, like Monsier Jourdain, been running in the IO monad all my
life, and didn't even know it?

Thanks,
Henry Laxen

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