RE: Summary of GHC 6.6 test suite failures on MSYS/MinGW

2006-09-18 Thread Simon Peyton-Jones








Dont worry about Maessen_hashtab. It
fails core Lint, and its on my list to look at. (Its been failing for some
time)



S













From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Brian Smith
Sent: 13 September 2006 18:23
To:
glasgow-haskell-bugs@haskell.org
Subject: Summary of GHC 6.6 test
suite failures on MSYS/MinGW





I finished re-running the
test suite with all the necessary libraries installed. 

Here are the tests that are failing:

make stage=2 TESTS=TH_exn TH_fail cabal01 cabal02 conc023 conc037 conc049
conc056 ffi012 ghcpkg04 maessen_hashtab readwrite002 tcfail115 tcfail140
utf8_002 utf8_003 utf8_004 utf8_005 

Of particular concern is maessen_hashtab because it segfaults during the test.

Below is a brief description of the result of each test. For many of these
tests, I do not yet know enough to fix them. But, hopefully this report will be
helpful to somebody else. 

Regards,
Brian


* maessen-hashtab

This test segfaults, dereferencing a null pointer. This happens every way
(normal,opt,optasm,prof,profasm,ghci,threaded1,threaded2) it gets run. The
error message printed is too long to repeat here. I have no idea what the
problem is. 

* utf8_002, utf8_003, utf8_004, utf8_005:

These tests all fail the same way, outputing:
 utf8_002.hs:2:0: lexical error at end of input
instead of:
 utf8_002.hs:2:0: lexical error (UTF-8 decoding error) 



* readwrite002

This program complains to stderr:
 readwrite002.exe: readwrite002.inout: hWaitForInput: invalid
argument (Invalid argument)
and to stdout:
 ###

 Caught EOF
 ###

 Caught EOF
 ###

 Caught EOF
   


* TH_exn(normal)
TH_fail(normal)

 These two fail because the GHC indents the pretty-printed
code in the error message differently than expected.



* conc023(ghci)

This test only fails when run via GHCi. This test runs out of memory. The error
message to stderr is: 
 conc023: failed to create OS thread: Not enough storage is
available to process this command.

When I came back to the computer I saw that Windows was warning me that I was
out of virtual memory and that it was increasing my page file size. I have 1GB
of RAM which I think should be sufficient to run the testsuite successfully. 



* conc037(threaded2)

This test prints the output in a different order than expected, but I don't
know enough about how Control.Concurrent is supposed to work to know if the
problem is in GHC or in the test. Please note that I am running the tests on a
dual core (Core Duo) processor: 
 ! newThread started
 ! mainThread
 ! newThread back again
 ! 1 sec later
 ! 
 ! shutting down
 --- 1,6 
 ! mainThread
 ! newThread started
 ! newThread back again 
 ! 1 sec later
 ! 
 ! shutting down



* ffi012(ghci)

This happens only when run via GHCi. The following error message is issued
instead of the expected output:

During interactive linking, GHCi couldn't find the following symbol:
 Main_d1d4
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying

the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
 glasgow-haskell-bugs@haskell.org



ghcpkg04(normal)

An error message different than the expected. I didn't investigate this one too
closely: 

! 
! ghcpkg04.hs:1:0:
! Failed to load interface for `A':
! it was found in multiple packages:
testpkg-1.2.3.4 newtestpkg-2.0
--- 1,4 
! 
! ghcpkg04.hs:1:0:
! Failed to load interface for `A': 
! Use -v to see a list of the files
searched for.



* tcfail115, tcfail140

The error messages output by GHC are very different than the expected ones. No
clue as to why though.



* cabal01, cabal02

These fail because Cabal won't work when the GHC executable is actually a shell
script on Windows.


* process001, process002, prog001, prog002, prog003

These fail because they depend on executables (ls, rm) that are not available
on Windows. 








___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #900: SPECIALISE broken

2006-09-18 Thread GHC
#900: SPECIALISE broken
---+
  Reporter:  simonmar  |  Owner: 
  Type:  bug   | Status:  closed 
  Priority:  normal|  Milestone:  6.6
 Component:  Compiler  |Version:  6.5
  Severity:  normal| Resolution:  fixed  
  Keywords:| Os:  Unknown
Difficulty:  Unknown   |   Architecture:  Unknown
---+
Changes (by simonpj):

  * resolution:  = fixed
  * status:  new = closed

Comment:

 Fixed.  Test is tc212.hs

 Simon

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/900
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


threadDelay not ending

2006-09-18 Thread Rich Fought
I've got some unit test code that forks off test processes using the 
'system' function and then delays using 'threadDelay' to synchronize 
with the test process.


This has worked fine until I upgraded to 6.4.2, now some of the 
'threadDelay' calls never return - it's like they are stuck in limbo.


Any ideas?  What would have changed between 6.4 and 6.4.2 that would 
cause this behavior?


Thanks,
Rich

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: threadDelay not ending

2006-09-18 Thread Seth Kurtzberg
What is your environment?

My project (which is about 70% Haskell) makes extensive use of
threadDelay.  I've not seen this behavior with 6.4.2.  My environment is
Linux using a recent 2.6 kernel.

For obvious reasons I need to know whether there is a threadDelay issue
here that is preparing to bite me.

Seth Kurtzberg


On Mon, September 18, 2006 7:23 am, Rich Fought wrote:
 I've got some unit test code that forks off test processes using the
 'system' function and then delays using 'threadDelay' to synchronize
 with the test process.

 This has worked fine until I upgraded to 6.4.2, now some of the
 'threadDelay' calls never return - it's like they are stuck in limbo.

 Any ideas?  What would have changed between 6.4 and 6.4.2 that would
 cause this behavior?

 Thanks,
 Rich

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users




-- 
Seth Kurtzberg
[EMAIL PROTECTED]
Software Engineer
Specializing in Reliability and Security


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: threadDelay not ending

2006-09-18 Thread Rich Fought

I am running on Red Hat Enterprise Linux with the latest RH 2.6 kernel.

This is very bizarre and I am having a hard time figuring out what is 
going on.  I don't see any issues in the project code itself, just my 
unit tests.


Rich

Seth Kurtzberg wrote:

What is your environment?

My project (which is about 70% Haskell) makes extensive use of
threadDelay.  I've not seen this behavior with 6.4.2.  My environment is
Linux using a recent 2.6 kernel.

For obvious reasons I need to know whether there is a threadDelay issue
here that is preparing to bite me.

Seth Kurtzberg


On Mon, September 18, 2006 7:23 am, Rich Fought wrote:
  

I've got some unit test code that forks off test processes using the
'system' function and then delays using 'threadDelay' to synchronize
with the test process.

This has worked fine until I upgraded to 6.4.2, now some of the
'threadDelay' calls never return - it's like they are stuck in limbo.

Any ideas?  What would have changed between 6.4 and 6.4.2 that would
cause this behavior?

Thanks,
Rich

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users






  


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


RE: ANNOUNCE: GHC 6.6 Release Candidate

2006-09-18 Thread Simon Peyton-Jones
Excellent example.  It's very hard to give good error messages for
impredicative polymorphism.  I've tried to improve this one a bit.
(Test is tcfail165.hs)

Simon

| -Original Message-
| From: [EMAIL PROTECTED]
[mailto:glasgow-haskell-users-
| [EMAIL PROTECTED] On Behalf Of Tomasz Zielonka
| Sent: 01 September 2006 19:55
| To: Simon Marlow
| Cc: glasgow-haskell-users@haskell.org
| Subject: Re: ANNOUNCE: GHC 6.6 Release Candidate
| 
| On Fri, Sep 01, 2006 at 11:03:09AM +0100, Simon Marlow wrote:
|  Please test as much as possible, bugs are much cheaper if we find
them
|  before the release!
| 
| I was playing with impredicativity, when I got this strange error
| message:
| 
| Prelude :l Imp
| [1 of 1] Compiling Imp  ( Imp.hs, interpreted )
| 
| Imp.hs:15:17:
| Couldn't match expected type `forall a. (Show a) = a -
String'
|against inferred type `a - String'
|   Expected type: forall a1. (Show a1) = a1 - String
|   Inferred type: forall a1. (Show a1) = a1 - String
| In the second argument of `putMVar', namely
| `(show :: forall a. (Show a) = a - String)'
| In the expression:
| putMVar var (show :: forall a. (Show a) = a - String)
| Failed, modules loaded: none.
| 
| I am still trying to understand this extension, so my code probably
| makes not much sense, but it's alarming that the compiler cannot unify
| two types that are even equal. Maybe the bug is in the error message?
| 
| Here is the code:
| 
| module Imp where
| 
| import Control.Concurrent
| 
| main = do
| var - newEmptyMVar :: IO (MVar (forall a. Show a = a -
String))
| let thread x = do
| forkIO $ sequence_ $ repeat $ do
| f - takeMVar var
| putStrLn (f x)
| threadDelay 10
| thread (1 :: Integer)
| thread abcdef
| putMVar var (show :: forall a. Show a = a - String)
| threadDelay 1000
| 
| I am using ghc-6.5.20060831 with -fglasgow-exts
| 
| Best regards
| Tomasz
| ___
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: threadDelay not ending

2006-09-18 Thread Seth Kurtzberg
On Mon, 18 Sep 2006 11:56:21 -0500
Rich Fought [EMAIL PROTECTED] wrote:

 I am running on Red Hat Enterprise Linux with the latest RH 2.6 kernel.
 
 This is very bizarre and I am having a hard time figuring out what is 
 going on.  I don't see any issues in the project code itself, just my 
 unit tests.

Rich,

I'm having trouble coming up with even a credible theory of what might be 
happening.  I can't come up with any theory, no matter how far fetched, that 
would account for things working with 6.4.1 and not working with 6.4.2.

If there is anything I can do to help you narrow this down, let me know.

Seth

 
 Rich
 
 Seth Kurtzberg wrote:
  What is your environment?
 
  My project (which is about 70% Haskell) makes extensive use of
  threadDelay.  I've not seen this behavior with 6.4.2.  My environment is
  Linux using a recent 2.6 kernel.
 
  For obvious reasons I need to know whether there is a threadDelay issue
  here that is preparing to bite me.
 
  Seth Kurtzberg
 
 
  On Mon, September 18, 2006 7:23 am, Rich Fought wrote:

  I've got some unit test code that forks off test processes using the
  'system' function and then delays using 'threadDelay' to synchronize
  with the test process.
 
  This has worked fine until I upgraded to 6.4.2, now some of the
  'threadDelay' calls never return - it's like they are stuck in limbo.
 
  Any ideas?  What would have changed between 6.4 and 6.4.2 that would
  cause this behavior?
 
  Thanks,
  Rich
 
  ___
  Glasgow-haskell-users mailing list
  Glasgow-haskell-users@haskell.org
  http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 
 
  
 
 

 
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Change Data.Bits.rotate to rotate Integer (unbounded) types

2006-09-18 Thread Peter Tanski
Welcome back!  Since Data.Bits is not defined in the Haskell 1998  
standard, are we free to change the implementation of Data.Bits?  if  
we are free to change the implementation of Data.Bits, would it be  
all right to change the operation of rotate, rotateL and rotateR over  
unbounded types (to my knowledge, currently only Integer)?  I would  
like to change rotate, rotateL and rotateR to actually rotate (not  
shift) Integers.


-Pete
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell] Haskell Weekly News: September 18, 2006

2006-09-18 Thread Donald Bruce Stewart

---
Haskell Weekly News
http://haskell.org/haskellwiki/HWN
Issue 41 - September 18, 2006
---

   Welcome to issue 41 of HWN, a weekly newsletter covering developments
   in the Haskell community. Each week, new editions are posted to [1]the
   Haskell mailing list as well as to [2]the Haskell Sequence and
   [3]Planet Haskell. [4]RSS is also available, and headlines appear on
   [5]haskell.org.

   The 2006 Haskell Workshop was held today in Portland, Oregon. Thanks
   to Edward Kmett for a report on the event.

   1. http://www.haskell.org/mailman/listinfo/haskell
   2. http://sequence.complete.org/
   3. http://planet.haskell.org/
   4. http://sequence.complete.org/node/feed
   5. http://haskell.org/

Announcements

 * Haskell98 Termination Analyser . Stephan Swidersk [6]announced the
   integration of an automatic Haskell98 termination analyzer in the
   termination tool AProVE. The tool accepts full Haskell as
   specified in the Haskell 98 Report and is available through our
   web interface. [7]More

   6. http://article.gmane.org/gmane.comp.lang.haskell.general/14193
   7. http://aprove.informatik.rwth-aachen.de/

 * Free theorems . Janis Voigtlaender [8]announced that Sascha Boehme
   has done a project to implement the Reynolds/Wadler algorithm
   generating theorems from polymorphic types, plus simplifications
   and postprocessings for such free theorems. [9]More info

   8. http://article.gmane.org/gmane.comp.lang.haskell.general/14160
   9. http://haskell.as9x.info/

 * Haddock/GHC SoC . David Waern [10]announced a short status report
   of the Port Haddock to use GHC Summer of Code project. The GHC
   modifications, are finished and will be included in the GHC head
   repository soon.

  10. http://article.gmane.org/gmane.comp.lang.haskell.general/14149

 * AutoForms release 0.2 . Mads Lindstr?m [11]released AutoForms 0.2,
   a library to ease the creation of GUIs. It does this by using
   generic programming (SYB) to construct GUI components. [12]More
   info

  11. http://article.gmane.org/gmane.comp.lang.haskell.general/14148
  12. http://autoforms.sourceforge.net/

 * HSPClientside 0.2 . Joel Bj?rnson [13]announced a new version of
   HSPClientside (0.2) ,developed as a GSoC project during this
   summer. HSPClientside is a Haskell Server Pages library for
   generating JavaScript code. [14]More info

  13. http://article.gmane.org/gmane.comp.lang.haskell.general/14133
  14. http://darcs.haskell.org/SoC/hsp.clientside/

 * SOE implementation based on Gtk2Hs . Duncan Coutts [15]Due to
   popular demand the new SOE implementation based on Gtk2Hs is
   [16]available. The rendering quality is better than the original
   HGL version. [17]Here's a side-by-side comparison

  15. http://article.gmane.org/gmane.comp.lang.haskell.general/14132
  16. file://localhost/home/dons/dons/src/hwn/now
  17. http://haskell.org/~duncan/gtk2hs/SOE-cairo.png

 * The experimental GHCi debugger . Pepe [18]announced the results of
   his SoC project, the experimental Haskell debugger. [19]More
   details

  18. http://article.gmane.org/gmane.comp.lang.haskell.general/14131
  19. http://haskell.org/haskellwiki/GHC/GHCiDebugger

 * SmallCheck . Colin Runciman [20]released a prototype tool that is
   similar in spirit, and in some of its workings, to QuickCheck.
   SmallCheck is, though, based on exhaustive testing in a bounded
   space of test values. [21]More info

  20. http://article.gmane.org/gmane.comp.lang.haskell.general/14129
  21. http://www.cs.york.ac.uk/fp/smallcheck0.0.tar

 * Frisby: composable, linear time parser for arbitrary PEG grammers
   . John Meacham [22]released Frisby, an implementation of the
   'packrat' parsing algorithm, which parse PEG grammars and have a
   number of very useful qualities, they are a generalization of
   regexes in a sense that can parse everything in LL(k), LR(k), and
   more, including things that require unlimited lookahead, all in
   guaranteed linear time. [23]More information

  22. http://article.gmane.org/gmane.comp.lang.haskell.general/14128
  23. http://repetae.net/computer/frisby/

 * HaskellNet . Jun Mukai [24]published a status report on the state
   of his SoC project, HaskellNet

  24. http://article.gmane.org/gmane.comp.lang.haskell.general/14126

 * GHC's new support engineer . Simon Marlow [25]announced that GHC
   now has a full-time support engineer, Ian Lynagh (aka Igloo on
   IRC). He'll be helping with all aspects of GHC, especially release
   management, bug diagnosis and tracking, documentation, packaging,
   and supporting other GHC hackers. Welcome Ian!

  25. 

Re: [Haskell] Haskell Weekly News: September 18, 2006

2006-09-18 Thread David House

On 18/09/06, Donald Bruce Stewart [EMAIL PROTECTED] wrote:

* SOE implementation based on Gtk2Hs . Duncan Coutts [15]Due to
  popular demand the new SOE implementation based on Gtk2Hs is
  [16]available. The rendering quality is better than the original
  HGL version. [17]Here's a side-by-side comparison

 15. http://article.gmane.org/gmane.comp.lang.haskell.general/14132
 16. file://localhost/home/dons/dons/src/hwn/now
 17. http://haskell.org/~duncan/gtk2hs/SOE-cairo.png


Somewhat unsurprisingly, link 16 didn't work for me.

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


[Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu

Hi, I'm a student and I have to do a program with Haskell. This is the first
time I use this languaje, and I'm having problems with the indentation. I
want to check if this function is correct, but when I try to make the GHCi
interpret it, I get line 18:parse error (possibly incorrect indentation)

The function is:

-- Replaces a wildcard in a list with the list given as the third argument
substitute :: Eq a = a - [a] - [a] - [a]
substitute e l1 l2= [check_elem c | c - l1] where
check_elem::Eq a = a - [a]
check_elem x = 
if x == e then return l2

-- Tries to match two lists. If they match, the result consists of the
sublist
-- bound to the wildcard in the pattern list.
(line 18) match :: Eq a = a - [a] - [a] - Maybe [a]
match _ _ _ = Nothing
{- TO BE WRITTEN -}

Thank you for your attention!
-- 
View this message in context: 
http://www.nabble.com/Problems-interpreting-tf2290155.html#a6360687
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 02:51:34AM -0700, Carajillu wrote:
 
 Hi, I'm a student and I have to do a program with Haskell. This is the first
 time I use this languaje, and I'm having problems with the indentation. I
 want to check if this function is correct, but when I try to make the GHCi
 interpret it, I get line 18:parse error (possibly incorrect indentation)
 
 The function is:
 
...
   if x == e then return l2

I did not understand what you are trying to do, anyway the error
message is due to the expression above, and not to indentation.
The Haskell if constructions is: if ... then ... else, and else
cannot be missing.

Moreover, return is not a way to return a value. It is a special
function that works with the monad class. Actually it is one of the
two methods of the monad class, and it inserts a value into a monad.

As far as your code goes, I'd suggest you to read some tutorials, like
The Gentle Introduction, or Hasekll for C Programmers.

Have a look here:
http://haskell.org/haskellwiki/Learning_Haskell
and here
http://haskell.org/haskellwiki/Books_and_tutorials  

Hope this helps.

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Ketil Malde
Carajillu [EMAIL PROTECTED] writes:

 I get line 18:parse error (possibly incorrect indentation)

..which is a bit misleading, as the problem is on the preceeding line
of code.

   if x == e then return l2

And if x /= e?  What is check_elem then?¹  

 -- Tries to match two lists. If they match, the result consists of the
 sublist
 -- bound to the wildcard in the pattern list.
 (line 18) 

-k

¹ If you really don't want to provide that option, you could perhaps do:
check_elem x | x == e = return l2

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 12:54:34PM +0200, Albert Crespi wrote:
 Thank you very much for your reply!
 As I said, it is my first experience with Haskell, I have been programming
 in Java and C for some years, and I find this language very different from
 them. Anyway I'll try to fix the function with the information that you gave
 me.
 Thanks again!
 
You're welcome.

By the way, this is what the comments say you are trying to do:

-- Replaces a wildcard in a list with the list given as the third argument
substitute :: Eq a = a - [a] - [a] - [a]
substitute e l1 l2= [c | c - check_elem l1]
where check_elem [] = l1
  check_elem (x:xs) = if x == e then (l2 ++ xs) else check_elem xs

This is the result:

*Main substitute 1 [1,2,3] []
[2,3]
*Main substitute 1 [1,2,3] [7,8,9]
[7,8,9,2,3]
*Main 

Have fun with Haskell.

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu

Wow! I'm starting to love this languaje, and the people who uses it!:)


Andrea Rossato wrote:
 
 On Mon, Sep 18, 2006 at 12:54:34PM +0200, Albert Crespi wrote:
 Thank you very much for your reply!
 As I said, it is my first experience with Haskell, I have been
 programming
 in Java and C for some years, and I find this language very different
 from
 them. Anyway I'll try to fix the function with the information that you
 gave
 me.
 Thanks again!
 
 You're welcome.
 
 By the way, this is what the comments say you are trying to do:
 
 -- Replaces a wildcard in a list with the list given as the third argument
 substitute :: Eq a = a - [a] - [a] - [a]
 substitute e l1 l2= [c | c - check_elem l1]
 where check_elem [] = l1
   check_elem (x:xs) = if x == e then (l2 ++ xs) else check_elem xs
 
 This is the result:
 
 *Main substitute 1 [1,2,3] []
 [2,3]
 *Main substitute 1 [1,2,3] [7,8,9]
 [7,8,9,2,3]
 *Main 
 
 Have fun with Haskell.
 
 Ciao
 Andrea
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/Problems-interpreting-tf2290155.html#a6361815
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 04:16:55AM -0700, Carajillu wrote:
 
 Wow! I'm starting to love this languaje, and the people who uses it!:)
 

You spoke too early. My code had a bug, a huge one...

this is the right one:

-- Replaces a wildcard in a list with the list given as the third argument
substitute :: Eq a = a - [a] - [a] - [a]
substitute e l1 l2= [c | c - check_elem l1]
where check_elem [] = l1
  check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++ check_elem 
xs


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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Neil Mitchell

Hi


  check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++ check_elem 
xs


Why not:

  check_elem (x:xs) = if x == e then (l2 ++ xs) else x : check_elem xs


Thanks

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 12:25:21PM +0100, Neil Mitchell wrote:
 Why not:
  check_elem (x:xs) = if x == e then (l2 ++ xs) else x : check_elem xs
 
 Thanks

Thank you! 
Lists are my personal nightmare...;-)

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


[Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Jón Fairbairn
Andrea Rossato [EMAIL PROTECTED] writes:

 On Mon, Sep 18, 2006 at 04:16:55AM -0700, Carajillu wrote:
  
  Wow! I'm starting to love this languaje, and the people who uses it!:)
  
 
 You spoke too early. My code had a bug, a huge one...
 
 this is the right one:
 
 -- Replaces a wildcard in a list with the list given as the third argument
 substitute :: Eq a = a - [a] - [a] - [a]
 substitute e l1 l2= [c | c - check_elem l1]
 where check_elem [] = l1
   check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++ 
 check_elem xs


I think it's nicer to do it like this:

   substitute e l l'
   = concat (map subst_elem l)
 where subst_elem x
   | x == e = l'
   | otherwise = [x]

since subst_elem has a more straightforward meaning than
check_elem, and the concatenation is handled by a well
known standard function.

Also, it would usually be more useful to have the argument
to replace /with/ before the argument to replace /in/, so
that (substitute '*' wurble) is a function that replaces
all the '*'s in it's argument with wurbles.

And if you do that, you can write it like this:

   subst e l'
   = concat . map subst_elem
 where subst_elem x
   | x == e = l'
   | otherwise = [x]

-- 
Jón Fairbairn [EMAIL PROTECTED]

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


[Haskell-cafe] Re: Why is type 'b' forced to be type 'm a' and not possibly 'm a - m a' (Anatoly Zaretsky)

2006-09-18 Thread Vivian McPhail
 Message: 6
 Date: Fri, 15 Sep 2006 18:36:35 +0300
 From: Anatoly Zaretsky [EMAIL PROTECTED]
 Subject: Re: [Haskell-cafe] Why is type 'b' forced to be type 'm a'
   and not possibly 'm a - m a'
 To: Vivian McPhail [EMAIL PROTECTED]
 Cc: Haskell Cafe haskell-cafe@haskell.org
 Message-ID:
   [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 On 9/15/06, Vivian McPhail [EMAIL PROTECTED] wrote:
 
  class Forkable a where
  fork :: String - a - a - a
 
  ...
  {-
  instance (Monad m, Forkable (m a), Forkable b) = Forkable (m a - b)
where
  fork n a1 a2 a = do
   a' - a
   fork n (a1 $ return a') (a2 $ return a')
  -}
 
 
 Let's do manual type checking.
 First, fork :: Forkable a = String - a - a - a
 So for Forkable (m a - b)
   fork :: String - (m a - b) - (m a - b) - m a - b
 Then
   fork n a1 a2 a :: b
 But you define it as
   fork n a1 a2 a = do {...}
 So it should be of type Monad t = t a, not just any `b'.
 
 Instead, you can define
   instance (Monad m, Forkable (m b)) = Forkable (m a - m b) where
 ...
 

Well, I can partially instantiate what I am trying to achieve by enumerating
cases.  Note that when the first type is a monadic type the computation gets
evaluated and then forked, but when the first type is a function it merely
gets passed.  My problem is that there are a very large number of possible
cases.  So in the case Forkable (m a - b), a number of instances of which I
can implement (e.g. Forkable (m a - m a - m a), Forkable ((m a - m a) -
m a), and Forkable (m a - (m a - m a) - m a)), I don't see why 'b' should
necessarily typecheck to 't t1'.

What I would like to be able to do is differentiate between Forkable (m a -
b) and Forkable (function type - b).

By the way, the following code typechecks and runs correctly, my problem is
that enumerating all possible types requires five factorial (120) different
instances, and to a lazy functional programmer who can 'see' the pattern it
seems that there must be a nicer way of achieving my end.

\begin{code}
instance (Monad m, Forkable (m a)) = Forkable (m a - m a) where
fork n a1 a2 a = do
 a' - a
 fork n (a1 $ return a') (a2 $ return a')

instance (Monad m, Forkable (m a)) = Forkable (m a - m a - m a) where
fork n a1 a2 a b = do
   a' - a
   fork n (a1 $ return a') (a2 $ return a') b

instance (Monad m, Forkable (m a)) = Forkable ((m a - m a) - m a) where
fork n a1 a2 a = do
 fork n (a1 a) (a2 a)

instance (Monad m, Forkable (m a)) = Forkable (m a - (m a - m a) - m a)
where
fork n a1 a2 a b = do
   a' - a
   fork n (a1 $ return a') (a2 $ return a') b

\end{code}

 Note that to compile it you also need -fallow-undecidable-instances
 and -fallow-overlapping-instances.
 
 --
 Tolik
 

Thanks for your help so far!



Cheers,

Vivian

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date: 15/09/2006
 

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Bulat Ziganshin
Hello Carajillu,

Monday, September 18, 2006, 1:51:34 PM, you wrote:

 Hi, I'm a student and I have to do a program with Haskell. This is the first
 time I use this languaje, and I'm having problems with the indentation. I
 want to check if this function is correct, but when I try to make the GHCi
 interpret it, I get line 18:parse error (possibly incorrect indentation)

i want to add to Andrea's answer:

 The function is:

 -- Replaces a wildcard in a list with the list given as the third argument
 substitute :: Eq a = a - [a] - [a] - [a]
 substitute e l1 l2= [check_elem c | c - l1] where
 check_elem::Eq a = a - [a]
 check_elem x = 
 if x == e then return l2

Haskell functions are like mathematical ones - first, you don't need
to use 'return' to denote result - just write it. second, you should
provide results for any possible input values, otherwise function will
just fail on return values for which you don't provided result. 'if'
construct ensures this by forcing to write both 'then' and 'else'
parts. so, your function, probably, should return l2 if comparison
succeeds, and x otherwise:

 check_elem x =
 if x == e then l2 else x

next problem is that x and l2 had different types and type-checking
will not allow you to write this. It's right - you can't construct
list, whose some elements are, for example,

-- i've got a break to rescue a bat that was flied into our house :)

Int and some - [Int]:  [1,[0,0,0],3,4] is impossible

if your need to replace all elements of l1 that are equal to e,
with _several_ list elements, i.e.

substitute 2 [1,2,3,4] [0,0,0] = [1,0,0,0,3,4]

you should use the following technique:

replace all elements of l1 with either l2 or [x] (where x is original
list element). result of such operation:

substitute1 2 [1,2,3,4] [0,0,0] = [[1],[[0,0,0],[3],[4]]

i.e. now all elements are lists, although some have just one element.
then you should use concat operation to transform this list into what
you need:

concat [[1],[[0,0,0],[3],[4]] = [1,0,0,0,3,4]

i think that you are interested to write the complete solution yourself.
just note that there is concatMap function that will allow you to
further simplify the code




 -- Tries to match two lists. If they match, the result consists of the
 sublist
 -- bound to the wildcard in the pattern list.
 (line 18) match :: Eq a = a - [a] - [a] - Maybe [a]
 match _ _ _ = Nothing
 {- TO BE WRITTEN -}

this definition is perfectly ok :)



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 12:42:59PM +0100, Jón Fairbairn wrote:
 And if you do that, you can write it like this:
 
subst e l'
= concat . map subst_elem
  where subst_elem x
| x == e = l'
| otherwise = [x]

Pretty. Just to many keystrokes.
This should take two keystrokes less, probably:

subst e l [] = []
subst e l (x:xs) = if x == e then l ++ xs else x : subst e l xs

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu

Finally I took Andrea's solution check_elem (x:xs) = if x == e then (l2 ++
xs) else [x] ++ check_elem xs
I think it's easy to understand for me ( in my noob level), than the
recursive one. 
I'm testing it and it's working really well. The other solutions are a
little complicated for me, but I'm still trying to undestand them.
Thanks!


Andrea Rossato wrote:
 
 On Mon, Sep 18, 2006 at 12:25:21PM +0100, Neil Mitchell wrote:
 Why not:
  check_elem (x:xs) = if x == e then (l2 ++ xs) else x : check_elem xs
 
 Thanks
 
 Thank you! 
 Lists are my personal nightmare...;-)
 
 Andrea
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/Problems-interpreting-tf2290155.html#a6362822
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu

Not a good solution, it just substitutes the first occurrence of the item in
the list. I'll try the others

Carajillu wrote:
 
 Finally I took Andrea's solution check_elem (x:xs) = if x == e then (l2
 ++ xs) else [x] ++ check_elem xs
 I think it's easy to understand for me ( in my noob level), than the
 recursive one. 
 I'm testing it and it's working really well. The other solutions are a
 little complicated for me, but I'm still trying to undestand them.
 Thanks!
 
 
 Andrea Rossato wrote:
 
 On Mon, Sep 18, 2006 at 12:25:21PM +0100, Neil Mitchell wrote:
 Why not:
  check_elem (x:xs) = if x == e then (l2 ++ xs) else x : check_elem xs
 
 Thanks
 
 Thank you! 
 Lists are my personal nightmare...;-)
 
 Andrea
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Problems-interpreting-tf2290155.html#a6362912
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re[2]: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Bulat Ziganshin
Hello Andrea,

Monday, September 18, 2006, 3:22:43 PM, you wrote:

 substitute e l1 l2= [c | c - check_elem l1]

why not just

substitute e l1 l2= check_elem l1

? :)

 where check_elem [] = l1

should be

 where check_elem [] = []

otherwise you just append second (backup? :) copy of original list to
result :)




-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 05:42:47AM -0700, Carajillu wrote:
 
 Not a good solution, it just substitutes the first occurrence of the item in
 the list. I'll try the others

I did not get this point.
You must take Jón's approach with map.
andrea
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 02:52:45PM +0200, Andrea Rossato wrote:
 On Mon, Sep 18, 2006 at 05:42:47AM -0700, Carajillu wrote:
  
  Not a good solution, it just substitutes the first occurrence of the item in
  the list. I'll try the others
 
 I did not get this point.
 You must take Jón's approach with map.

or use this line in mine: 
check_elem (x:xs) = if x == e then l2 ++ check_elem xs else x : check_elem xs 

that is to say, you must check also the tail after the matched element.
andrea

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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 05:35:47AM -0700, Carajillu wrote:
 I'm testing it and it's working really well. The other solutions are a
 little complicated for me, but I'm still trying to undestand them.

Jón's approach (the last version of his message), usually cleaner and
more concise, is called point-free and is quite common in functional
programming. It can be a bit confusing to newcomers, though, since
part of the function's arguments do not appear explicitly in the
expressions' body (as the list to be matched and modified in your
example). 

You can read something more about this style here:
http://haskell.org/haskellwiki/Pointfree

Hope this helps.
Andrea


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


Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu

Definitely I'll take this solution, I'm reading about Pointfree, I think it's
not that dificult to understand. And moreover it's the simpliest way to
write code.


Jón Fairbairn-2 wrote:
 
 Andrea Rossato [EMAIL PROTECTED] writes:
 
 On Mon, Sep 18, 2006 at 04:16:55AM -0700, Carajillu wrote:
  
  Wow! I'm starting to love this languaje, and the people who uses it!:)
  
 
 You spoke too early. My code had a bug, a huge one...
 
 this is the right one:
 
 -- Replaces a wildcard in a list with the list given as the third
 argument
 substitute :: Eq a = a - [a] - [a] - [a]
 substitute e l1 l2= [c | c - check_elem l1]
 where check_elem [] = l1
   check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++
 check_elem xs
 
 
 I think it's nicer to do it like this:
 
substitute e l l'
= concat (map subst_elem l)
  where subst_elem x
| x == e = l'
| otherwise = [x]
 
 since subst_elem has a more straightforward meaning than
 check_elem, and the concatenation is handled by a well
 known standard function.
 
 Also, it would usually be more useful to have the argument
 to replace /with/ before the argument to replace /in/, so
 that (substitute '*' wurble) is a function that replaces
 all the '*'s in it's argument with wurbles.
 
 And if you do that, you can write it like this:
 
subst e l'
= concat . map subst_elem
  where subst_elem x
| x == e = l'
| otherwise = [x]
 
 -- 
 Jón Fairbairn [EMAIL PROTECTED]
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/Problems-interpreting-tf2290155.html#a6363827
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re[2]: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Bulat Ziganshin
Hello Andrea,

Monday, September 18, 2006, 4:23:21 PM, you wrote:

subst e l'
= concat . map subst_elem
  where subst_elem x
| x == e = l'
| otherwise = [x]

 Pretty. Just to many keystrokes.
 This should take two keystrokes less, probably:

 subst e l [] = []
 subst e l (x:xs) = if x == e then l ++ xs else x : subst e l xs

but the goal is not keystrokes itself but easy of understanding. for
me, first solution looks rather idiomatic and intuitively
understandable. second solution requires more time to got it, but
seems easier for novices that are not yet captured higher-level
Haskell idioms. i just want to said that it will be easier to read it
if you split it into several lines:

subst e l [] = []
subst e l (x:xs) = if x == e
 then l ++ xs
 else x : subst e l xs

or

subst e l [] = []
subst e l (x:xs) | x==e  = l ++ xs
 | otherwise = x : subst e l xs

and that your solution substitutes only first match in a list:

subst 1 [1,1] [0] = [0,1]


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 04:52:33PM +0400, Bulat Ziganshin wrote:
 but the goal is not keystrokes itself but easy of understanding. for
 me, first solution looks rather idiomatic and intuitively
 understandable. second solution requires more time to got it, but
 seems easier for novices that are not yet captured higher-level
 Haskell idioms. 

I was obviously kidding, as the ;-) should have made clear.
;-)

Apart for the bug (I did not understand that all the occurrences should
be replaced) I wrote something that was as close as possible to
Albert's first attempt.

For the rest, I completely agree with you and find the second one
a lot easier...

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


[Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Jón Fairbairn
Andrea Rossato [EMAIL PROTECTED] writes:

 On Mon, Sep 18, 2006 at 12:42:59PM +0100, Jón Fairbairn wrote:
  And if you do that, you can write it like this:
  
 subst e l'
 = concat . map subst_elem
   where subst_elem x
 | x == e = l'
 | otherwise = [x]
 
 Pretty. Just to many keystrokes.

Keystrokes? Learn to touchtype!

 This should take two keystrokes less, probably:
 
 subst e l [] = []
 subst e l (x:xs) = if x == e then l ++ xs else x : subst e l xs

but if you want short, do this:

 subst e l' = concat.map (\x-if x==e then l' else [x])

which beats yours by twenty seven characters and one bug ;-P

-- 
Jón Fairbairn [EMAIL PROTECTED]
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2006-09-13)

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


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Neil Mitchell

Hi


subst e l' = concat.map (\x-if x==e then l' else [x])


subst e l' = concatMap (\x-if x==e then l' else [x])

Let's save an extra character :)

Thanks

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


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Joachim Breitner
Hi,

Am Montag, den 18.09.2006, 16:00 +0100 schrieb Neil Mitchell:
  subst e l' = concat.map (\x-if x==e then l' else [x])
 subst e l' = concatMap (\x-if x==e then l' else [x])
 Let's save an extra character :)
We are talking keystrokes here, so count the shift key!

Greetings,
Joachim
-- 
Joachim Breitner
  e-Mail: [EMAIL PROTECTED]
  Homepage: http://www.joachim-breitner.de
  ICQ#: 74513189
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread wld

Hi,
On 9/18/06, Joachim Breitner [EMAIL PROTECTED] wrote:

Hi,

Am Montag, den 18.09.2006, 16:00 +0100 schrieb Neil Mitchell:
  subst e l' = concat.map (\x-if x==e then l' else [x])
 subst e l' = concatMap (\x-if x==e then l' else [x])
 Let's save an extra character :)
We are talking keystrokes here, so count the shift key!

Greetings,
Joachim


Sorry, couldn't resist... If we *really* talking keystrokes, it much
depends on auto-completion features of your editor! :)

V.Rudenko
--
λ is the ultimate
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Lennart Augustsson

Or even shorter:

subst e l = concatMap $ \x-if x==e then l else [x]

I kinda like the list comprehension version too

subst e l1 l2 = [ r | x - l2, r - if x==e then l1 else [x] ]


On Sep 18, 2006, at 10:54 , Jón Fairbairn wrote:


Andrea Rossato [EMAIL PROTECTED] writes:


On Mon, Sep 18, 2006 at 12:42:59PM +0100, Jón Fairbairn wrote:

And if you do that, you can write it like this:

   subst e l'
   = concat . map subst_elem
 where subst_elem x
   | x == e = l'
   | otherwise = [x]


Pretty. Just to many keystrokes.


Keystrokes? Learn to touchtype!


This should take two keystrokes less, probably:

subst e l [] = []
subst e l (x:xs) = if x == e then l ++ xs else x : subst e l xs


but if you want short, do this:


subst e l' = concat.map (\x-if x==e then l' else [x])


which beats yours by twenty seven characters and one bug ;-P

--  
Jón Fairbairn  
[EMAIL PROTECTED]
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated  
2006-09-13)


___
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


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Neil Mitchell

Hi,

Out of curiosity, I've been developing a tool called Dr Haskell, for a
sample run:


module Test where

substitute1 :: Eq a = a - [a] - [a] - [a]
substitute1 e l1 l2= [c | c - check_elem l1]
  where check_elem [] = l1
check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++ check_elem xs


substitute2 e l l'
 = concat (map subst_elem l)
   where subst_elem x
 | x == e = l'
 | otherwise = [x]

subst3 e l [] = []
subst3 e l (x:xs) = if x == e then l ++ xs else x : subst3 e l xs


subst4 e l' = concat.map (\x-if x==e then l' else [x])



drhaskell Test.hs


I can apply Hints.concat_map in Test.subst4
I can apply Hints.concat_map in Test.substitute2
I can apply Hints.box_append in Test.Test.Prelude.200.check_elem

For the curious, see the darcs repo:

http://www.cs.york.ac.uk/fp/darcs/drhaskell/

(Requires Yhc)

Thanks

Neil

PS. dons also contributed some of the earlier discussion to this tool,
so deserves some credit.


On 9/18/06, wld [EMAIL PROTECTED] wrote:

Hi,
On 9/18/06, Joachim Breitner [EMAIL PROTECTED] wrote:
 Hi,

 Am Montag, den 18.09.2006, 16:00 +0100 schrieb Neil Mitchell:
   subst e l' = concat.map (\x-if x==e then l' else [x])
  subst e l' = concatMap (\x-if x==e then l' else [x])
  Let's save an extra character :)
 We are talking keystrokes here, so count the shift key!

 Greetings,
 Joachim

Sorry, couldn't resist... If we *really* talking keystrokes, it much
depends on auto-completion features of your editor! :)

V.Rudenko
--
λ is the ultimate

___
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


[Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Aaron Denney
On 2006-09-18, Jón Fairbairn [EMAIL PROTECTED] wrote:
 Andrea Rossato [EMAIL PROTECTED] writes:

 On Mon, Sep 18, 2006 at 12:42:59PM +0100, Jón Fairbairn wrote:
  And if you do that, you can write it like this:
  
 subst e l'
 = concat . map subst_elem
   where subst_elem x
 | x == e = l'
 | otherwise = [x]
 
 Pretty. Just to many keystrokes.

 Keystrokes? Learn to touchtype!

One has only a finite number of keystrokes before one's hands give out.
Use them wisely.

-- 
Aaron Denney
--

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


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Sam Pointon

On 18/09/06, Aaron Denney [EMAIL PROTECTED] wrote:

One has only a finite number of keystrokes before one's hands give out.
Use them wisely.


i agr rdndncy = bd  shd b stmpd out wsts bndwth 2

Slightly more seriously, a few extra keystrokes can -really- improve
clarity. For example, you can write English and still be understood
(reasonably) well without most of the vowels. But how on Earth do you
interpret ld mn gd t shp? Or any Perl/Ruby/whatever golf entry?

I'd rather waste keystrokes writing clearer code than brain cycles
understanding obfuscated code, personally.

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


Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 11:04:27AM -0400, Lennart Augustsson wrote:
 Or even shorter:
 
 subst e l = concatMap $ \x-if x==e then l else [x]
 
 I kinda like the list comprehension version too
 
 subst e l1 l2 = [ r | x - l2, r - if x==e then l1 else [x] ]

This is the version I first wanted to (try to) implement (improvements
thanks to the thread, obviously :-):

newtype SF a b = SF { runSF :: [a] - [b] } 
instance Arrow SF where
arr f = SF (map f)
SF f  SF g = SF (f  g)
first (SF f) = SF (unzip  first f  uncurry zip)

substitute e l = arr (\x-if x==e then l else [x])  SF concat

I was studying Hughes when I read the first mail of this thread. But
you can see it yourself...

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


[Haskell-cafe] darcs get-together tuesday evening (2006-09-19 18:00)

2006-09-18 Thread Eric Y. Kow
Dear darcs users, hackers and observers (*),

We're getting together around 18:00 this Tuesday to discuss and/or hack
on darcs.  This will be after the ICFP sessions for that day, in
Portland, Oregon, specifically the Marriott downtown waterfront LL1.

David Roundy will be there, Ian Lynagh and me too.
Hope to see you there.

(*) Sorry for the spam, Haskellers.  I figured we might as well try
to catch ICFP bystanders.

-- 
Eric Kow http://www.loria.fr/~kow
PGP Key ID: 08AC04F9 Merci de corriger mon français.


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


[Haskell-cafe] Re: foreach

2006-09-18 Thread Benjamin Franksen
Brandon Moore wrote:
 Couldn't '\' delimit a subexpression, as parentheses do? Would there be
 any ambiguity in accepting code like State \s - (s, s) instead of
 requiring State $ \s - (s, s), or taking
 
 main = do
 args - getArgs
 foreach args \arg - do
 foreach [1..3] \n - do
 putStrLn ((show n) ++ )  ++ arg
 
 It would be a bit odd to have a kind of grouping the always starts
 explicitly and ends implicitly, but other than that it seems pretty
 handy, harmless, and natural (I know I've tried to write this sort of
 thing often enough)

Sounds like an extremely good idea to me.

Ben

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


Re: [Haskell-cafe] foreach

2006-09-18 Thread Twan van Laarhoven
Couldn't '\' delimit a subexpression, as parentheses do? Would there be 
any ambiguity in accepting code like State \s - (s, s) instead of 
requiring State $ \s - (s, s), or taking


Looking at the Haskell 98 language definition it seems that a whole 
class of these expressions are disallowed inside function applications:

 exp10   - \ apat1 ... apatn - exp
 | let decls in exp
 | if exp then exp else exp
 | case exp of { alts }
 | do { stmts }
 | fexp

This means that none of the following are legal Haskell declarations, 
even though they are unambiguous:

 a = State \s - (s, s)
 b = map let f x = x + 1 in f
 c = return if a then b else c
 d = catch do x - getLine
  return x

It can be argued that this is mostly obfuscation, and that it can 
sometimes be confusing, especially with let and do, but it saves on the 
amount of parentheses or $s. What was the original reasoning for 
disallowing these more complex expressions as the rightmost argument in 
an fexp? Or was this simply not considered?


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


Re: [Haskell-cafe] Re: Optimization problem

2006-09-18 Thread Ross Paterson
On Sun, Sep 17, 2006 at 01:08:04PM +0200, [EMAIL PROTECTED] wrote:
 Ross Paterson wrote:
  It's interesting that these composed transformations don't seem to cost
  too much.
 
 That the composed transformations are indeed cheap is not necessarily
 disturbing.

I meant the composition of the transformations of the tree (update or
reverse insert) that Bertram does for each list element.  They're cheap
because they're bounded by the depth of the tree, and even cheaper if
you're probing some other part of the tree.

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


Re: [Haskell-cafe] Re: Optimization problem

2006-09-18 Thread Ross Paterson
On Mon, Sep 18, 2006 at 12:23:11AM +0100, Ross Paterson wrote:
 To prove that (even for partial and infinite lists ps)
 
   splitSeq ps = [(a, seconds a ps) | a - nub ps]
 
 [...] we can establish, by induction on the input list,
 
 (1)   fst (splitSeq' s ps) =
   [(a, seconds a ps) | a - nub ps, not (member a s)]
 (2)   member x s  =
   get x s (snd (splitSeq' s ps)) = seconds x ps

Oops, nub ps should be nub (map fst ps) in each case.

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


[Haskell-cafe] Either e Monad

2006-09-18 Thread Deokhwan Kim
Dear all,

Where is the Monad instance declaration of Either e?

From the description of Control.Monad.Error, I deduce that Either e is
an instance of Monad.


http://haskell.org/ghc/docs/latest/html/libraries/mtl/Control-Monad-Error.html

  class Monad m = MonadError e m | m - e where ...

  Error e = MonadError e (Either e)

But, I cannot find the Monad instance declaration of Either anywhere.

Thanks.

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