Re: [Haskell-cafe] Functor and Haskell

2009-04-22 Thread Kim-Ee Yeoh


Daryoush Mehrtash-2 wrote:
 
 I am not sure I follow how the endofunctor gave me the 2nd functor.
 
 As I read the transformation there are two catagories C and D and two
 functors F and G between the same two catagories.  My problem is that I
 only
 have one functor between the Hask and List catagories.  So where does the
 2nd functor come into picture that also maps between the same C and D
 catagories?
 

Consider
singleton :: a - [a]
singleton x = [x]

Here F is the identity functor, and G is the list functor. And yes, C=D=
category of (a subset of) Haskell types.

-- 
View this message in context: 
http://www.nabble.com/Functor-and-Haskell-tp23166441p23170956.html
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: Is 78 characters still a good option? Was: [Haskell-cafe] breaking too long lines

2009-04-22 Thread Jason Dusek
  The question of which column width is right is not a
  revealing one -- there is little technical or scientific basis
  to prefer 117 to 80.

  The line length that we prefer is similarly unenlightening.
  The number of people who, when pushing for column widths
  greater than 80, choose 132 instead shows us how just how
  unexploratory and hidebound folks are on this issue. Like you
  didn't pick 132 because it's the other traditional terminal
  size.

  Column width is rather like driving on a certain side of the
  road. Is one side better than the other? No. Let's change it!
  Why? The year after you change the ordinance, people will
  still be crashing into one another when they get up in the
  morning and switch by mistake -- and people out in the country
  will drive on the old side for a decade afterward, to Hell
  with the law. All this and *not for any benefit*.

  The effect of liberalizing the line length will be anarchy.
  I'll be resizing my terminal several times a week because some
  goofball likes 91 characters while another likes 354. Whereas
  now, we expect code from most sources to fit in 80 columns
  *and it does*. I've not changed the width of my terminal for
  code, email or reading in, well, uhm -- well ever since I
  changed it to 80.

  80 columns is a wise limit because it's in wide use. It's not
  about whether I like it best -- it's about whether I expect
  most everyone else to be happy with code that I write in it
  (and I do). In matters where there is no clearcut best answer,
  social convention creates a clear expectation.

  Now in the presence of new knowledge, social convention must
  be changed. Unfortunately, there is no new science on line
  lengths. There is no reason to prefer any other column width
  to 80; the number was chosen a long time ago. Let's accept it
  and move on.

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


[Haskell-cafe] Re: ANN: list-tries-0.0 - first release

2009-04-22 Thread Matti Niemenmaa

Felipe Lessa wrote:

On Wed, Apr 22, 2009 at 12:29:05AM +0300, Matti Niemenmaa wrote:

Good to hear that it works for someone else, too. (I don't have a new
enough version of containers installed myself, after upgrading to
6.10.2.) Just bear in mind that some functions won't work.


What exactly don't work? What is the problem with containers-0.2?


The following three bugs are the problem:

(1) http://hackage.haskell.org/trac/ghc/ticket/2644
(2) http://hackage.haskell.org/trac/ghc/ticket/2769
(3) http://hackage.haskell.org/trac/ghc/ticket/2960

(1) means that any intersection function will fail on a trie 
parametrized with an IntMap.


(2) I worked around, it just means that mapAccumDescWithKey on a trie 
parametrized with a Map as well as mapAccumDesc and mapAccumDescWithKey 
on a trie parametrized with an IntMap will have worse performance, as 
they go via lists.


Finally, (3) means that using any Traversable function on a trie 
parametrized with an IntMap will error out.


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


Re: Is 78 characters still a good option? Was: [Haskell-cafe] breaking too long lines

2009-04-22 Thread Jason Dusek
  Really, the whole thing makes me wish we had blasphemy laws.

If any person, in speaking or in writing, shall indicate
a preference for column widths other than 80 or indent
characters other than spaces (`0x20`) they shall be
compelled to present some science or be subject to
imprisonment.

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


[Haskell-cafe] Being impure within a 'pure' function

2009-04-22 Thread Daniel K.
Hello,

imagine the following situation: You want to implement e.g. Dijkstra's
algorithm to find a shortest path between nodes u and v in a graph. This
algorithm relies heavily on mutating arrays, so the type signature would
look something like

getDistance :: Graph - Node - Node - IO Int

Not mutating the underlying arrays would probably result in poor
performance. BUT: For a constant graph, the distance between two nodes stays
the same all the time, so in fact getDistance should be a pure function!
So here is my question: Is there a way to write functions in Haskell that do
some IO internally, but that are guaranteed to be side-effect free? Of
course one would have to make sure that the array that is mutated inside
getDistance must not be accessible from outside the function.

Is that possible? If not, wouldn't that be desirable? If not, why not?

Thanks

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


[Haskell-cafe] Trouble with type signatures and type families

2009-04-22 Thread Stephan Friedrichs
Hi,

consider the following code:


class Foo f where
type Bar f :: *
type Baz f :: *

from :: Bar f - Baz f
to   :: Baz f - Bar f

data Tree a b c
= Empty
| Tree b c (Tree a b c) (Tree a b c)

--singleton :: (Foo f) = Bar f - Tree a (Bar f) (Baz f)
singleton x = Tree x (from x) Empty Empty


what type does 'singleton' have? ghci-6.10.2 says:

 :t singleton
singleton :: forall f a. (Foo f) = Bar f - Tree a (Bar f) (Baz f)

which is no surprise. But when I uncomment the type signature in the
above code sample, loading it to ghci gives the following error:

 :r
[1 of 1] Compiling Main ( T.hs, interpreted )

T.hs:14:22:
Couldn't match expected type `Baz f1' against inferred type `Baz f'
In the second argument of `Tree', namely `(from x)'
In the expression: Tree x (from x) Empty Empty
In the definition of `singleton':
singleton x = Tree x (from x) Empty Empty

T.hs:14:27:
Couldn't match expected type `Bar f' against inferred type `Bar f1'
In the first argument of `from', namely `x'
In the second argument of `Tree', namely `(from x)'
In the expression: Tree x (from x) Empty Empty
Failed, modules loaded: none.

I don't get it... what's wrong, I just copied the inferred type?

//Stephan


-- 

Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

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


Re: [Haskell-cafe] Being impure within a 'pure' function

2009-04-22 Thread Eugene Kirpichov
Yes. Use the ST (State Thread) monad. Data.Array.ST, STRef etc.

2009/4/22 Daniel K. anmeldema...@gmail.com:
 Hello,

 imagine the following situation: You want to implement e.g. Dijkstra's
 algorithm to find a shortest path between nodes u and v in a graph. This
 algorithm relies heavily on mutating arrays, so the type signature would
 look something like

 getDistance :: Graph - Node - Node - IO Int

 Not mutating the underlying arrays would probably result in poor
 performance. BUT: For a constant graph, the distance between two nodes stays
 the same all the time, so in fact getDistance should be a pure function!
 So here is my question: Is there a way to write functions in Haskell that do
 some IO internally, but that are guaranteed to be side-effect free? Of
 course one would have to make sure that the array that is mutated inside
 getDistance must not be accessible from outside the function.

 Is that possible? If not, wouldn't that be desirable? If not, why not?

 Thanks

   Daniel


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





-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Trouble with type signatures and type families

2009-04-22 Thread Gleb Alexeyev
You may want to read the comments at 
http://hackage.haskell.org/trac/ghc/ticket/1897.


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


Re: [Haskell-cafe] Being impure within a 'pure' function

2009-04-22 Thread Jason Dusek
  If you want to do raw IO and repackage it as pure, you can
  use `unsafePerformIO` and friends. It is important to use the
  `NOINLINE` pragma in that case.

--
Jason Dusek


 |...unsafePerformIO...|
  
http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO-Unsafe.html#v%3AunsafePerformIO
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Being impure within a 'pure' function

2009-04-22 Thread Thomas Davie


On 22 Apr 2009, at 10:38, Daniel K. wrote:


Hello,

imagine the following situation: You want to implement e.g.  
Dijkstra's algorithm to find a shortest path between nodes u and v  
in a graph. This algorithm relies heavily on mutating arrays, so the  
type signature would look something like


getDistance :: Graph - Node - Node - IO Int

Not mutating the underlying arrays would probably result in poor  
performance. BUT: For a constant graph, the distance between two  
nodes stays the same all the time, so in fact getDistance should be  
a pure function!
So here is my question: Is there a way to write functions in Haskell  
that do some IO internally, but that are guaranteed to be side- 
effect free? Of course one would have to make sure that the array  
that is mutated inside getDistance must not be accessible from  
outside the function.


Is that possible? If not, wouldn't that be desirable? If not, why not?


Either, as Eugene suggested, use the ST monad, as is possible in this  
case (and much better than the solution I'm proposing), or if you  
*really* can't get out of using IO, use unsafePerformIO.  You will  
though have to provide several guarantees yourself that the type  
system would normally provide for you (hence the unsafe part - it  
should really be verifyItsSafeYourselfPerformIO).


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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Miguel Mitrofanov


On 22 Apr 2009, at 13:07, Jon Fairbairn wrote:


Miguel Mitrofanov miguelim...@yandex.ru writes:


Well, the problem is that every implementor does choose a
subset of standart to implement.


That's what I'm complaining about.


And that's exactly what you (or anybody else) can't do anything about  
(thank God for that).



It's much worse in JavaScript - essential features working
differently in Internet Explorer, Firefox, Opera, and
Safari, and sometimes they even differ between versions; Web
programmers still manage.


Strange example to choose. Have you any idea how much time
is wasted because of the implementation differences in
JavaScript?


Actually, I have a pretty good idea - I've used to be a Web  
programmer. Surprisingly, not much.



It's arrogant
and disrespectful on the part of the implementors to say
that they know better than the committee what features
should be part of the language.


It's arrogant and disrespectful on the part of the committee to say  
that they know better than the implementors what features should they  
implement.


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


Re[2]: [Haskell-cafe] Being impure within a 'pure' function

2009-04-22 Thread Bulat Ziganshin
Hello Jason,

Wednesday, April 22, 2009, 1:14:49 PM, you wrote:

there is no any need in unsafePerformIO for array computations - ST
monad is exactly what one need here

   If you want to do raw IO and repackage it as pure, you can
   use `unsafePerformIO` and friends. It is important to use the
   `NOINLINE` pragma in that case.

 --
 Jason Dusek


  |...unsafePerformIO...|
  
 http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO-Unsafe.html#v%3AunsafePerformIO
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Jon Fairbairn
Miguel Mitrofanov miguelim...@yandex.ru writes:

 Well, the problem is that every implementor does choose a
 subset of standart to implement.

That's what I'm complaining about.

 It's much worse in JavaScript - essential features working
 differently in Internet Explorer, Firefox, Opera, and
 Safari, and sometimes they even differ between versions; Web
 programmers still manage.

Strange example to choose. Have you any idea how much time
is wasted because of the implementation differences in
JavaScript? 

 (n+k)-patterns are nothing compared to that.

Since there is no need for /any/ differences in the
implemented part of H98, we can, if we choose, have /the/
language where all this crap about I'd better not use this
part of the standard because the MuckWorx compiler doesn't
implement it doesn't apply.

This thread is really depressing (this is about the rest of
the thread, not your post Miguel). We're rehearsing the
arguments about n+k patterns that were gone through by the
first Haskell committee and then rehashed by the H98 folks,
when that's completely irrelevant -- n+k patterns are in
H98, so implementors should implement them. It's arrogant
and disrespectful on the part of the implementors to say
that they know better than the committee what features
should be part of the language.

I'm reminded of decades ago when people talked about
implementing extended subsets of this or that language.
Perl is an extended subset of Haskell...

Concerning the suggestion that I should implement them,
given that I'm against n+k patterns, I hardly think the
effort should fall on me -- I'm not in the business of
implementing Haskell at all at the moment. Or maybe I should
be more pro-active. Here, using my favoured paradigm of
Advanced Reactive Software Engineering (a successor to
extreme programming and the like) is my Haskell 98 compiler
(currently only implements a subset):

module Main where
main = error (You have used an unimplemented feature of Haskell 98.\n\
  \Please submit a test case and patch to correct the deficiency\n)

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Issues with IO and FFIs

2009-04-22 Thread Jon Harrop

Does anyone have any comments on the following criticism of some difficulties 
with FFI, including IO, in Haskell:

http://groups.google.com/group/comp.lang.functional/msg/6d650c086b2c8a49?hl=en

In particular, is it not always possible to write IO libraries safely in 
Haskell?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Cabal's default install location

2009-04-22 Thread Duncan Coutts
On Wed, 2009-04-22 at 11:33 +0200, david48 wrote:
  
 The default should at least be consistent among cabal install, runghc
 Setup.hs, installing GHC, Gtk2Hs, and so on.
 
 If GHC is installed in /home/myusername/local, 

Where you choose to install ghc is not related.

 what does cabal install --global ?

Global always means /usr/local by default, unless you change it in the
cabal config file.

By default ghc, gtk2hs also install globally in /usr/local (unless you
specify a --prefix.)

This tradition of global and /usr/local for ./configure scripts is ok,
but for a convenient package manager it's not necessarily ideal.

Duncan

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


Re: [Haskell-cafe] Issues with IO and FFIs

2009-04-22 Thread Bertram Felgenhauer
Jon Harrop wrote:
 
 Does anyone have any comments on the following criticism of some
 difficulties  with FFI, including IO, in Haskell:
 
 http://groups.google.com/group/comp.lang.functional/msg/6d650c086b2c8a49?hl=en

That post conflates two separate questions.

1) binding to foreign libraries that export functions that are
   semantically pure, but can't be imported as pure functions, for
   example because they use pointers.

   unsafePerformIO was added in the FFI spec for exactly this purpose,
   as you can see for yourself here:

   http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise5.html#x8-240005.1

2) global variables. This has been a topic of long and heated debates,
   with no clear winner. I don't think another debate will be fruitful.

 In particular, is it not always possible to write IO libraries safely in 
 Haskell?

Flame bait? Yes, it is not always possible, because some interfaces are
inherently unsafe, putting the burden of using them safely on the user.
unsafePerformIO itself is a prime example for this.

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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread david48
On Wed, Apr 22, 2009 at 12:32 AM, Duncan Coutts duncan.cou...@worc.ox.ac.uk
 wrote:

 On Tue, 2009-04-21 at 12:31 +0200, david48 wrote:
  For what it's worth, It's bothered me often enough that cabal doesn't
  install globally by default that I had to reinstall ghc in order to
  solve package issues.

 Do you know what the problem was exactly? It's possible to get problems
 with overlap between the user and global package dbs, but the exact same
 problems can also happen just within the global package db.



One problem I had was while installing Lehksah. ( It was you who pointed me
to the solution, thanks. )
The last problem was for installing wxhaskell from the source. The first
part compiled just fine, but the second wouldn't with a package problem. I
didn't want to bother searching what the problem was, so I thought it was
faster to reinstall ghc and compile wxhaskell then. (it worked)
Also, I think it's been a while I managed to do a cabal upgrade which didn't
stop on a dependency issue.

Since I didn't write down the exact problems I had, I'm attempting a fresh
install, and I'll write down what happens as I go.

1) Installing GHC 6.10.2 from the tarball, I decided to give it a try to
./configure --prefix=/home/david/local
2) Adding /home/david/local' to my PATH
3) I find a binary for cabal-install 0.6.0,
4) cabal update
5) cabal install cabal-install

Proceeds to download and compile HTTP-4000.0.6, then zlib-0.5.0.0 which
fails because I don't have zlib.h on this new system.

da...@pcdavid2:~$ sudo apt-get install
... well there is no zlib-dev, libzlib-dev available on Jaunty. there is a
zlib1-dev which fails to install, and a zlib1g-dev which works.

da...@pcdavid2:~$ cabal-0.6.0 install cabal-install   again.
This time zlib-0.5.0.0 compiles, but then :
/usr/bin/ld: cannot find -lgmp

da...@pcdavid2:~$ sudo apt-get install libgmp3-dev

da...@pcdavid2:~$ download/cabal-0.6.0 install cabal-install   againagain.

This time all goes well except that:
Installing executable(s) in /home/david/.cabal/bin
why the hell would cabal install binaries in a subdirectory of a hidden
directory. Why not /home/david/bin or /home/david/local/bin ?

Ok so I find out the setting to change in .cabal/configure, but there's
already two packages installed and downloaded there, and I don't know how to
change them to the correct location.

So, deleting .cabal and local, reinstalling ghc. I kept the de-tarred
directory around, so it's really quick.
cabal-update again, make sure config has the right path.
oops. Cabal thinks zlib is still around, I thought I had deleted that.

Looks like reinstalling ghc didn't rewrite my package list. removing .ghc
and trying again.
Now something else.

da...@pcdavid2:~$ ghc-pkg check
There are problems in package rts-1.0:
  include-dirs: PAPI_INCLUDE_DIR doesn't exist or isn't a directory

The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
rts-1.0
haddock-2.4.2
ghc-prim-0.1.0.0
integer-0.1.0.1
base-4.1.0.0
...

Solution :
da...@pcdavid2:~$ ghc-pkg describe rts | sed 's/PAPI_INCLUDE_DIR//' |
ghc-pkg update -

da...@pcdavid2:~$ download/cabal-0.6.0 install cabal-install
Linking dist/build/cabal/cabal ...
Installing executable(s) in /home/david/.cabal/bin

WTF?

da...@pcdavid2:~$ vi .cabal/config
install-dirs user
  -- prefix: /home/david/local
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib

I give up for now.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Cabal's default install location

2009-04-22 Thread david48
On Wed, Apr 22, 2009 at 12:06 PM, Duncan Coutts duncan.cou...@worc.ox.ac.uk
 wrote:

 On Wed, 2009-04-22 at 11:33 +0200, david48 wrote:
 
  The default should at least be consistent among cabal install, runghc
  Setup.hs, installing GHC, Gtk2Hs, and so on.
 
  If GHC is installed in /home/myusername/local,

 Where you choose to install ghc is not related.


What about the package list ?
In other words, why would I need a separate user and global package list if
ghc is installed in my home directory ?

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


Re: [Haskell-cafe] Issues with IO and FFIs

2009-04-22 Thread Bulat Ziganshin
Hello Jon,

Wednesday, April 22, 2009, 1:54:58 PM, you wrote:

 Does anyone have any comments on the following criticism of some difficulties
 with FFI, including IO, in Haskell:

 http://groups.google.com/group/comp.lang.functional/msg/6d650c086b2c8a49?hl=en

 In particular, is it not always possible to write IO libraries safely in
 Haskell?

i think that this letter is true on factual part but he exaggerate
this problem

1) you can develop any pure-haskell imperative library with safe (no global
state) interface and implementation. well, you can do the same with
any other language too :)

2) if you are going to hardware level, it usually has von Neumann
architecture, i.e. global state. so when providing some service to
application, you have to deal with global state at some level. if it
doesn't handled at C level (in his example, MVar may be maintained at C
side), you need to to this at Haskell level

3) haskell language still doesn't provide features to create global
variables, although it was proposed to add syntax he uses:

globalLock - newMVar False
-- the same as globalLock = unsafePerformIO (newMVar False)
-- but with guarantees of no sharing

so we use unsafePerformIO hack instead


that's all. if we sometimes deal with global-state C libraries, we may
need to use global vars too. anyway, at some level (be it C or
Haskell) we need to create safe interface too unsafe von Neumann
hardware


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] ANN: Elerea, another FRP library

2009-04-22 Thread Wolfgang Jeltsch
Am Dienstag, 21. April 2009 17:18 schrieb Patai Gergely:
  What about evaluation time? If I remember correctly, the values
  of signals depend on the time when the signal expressions are
  evaluated. So evaluating them multiple times might lead to
  different behavior. Is this correct?

 It is. However, there is really only one construct that needs extra care
 here: the latcher. All the others create top-level nodes that get
 evaluated just once during the first attempt to sample the output of the
 network. Therefore, duplication and merging of identical expressions
 only affects the performance unless they are hidden in the input signal
 of a latcher.

But isn’t the latter a fundamental problem?

To make things a bit more concrete, look at the following code snippet:

 time :: Signal DTime
 time = stateful 0 (+)

 timeSwitching :: Signal Bool - Signal DTime
 timeSwitching control = latcher time control (pure time)

If the time signal is evaluated only once then for any signal c,
timeSwitching c should be equivalent to time. But what if I replace time by 
stateful 0 (+) in the definition of timeSwitching? If stateful 0 (+) is 
evaluated everytime a switch occurs then timeSwitching would always switch 
back to time 0.

So one first has to answer the question what the intended semantics should be. 
Should signals start at the beginning or should they start every time they 
are switched into?

Implementing the first semantics is difficult since the system would have to 
know what signals will be used later. I think this is impossible in general 
because of undecidability issues. (Grapefruit’s approach is to force the user 
to specify what signals are used later.)

Implementing the second semantics would require a single signal having 
possibly different values when started at different times. This in turn would 
disallow caching of signal values in mutable variables.

Maybe I just misunderstood something, so please correct me if I’m wrong.

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


Re: [Haskell-cafe] Re: Cabal's default install location

2009-04-22 Thread Duncan Coutts
On Wed, 2009-04-22 at 12:26 +0200, david48 wrote:
 
 
 On Wed, Apr 22, 2009 at 12:06 PM, Duncan Coutts
 duncan.cou...@worc.ox.ac.uk wrote:
 On Wed, 2009-04-22 at 11:33 +0200, david48 wrote:
 
  The default should at least be consistent among cabal
 install, runghc
  Setup.hs, installing GHC, Gtk2Hs, and so on.
 
  If GHC is installed in /home/myusername/local,
 
 
 Where you choose to install ghc is not related.
 
 What about the package list ?
 In other words, why would I need a separate user and global package
 list if ghc is installed in my home directory ?

Sure, you don't strictly need two in that case.

Duncan

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


Re: [Haskell-cafe] Re: Cabal's default install location

2009-04-22 Thread david48
The default should at least be consistent among cabal install, runghc
Setup.hs, installing GHC, Gtk2Hs, and so on.

If GHC is installed in /home/myusername/local, what does cabal install
--global ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: breaking too long lines

2009-04-22 Thread Christian Maeder
Maurí­cio wrote:
 according the several style guides, lines shouldn't be too long
 (longer than 78 characters).
 
 Since Haskell is usually nice to parse, wouldn't it be
 interesting to replace a pretty printer program for layout
 manuals? I saw in your first link that the teacher provided
 a tool to check for non-compliant layout, but wouldn't it
 be easier to provide a pretty-printer (with line size as one
 parameter to the command line)?

Yes, this tool
http://www.cs.caltech.edu/courses/cs11/material/haskell/misc/haskell_style_check
is quite good. It should have been written in Haskell!

(Btw, it warns wrongly about a comma not followed by a space in a
character literal ',')

My other favorite tool is hlint
http://community.haskell.org/~ndm/darcs/hlint/hlint.htm

Surely, I would prefer a single tool. There are certainly some style
elements that can be corrected automatically, like replacing tabs,
deleting trailing whitespace, putting a final newline at the of a file,
shrinking more than 2 consecutive blank lines to just two blank lines, etc.

However, parsing and pretty-printing code _and_ all comments (!) is not
that easy to implement. Also tools like Haddock and programatica have
limitations (and are written for different purposes).

Some comments may refer to line numbers! (This is quite common in
teaching documents and maybe correctly and better achieved by labels.)

A conversion program could support different style options, but it would
need to make sure that the resulting text is still valid haskell and
produces equivalent code. But also a speed-up may mess-up your overall
behavior!

Looking at hlint, it makes suggestions that require additional imports
or use different function. All these may cause ambiguities, although
unlikely. Some suggestions (eta-reduce) cause the monomorphism-
restriction to jump in.

The current pretty-printer happened to put a lambda sign \ as the last
character on a line causing cpp to fail, etc.

Yet, such a (difficult to implement) tool would be useful.

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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Duncan Coutts
On Wed, 2009-04-22 at 12:21 +0200, david48 wrote:

 Do you know what the problem was exactly? It's possible to get
 problems with overlap between the user and global package dbs,
 but the exact same problems can also happen just within the
 global package db.
 
 
 One problem I had was while installing Lehksah. ( It was you who
 pointed me to the solution, thanks. )
 The last problem was for installing wxhaskell from the source. The
 first part compiled just fine, but the second wouldn't with a package
 problem. I didn't want to bother searching what the problem was, so I
 thought it was faster to reinstall ghc and compile wxhaskell then. (it
 worked) 
 Also, I think it's been a while I managed to do a cabal upgrade which
 didn't stop on a dependency issue.
 
 Since I didn't write down the exact problems I had, I'm attempting a
 fresh install, and I'll write down what happens as I go.
 
 1) Installing GHC 6.10.2 from the tarball, I decided to give it a try
 to ./configure --prefix=/home/david/local
 2) Adding /home/david/local' to my PATH
 3) I find a binary for cabal-install 0.6.0,
 4) cabal update
 5) cabal install cabal-install
 
 Proceeds to download and compile HTTP-4000.0.6, then zlib-0.5.0.0
 which fails because I don't have zlib.h on this new system.
 
 da...@pcdavid2:~$ sudo apt-get install
 ... well there is no zlib-dev, libzlib-dev available on Jaunty. there
 is a zlib1-dev which fails to install, and a zlib1g-dev which works.
 
 da...@pcdavid2:~$ cabal-0.6.0 install cabal-install   again.
 This time zlib-0.5.0.0 compiles, but then :
 /usr/bin/ld: cannot find -lgmp

The ghc installer should really check for this at install time rather
than us waiting for the first time you compile something for it to fail.

 da...@pcdavid2:~$ sudo apt-get install libgmp3-dev
 
 da...@pcdavid2:~$ download/cabal-0.6.0 install cabal-install
 againagain.
 
 This time all goes well except that:
 Installing executable(s) in /home/david/.cabal/bin
 why the hell would cabal install binaries in a subdirectory of a
 hidden directory. Why not /home/david/bin or /home/david/local/bin ?

Yes, this is clearly suboptimal but getting agreement on where to put it
has not proved easy. There are users that will scream and shout if we
install to $HOME/bin by default.

Please add your thoughts on the best default behaviour to this ticket:
http://hackage.haskell.org/trac/hackage/ticket/289

In my opinion, what we should do is something like:

  * By default use symlink-bindir: ~/bin  if that directory is on
the path (creating it if necessary -- but only if the dir was
already on the $PATH). In this case we would inform users that's
what we've done and about the location of the config file if
they want to change it.
  * If the ~/bin directory is not on the $PATH then we should give a
warning that binaries will be installed in ~/.cabal/bin and that
the user should either put that on the $PATH or should change
the config file to specify a symlink-bindir directory that is on
the $PATH.

The symlink-bindir feature is safe in the sense that we never
overwrite files that are not already symlinks to the location where the
actual binaries are installed (eg usually ~/.cabal/bin). So in
particular we never overwrite any actual binaries you installed there
yourself.

 da...@pcdavid2:~$ ghc-pkg check
 There are problems in package rts-1.0:
   include-dirs: PAPI_INCLUDE_DIR doesn't exist or isn't a directory

That's a known bug in ghc-6.10.2 sadly. It means for the 6.10.2 release
that ghc-pkg check is not helpful (unless you fix it the way you did).

 da...@pcdavid2:~$ download/cabal-0.6.0 install cabal-install
 Linking dist/build/cabal/cabal ...
 Installing executable(s) in /home/david/.cabal/bin
 
 WTF?
 
 da...@pcdavid2:~$ vi .cabal/config
 install-dirs user
   -- prefix: /home/david/local
   -- bindir: $prefix/bin
   -- libdir: $prefix/lib
 
 I give up for now.

Lines starting with -- are comments. You need to uncomment the prefix
line for it to have an effect.

The latest version of cabal-install makes a config file with these
instructions at the top:

-- This is the configuration file for the 'cabal' command line tool.

-- The available configuration options are listed below.
-- Some of them have default values listed.

-- Lines (like this one) beginning with '--' are comments.
-- Be careful with spaces and indentation because they are
-- used to indicate layout for nested sections.

Unfortunately I think you mentioned that you grabbed a binary of an
older version so you missed out on the improved instructions.


Duncan

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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread david48
On Wed, Apr 22, 2009 at 1:01 PM, Duncan Coutts
duncan.cou...@worc.ox.ac.ukwrote:

 On Wed, 2009-04-22 at 12:21 +0200, david48 wrote:

 Lines starting with -- are comments. You need to uncomment the prefix
 line for it to have an effect.


Man do I feel dumb now :)


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


Re: [Haskell-cafe] Re: Cabal's default install location

2009-04-22 Thread Daniel Fischer
Am Mittwoch 22 April 2009 12:06:37 schrieb Duncan Coutts:
 On Wed, 2009-04-22 at 11:33 +0200, david48 wrote:
  The default should at least be consistent among cabal install, runghc
  Setup.hs, installing GHC, Gtk2Hs, and so on.
 
  If GHC is installed in /home/myusername/local,

 Where you choose to install ghc is not related.

  what does cabal install --global ?

 Global always means /usr/local by default, unless you change it in the
 cabal config file.

 By default ghc, gtk2hs also install globally in /usr/local (unless you
 specify a --prefix.)

But when I install a binary, it always ends up in /usr/lib and /usr/bin, not in 
/usr/local. How come?
Fortunately, once I've got the first binary, it's source installs from then on 
:)


 This tradition of global and /usr/local for ./configure scripts is ok,
 but for a convenient package manager it's not necessarily ideal.

 Duncan

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


Re: [Haskell-cafe] Re: Cabal's default install location

2009-04-22 Thread Victor Nazarov
On Wed, Apr 22, 2009 at 2:06 PM, Duncan Coutts
duncan.cou...@worc.ox.ac.ukwrote:

 On Wed, 2009-04-22 at 11:33 +0200, david48 wrote:
 
  The default should at least be consistent among cabal install, runghc
  Setup.hs, installing GHC, Gtk2Hs, and so on.
 
  If GHC is installed in /home/myusername/local,

 Where you choose to install ghc is not related.

  what does cabal install --global ?

 Global always means /usr/local by default, unless you change it in the
 cabal config file.

 By default ghc, gtk2hs also install globally in /usr/local (unless you
 specify a --prefix.)

 This tradition of global and /usr/local for ./configure scripts is ok,
 but for a convenient package manager it's not necessarily ideal.

 Ubuntu/Debian policy seems to be installation into /var/lib/cabal . So it's
clear that the whole hierarchy is managed by single tool cabal. Drawback is
that you should add /var/lib/cabal/bin into your PATH.

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


Re: [Haskell-cafe] Getting the x out

2009-04-22 Thread Cristiano Paris
On Wed, Apr 22, 2009 at 2:49 AM, michael rice nowg...@yahoo.com wrote:
 How do I get the x out of Just x?

Hi Michael,

in your code you're using Maybe to inform the caller of safeDivision
about an exceptional situation. This way, you made a full coverage of
all the input cases and nothing is left out, i.e. you created a total
function (which is GOOD).

If you introduced the Nothing case, you just don't want to ignore it.
Also, the type system is forcing you to take the Nothing case into
account so you can handle it properly. Hence, you might try something
like the maybe function, which accounts for the Nothing case.

If you'd use fromJust, the Nothing case would remain uncovered,
leading you to an unhandled exception, which conflicts with your
safeDivision definition.

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


Re: [Haskell-cafe] Non-atomic atoms for type-level programming

2009-04-22 Thread Tillmann Rendel

Hi Claus,

thanks for your elaborations. I'm still not convinced that a common name 
(e.g. TT :. Tr :. Tu :. Te) is a better interface than a common import 
(e.g. TypeLevel.Bool.True). In both cases, the authors of all modules 
have to actively collaborate, either to define common names, or to 
define common imports.


But I begin to see how type-level atoms could help to, e.g., implement 
more advanced module system as type-level embedded DSLs in Haskell.



Standard ML's answer to that kind of issue is type sharing.


Does type sharing help with making modules retroactively compatible?

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


Re: [Haskell-cafe] Getting the x out

2009-04-22 Thread michael rice
It makes sense, once you understand the terminology.

Thanks.

Michael

--- On Wed, 4/22/09, Cristiano Paris fr...@theshire.org wrote:

From: Cristiano Paris fr...@theshire.org
Subject: Re: [Haskell-cafe] Getting the x out
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Wednesday, April 22, 2009, 7:55 AM

On Wed, Apr 22, 2009 at 2:49 AM, michael rice nowg...@yahoo.com wrote:
 How do I get the x out of Just x?

Hi Michael,

in your code you're using Maybe to inform the caller of safeDivision
about an exceptional situation. This way, you made a full coverage of
all the input cases and nothing is left out, i.e. you created a total
function (which is GOOD).

If you introduced the Nothing case, you just don't want to ignore it.
Also, the type system is forcing you to take the Nothing case into
account so you can handle it properly. Hence, you might try something
like the maybe function, which accounts for the Nothing case.

If you'd use fromJust, the Nothing case would remain uncovered,
leading you to an unhandled exception, which conflicts with your
safeDivision definition.

Cristiano



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


Re: [Haskell-cafe] Getting the x out

2009-04-22 Thread michael rice
Hi Neil,

I just tried out Hoogle for the first time and it works great.

It seems there are a lot of resources available for Haskell; it just takes time 
to find out about them and how they work.

Thanks.

Michael

--- On Wed, 4/22/09, Neil Mitchell ndmitch...@gmail.com wrote:

From: Neil Mitchell ndmitch...@gmail.com
Subject: Re: [Haskell-cafe] Getting the x out
To: michael rice nowg...@yahoo.com
Cc: Tony Morris tonymor...@gmail.com, haskell-cafe@haskell.org
Date: Wednesday, April 22, 2009, 1:26 AM

Hi

It's not too hard. You wanted a function that converted Maybe a - a,
you just Hoogle for it:

http://haskell.org/hoogle/?hoogle=Maybe+a+-+a

Thanks

Neil

On Wed, Apr 22, 2009 at 2:07 AM, michael rice nowg...@yahoo.com wrote:
 Got it! I figured there must be some way to unpack it.

 My goodness, there are so many functions I'm not even aware of. Has anyone
 ever counted them all?

 Thanks.

 Michael

 --- On Tue, 4/21/09, Tony Morris tonymor...@gmail.com wrote:

 From: Tony Morris tonymor...@gmail.com
 Subject: Re: [Haskell-cafe] Getting the x out
 To: michael rice nowg...@yahoo.com
 Cc: haskell-cafe@haskell.org
 Date: Tuesday, April 21, 2009, 8:54 PM

 You mean, the x out of *Maybe* x even. In the very literal sense, the
 assumption that there is an x in Maybe x is false -- there may not be
 one since it is maybe, but not necessarily, x. IT's a bit like the use
 of null that you might have seen in other languages where you might have
 a value or you might have null. What you can do however, is say give me
 the x if there is one, otherwise, use this value.

 This is the fromMaybe function.

 Prelude Data.Maybe let safeDivision x y = if y == 0 then Nothing else
 Just (x/y)
 Prelude Data.Maybe 3 + (42 `fromMaybe` safeDivision 10 5)
 5.0
 Prelude Data.Maybe 3 + (42 `fromMaybe` safeDivision 10 0)
 45.0



 michael rice wrote:
 How do I get the x out of Just x?

 Michael

 =

 safeDivision :: Float - Float - Maybe Float
 safeDivision x y = if y == 0 then Nothing else Just (x/y)

 *Main Data.List safeDivision 10 5
 Just 2.0
 *Main Data.List 3 + (safeDivision 10 5)

 interactive:1:0:
     No instance for (Num (Maybe Float))
       arising from a use of `+' at interactive:1:0-22
     Possible fix: add an instance declaration for (Num (Maybe Float))
     In the expression: 3 + (safeDivision 10 5)
     In the definition of `it': it = 3 + (safeDivision 10 5)
 *Main Data.List


 

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


 --
 Tony Morris
 http://tmorris.net/




 ___
 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: ANNOUNCE: Utrecht Haskell Compiler (UHC) --first release

2009-04-22 Thread Claus Reinke

Installing executable(s) in /home/david/.cabal/bin
why the hell would cabal install binaries in a subdirectory of a
hidden directory. Why not /home/david/bin or /home/david/local/bin ?


Yes, this is clearly suboptimal but getting agreement on where to put it
has not proved easy. There are users that will scream and shout if we
install to $HOME/bin by default.


Having learned from experience that user preferences differ wildly,
even on similar platforms, not to mention a variety of platforms or,
even worse, intentionally different forks of the same platform, and 
that trying to guess what defaults might be sensible, let alone acceptable,

can be a losing game, I'd like to offer an alternative view:

   if there is no universally acceptable default, do not use a default

Next to not being bothered with configurations they agree with, users
like to be in control, or at least be informed about what is going on,
and precisely how to change it, *before* anything happens that they
do not like.

cabal install could, on its first invocation, point to its configuration
file, explaining precisely the minimum number of changes required
to get it working (with potential defaults being present in the config
file, commented out and explained, the config file could be a config
mini-tutorial).

This would depend on few things to be acceptable:

- configuration should be straightforward, with explanations of
   possible consequences being clear and close at hand; if there
   is no config file, the tool should be able to generate a partial
   one (with disputed choices commented out) for further editing

- configuration should be persistent (never overwrite old config
   file without user permission; propagate old config to new tool
   version)

That way, nothing would happen until users are satisfied that things
will happen exactly as they like it and, once that is done, they won't
have to think about this again (until cabal changes substantially and
needs to ask for further user advice, which seems better than silently
changing behaviour).

If you want cabal to be installable in settings where no user is
available, you could either generate a full config file before install,
or add an --i-really-don't-care-about-config-settings option.

This road isn't perfect, but it can be less unacceptable than any
arbitrary set of default choices.

Claus


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


[Haskell-cafe] Using Data.Complex

2009-04-22 Thread michael rice
Just exploring. How to load?

Michael

[mich...@localhost ~]$ ghci Data.Complex
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.

no location info: module `Data.Complex' is a package module
Failed, modules loaded: none.
Prelude 




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


Re: [Haskell-cafe] Using Data.Complex

2009-04-22 Thread andy morris
2009/4/22 michael rice nowg...@yahoo.com:
 Just exploring. How to load?

 Michael

 [mich...@localhost ~]$ ghci Data.Complex
 GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer ... linking ... done.
 Loading package base ... linking ... done.

 no location info: module `Data.Complex' is a package module
 Failed, modules loaded: none.
 Prelude



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



Try ':module + Data.Complex' from within GHCi. (Or 'import
Data.Complex' from within a source file, of course.)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Non-atomic atoms for type-level programming

2009-04-22 Thread Achim Schneider
Tillmann Rendel ren...@cs.au.dk wrote:

 Hi Claus,
 
 thanks for your elaborations. I'm still not convinced that a common
 name (e.g. TT :. Tr :. Tu :. Te) is a better interface than a common
 import (e.g. TypeLevel.Bool.True). In both cases, the authors of all
 modules have to actively collaborate, either to define common names,
 or to define common imports.
 
 But I begin to see how type-level atoms could help to, e.g.,
 implement more advanced module system as type-level embedded DSLs in
 Haskell.
 
  Standard ML's answer to that kind of issue is type sharing.
 
 Does type sharing help with making modules retroactively compatible?
 

map (\i - rot13 i) import Foo

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Achim Schneider
Richard O'Keefe o...@cs.otago.ac.nz wrote:

 On 21 Apr 2009, at 11:36 pm, Achim Schneider wrote:
 
  Richard O'Keefe o...@cs.otago.ac.nz wrote:
   
  Some of the right questions are
   - how many potential whatever users would need to have  
 whatever installed on _some_ machine they do NOT have  
 administrator access to?
   
  Irrelevant.  
 
 How van the question that is the very heart of this thread
 be irrelevant?
 
 This is precisely the situation I'm in, and it's precisely
 the class of users I'm arguing for.
 
 I'm encouraged by the constructive suggestions of package
 tools (nix, portage) that are said to address some of these
 issues.  Except of course that I have to install them first...

It's irrelevant, because I _do_ have root access to my machine, but
don't want to get forced into using it by a question that implies that
if you have access, you're going to use it. I didn't mean to nit pick,
though, I thought you were arguing for the other side...

I think the right question is how many people prefer user installs
over system installs, wrt. their hackage packages?. 

I estimate that, concerning developers, who are used to install
still-buggy, self-written libraries, as well as install things while
working, the percentage is very, very high: At least I don't want my
workflow to be broken to deal with the formal requirements of a global
install while developing, and I guess many others feel the same way.[1]

Endusers, of course, might have other preferences, but cabal doesn't
(IMHO) cater to them, directly: It caters to distribution packages (or
windows installers, or whatever), so cabal's default behaviour is quite
irrelevant for those cases.

[1] Thinking of it... is there a way to tell cabal to pretend a package
is installed by giving the path to it's source directory? Just like
include directories, but with packages.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread John A. De Goes


That's absurd. You have no way to access private source code, so any  
decision on what features to exclude from future versions of Haskell  
must necessarily look at publicly accessible source code. The only  
alternative is to continuously add, and never remove, features from  
Haskell, even if no one (that we know) uses them.


Moreover, the odds that everyone who is using n + k patterns are doing  
so only in private is an untestable hypothesis (i.e. unscientific) and  
extremely unlikely to be true.


Regards,

John A. De Goes
N-BRAIN, Inc.
The Evolution of Collaboration

http://www.n-brain.net|877-376-2724 x 101

On Apr 21, 2009, at 9:34 PM, Richard O'Keefe wrote:


It *is* true that things that *are* used in the commonly
available sources should continue to be supported in order
to preserve the value of those commonly available sources.
It is *not* true that things that are *not* used in the
commonly available sources are therefore of no value and
safely to be discarded.


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


Re: [Haskell-cafe] Non-atomic atoms for type-level programming

2009-04-22 Thread Claus Reinke
thanks for your elaborations. I'm still not convinced that a common name 
(e.g. TT :. Tr :. Tu :. Te) is a better interface than a common import 
(e.g. TypeLevel.Bool.True). In both cases, the authors of all modules 
have to actively collaborate, either to define common names, or to 
define common imports.


It is not a solution, it is a workaround. All it does is offer users another 
choice, so they can now say whether they are talking about shared or

locally defined labels:

module A where 
import Data.Label

data MyLabel
x = [$l|label|]
y = undefined::MyLabel

module B where 
import Data.Label

data MyLabel
x = [$l|label|]
y = undefined::MyLabel

module C where
import Data.Label
import A
import B
ok = [A.x,B.x]
fails = [A.y,B.y]

It does so by offering a meta-level commonality: A and B do not have
to agree on a common module to declare all their common types (the 
author of Data.Label has no idea what labels its importers might use,
other than the alphabet the labels are constructed from), they only 
need to agree on a common way of declaring all their shareable types.


But I begin to see how type-level atoms could help to, e.g., implement 
more advanced module system as type-level embedded DSLs in Haskell.


Well, atoms make labels, labels form extensible record fields, extensible 
records can be used as first-class modules, but there'd still be a lot missing.


This is really just a small step, and though it is a useful one, it has no such
high aspirations, yet. When I wrote the first-class-labels proposal for
Haskell', I was thinking about possible implementations (outlined in the
haskell prime wiki page I referred to) but they always looked as if they'd
require substantial changes. This workaround suggests that a few 
well-placed localised changes to GHC might be sufficient to get first-class

labels - just split the modifications over two, only losely coupled areas:

- provide label constructors
- provide label usage (preferably hiding the internal structure)

Until someone does that, quasiquoting offers a workaround, so people
can resume playing with things like type-level numbers, extensible record
libraries with and without label ordering, etc. I've filed a feature request
for type-level quasiquoting, in case anyone else has such needs:-)

http://hackage.haskell.org/trac/ghc/ticket/3177


Standard ML's answer to that kind of issue is type sharing.


Does type sharing help with making modules retroactively compatible?


It has been too long since I looked at this in detail, but yes. The way
I recall it (and the early example in [1] seems to confirm this, though
SML has changed after that paper was published) is that modules
have signatures, and type sharing constraints assert that parts of
these signatures have to match up (in Haskell-speak: imagine modules
as records, with two records R1 a and R2 b, then we can use a type 
'a~b = R1 a - R2 b - T' to assert that both records share the

same type parameter; only that Haskell modules aren't records
and aren't parameterized..).

It would be as if one could write modules parameterised by types,
instead of declaring them locally, and being able to share a type
parameter over several imports:

module A(type label) where x = undefined :: label
module B(type label) where x = undefined :: label

module C(type label) where
import A[label]
import B[label]
ok = [A.x,B.x]

Claus

[1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.14.3595
   Robert Harper and Mark Lillibridge,
   A Type-Theoretic Approach to Higher-Order Modules with Sharing


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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) --first release

2009-04-22 Thread Achim Schneider
Claus Reinke claus.rei...@talk21.com wrote:

 [...]

+1. That, and better error messages: A Verbose-Consequences flag in the
config (on by default), resulting in strings like Binaries have been
installed to $HOME/.cabal/bin and _not_ symlinked. $HOME/.cabal/bin is
not in your $PATH: You will not be able to call them directly from the
command line, and programs depending on them might be unable to locate
them, resulting in failure or limited functionality.

Hell, I never thought I'd ever advertise the usage of disclaimers...

Gentoo does this, too, btw: Remember, you have to be in the group
games to play games, You chose to build firefox with official
branding, distributing the binary (even in your local network) might
result in legal problems with the Mozilla Foundation. 

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


Re: [Haskell-cafe] ANN: Elerea, another FRP library

2009-04-22 Thread Patai Gergely
  network. Therefore, duplication and merging of identical
  expressions only affects the performance unless they are
  hidden in the input signal of a latcher.
 
 But isn't the latter a fundamental problem?
Of course it is, but I said afterwards that this can be resolved by
sampling 'more thoroughly'.

 If the time signal is evaluated only once then for any signal
 c, timeSwitching c should be equivalent to time. But what if I
 replace time by stateful 0 (+) in the definition of
 timeSwitching? If stateful 0 (+) is evaluated everytime a
 switch occurs then timeSwitching would always switch back to
 time 0.
The value stored in a constant signal is supposed to be evaluated
exactly once, therefore in this case the expected behaviour is that
timeSwitching is equivalent to time. The meaning of 'pure sig' is a
signal that refers to 'sig' at every point. At the present moment, if
you express the same by lifting the signal constructor directly, it will
also be evaluated exactly once, but only when the control signal is true
for the first time. This is obviously wrong, but it can be cured by
forcing evaluation at the beginning.

This also means that if you want to restart a signal without external
dependencies using a latcher, you have to inject some bogus dependency
to prevent memoisation. If the new signal depends on some others,
latching should behave intuitively.

 So one first has to answer the question what the intended
 semantics should be.  Should signals start at the beginning or
 should they start every time they are switched into?
Clearing up the semantics is certainly on my todo list. :)

 Implementing the first semantics is difficult since the system
 would have to know what signals will be used later. I think
 this is impossible in general because of undecidability
 issues. (Grapefruit's approach is to force the user to specify
 what signals are used later.)
Do you have a compact use case that demonstrates this problem?

 Implementing the second semantics would require a single signal
 having possibly different values when started at different
 times. This in turn would disallow caching of signal values in
 mutable variables.
Or at least it would require deep copying some initial snapshot at every
restart. But this only applies to completely self-contained signals,
since anything that depends on the outer world cannot be restarted by
definition.

Gergely

-- 
http://www.fastmail.fm - Faster than the air-speed velocity of an
  unladen european swallow

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


Re: [Haskell-cafe] Non-atomic atoms for type-level programming

2009-04-22 Thread Claus Reinke

in case anyone stumbles over my ad-hoc notations, that should have been:


module A[type label] where x = undefined :: label
module B[type label] where x = undefined :: label



module C[type label] where
import A[label]
import B[label]
ok = [A.x,B.x]


assuming that:

- 'module X[types]' means a module parameterized by 'types'
- 'import X[types]' means a module import with parameters 'types'.

Claus


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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Achim Schneider
Richard O'Keefe et all wrote:

 [n+k patterns]
 
I'd like to add my two cents: Assuming that UHC's roadmap strives to be
H'-compilant in the future, and n+k patterns aren't going to be in H',
why bother implementing them?

Also, assuming that current H98 code will be ported to H', shouldn't
n+k patterns be removed from existing code, anyway?

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


[Haskell-cafe] Re: Is 78 characters still a good option? Was: breaking too long lines

2009-04-22 Thread Achim Schneider
Jason Dusek jason.du...@gmail.com wrote:

   Really, the whole thing makes me wish we had blasphemy laws.
 
 If any person, in speaking or in writing, shall indicate
 a preference for column widths other than 80 or indent
 characters other than spaces (`0x20`) they shall be
 compelled to present some science or be subject to
 imprisonment.
 
I'll definitely add it to the list of questions should I ever conduct a
job interview. Just to test how much backing people have for their zeal.


-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


[Haskell-cafe] haxr build failure from cabal

2009-04-22 Thread Jeff Heard
haxr will no longer compile from cabal because of the dependency
marked HTTP  1.0.  The current version of the library requires HTTP 
4000.0.0 as it stands.  Can it be updated real quick in hackage?

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


Re: [Haskell-cafe] Re: Is 78 characters still a good option? Was: breaking too long lines

2009-04-22 Thread John A. De Goes


Another reason for the 80 character limit: some developers have very  
poor eyesight, which can be overcome with large monitors and large  
fonts. This won't work if you have to scroll the code.


Regards,

John A. De Goes
N-BRAIN, Inc.
The Evolution of Collaboration

http://www.n-brain.net|877-376-2724 x 101

On Apr 22, 2009, at 8:32 AM, Achim Schneider wrote:


Jason Dusek jason.du...@gmail.com wrote:


 Really, the whole thing makes me wish we had blasphemy laws.

   If any person, in speaking or in writing, shall indicate
   a preference for column widths other than 80 or indent
   characters other than spaces (`0x20`) they shall be
   compelled to present some science or be subject to
   imprisonment.

I'll definitely add it to the list of questions should I ever  
conduct a
job interview. Just to test how much backing people have for their  
zeal.



--
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


___
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: Is 78 characters still a good option? Was: breaking too long lines

2009-04-22 Thread David Leimbach
I've found that some developers have very poor taste in shirts as well,
therefore Haskell should have a dress code
Sorry I'm not buying 80 characters as a way to address bad eyesight.  ;-)  I
think there's supposed to be technology in the editors to deal with that...
just as we can try to find good women to dress us better.



On Wed, Apr 22, 2009 at 7:38 AM, John A. De Goes j...@n-brain.net wrote:


 Another reason for the 80 character limit: some developers have very poor
 eyesight, which can be overcome with large monitors and large fonts. This
 won't work if you have to scroll the code.

 Regards,

 John A. De Goes
 N-BRAIN, Inc.
 The Evolution of Collaboration

 http://www.n-brain.net|877-376-2724 x 101

 On Apr 22, 2009, at 8:32 AM, Achim Schneider wrote:

  Jason Dusek jason.du...@gmail.com wrote:

   Really, the whole thing makes me wish we had blasphemy laws.

   If any person, in speaking or in writing, shall indicate
   a preference for column widths other than 80 or indent
   characters other than spaces (`0x20`) they shall be
   compelled to present some science or be subject to
   imprisonment.

  I'll definitely add it to the list of questions should I ever conduct a
 job interview. Just to test how much backing people have for their zeal.


 --
 (c) this sig last receiving data processing entity. Inspect headers
 for copyright history. All rights reserved. Copying, hiring, renting,
 performance and/or quoting of this signature prohibited.


 ___
 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: haxr build failure from cabal

2009-04-22 Thread Christian Maeder
I think you can pass --preference=HTTP==3001.1.5 to cabal-install
0.6.2, try

  cabal install haxr --preference=HTTP==3001.1.5

Cheers Christian

Jeff Heard wrote:
 haxr will no longer compile from cabal because of the dependency
 marked HTTP  1.0.  The current version of the library requires HTTP 
 4000.0.0 as it stands.  Can it be updated real quick in hackage?
 
 -- Jeff
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haxr build failure from cabal

2009-04-22 Thread Sigbjorn Finne

Hi Jeff,

I have an updated and _seemingly_ working version of the haxr codebase,
but haven't had a chance to test it more than a gentle poke at the tires.

Will see if I can upload  commit the bits.

--sigbjorn

On 4/22/2009 07:37, Jeff Heard wrote:

haxr will no longer compile from cabal because of the dependency
marked HTTP  1.0.  The current version of the library requires HTTP 
4000.0.0 as it stands.  Can it be updated real quick in hackage?

-- Jeff
___
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] Overriding a Prelude function?

2009-04-22 Thread michael rice
I've been working through this example from: 
http://en.wikibooks.org/wiki/Haskell/Understanding_monads

I understand what they're doing all the way up to the definition of (), which 
duplicates Prelude function (). To continue following the example, I need to 
know how to override the Prelude () with the () definition in my file 
rand.hs.

Michael

==

[mich...@localhost ~]$ cat rand.hs
import System.Random

type Seed = Int

randomNext :: Seed - Seed
randomNext rand = if newRand  0 then newRand else newRand + 2147483647
    where newRand = 16807 * lo - 2836 * hi
  (hi,lo) = rand `divMod` 127773

toDieRoll :: Seed - Int
toDieRoll seed = (seed `mod` 6) + 1

rollDie :: Seed - (Int, Seed)
rollDie seed = ((seed `mod` 6) + 1, randomNext seed)

sumTwoDice :: Seed - (Int, Seed)
sumTwoDice seed0 =
  let (die1, seed1) = rollDie seed0
  (die2, seed2) = rollDie seed1
  in (die1 + die2, seed2)

() m n = \seed0 -
  let (result1, seed1) = m seed0
  (result2, seed2) = n seed1
  in (result2, seed2)

[mich...@localhost ~]$ 




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


Re: [Haskell-cafe] Overriding a Prelude function?

2009-04-22 Thread Ross Mellgren

I think

import Prelude hiding (())

does that.

-Ross

On Apr 22, 2009, at 11:44 AM, michael rice wrote:


I've been working through this example from: 
http://en.wikibooks.org/wiki/Haskell/Understanding_monads

I understand what they're doing all the way up to the definition of  
(), which duplicates Prelude function (). To continue following  
the example, I need to know how to override the Prelude () with  
the () definition in my file rand.hs.


Michael

==

[mich...@localhost ~]$ cat rand.hs
import System.Random

type Seed = Int

randomNext :: Seed - Seed
randomNext rand = if newRand  0 then newRand else newRand +  
2147483647

where newRand = 16807 * lo - 2836 * hi
  (hi,lo) = rand `divMod` 127773

toDieRoll :: Seed - Int
toDieRoll seed = (seed `mod` 6) + 1

rollDie :: Seed - (Int, Seed)
rollDie seed = ((seed `mod` 6) + 1, randomNext seed)

sumTwoDice :: Seed - (Int, Seed)
sumTwoDice seed0 =
  let (die1, seed1) = rollDie seed0
  (die2, seed2) = rollDie seed1
  in (die1 + die2, seed2)

() m n = \seed0 -
  let (result1, seed1) = m seed0
  (result2, seed2) = n seed1
  in (result2, seed2)

[mich...@localhost ~]$


___
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] Overriding a Prelude function?

2009-04-22 Thread Tim Wawrzynczak
You can try at the top
Import Prelude hiding ()

On Wed, Apr 22, 2009 at 10:44 AM, michael rice nowg...@yahoo.com wrote:

 I've been working through this example from:
 http://en.wikibooks.org/wiki/Haskell/Understanding_monads

 I understand what they're doing all the way up to the definition of (),
 which duplicates Prelude function (). To continue following the example, I
 need to know how to override the Prelude () with the () definition in my
 file rand.hs.

 Michael

 ==

 [mich...@localhost ~]$ cat rand.hs
 import System.Random

 type Seed = Int

 randomNext :: Seed - Seed
 randomNext rand = if newRand  0 then newRand else newRand + 2147483647
 where newRand = 16807 * lo - 2836 * hi
   (hi,lo) = rand `divMod` 127773

 toDieRoll :: Seed - Int
 toDieRoll seed = (seed `mod` 6) + 1

 rollDie :: Seed - (Int, Seed)
 rollDie seed = ((seed `mod` 6) + 1, randomNext seed)

 sumTwoDice :: Seed - (Int, Seed)
 sumTwoDice seed0 =
   let (die1, seed1) = rollDie seed0
   (die2, seed2) = rollDie seed1
   in (die1 + die2, seed2)

 () m n = \seed0 -
   let (result1, seed1) = m seed0
   (result2, seed2) = n seed1
   in (result2, seed2)

 [mich...@localhost ~]$



 ___
 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: Cabal's default install location

2009-04-22 Thread david48
On Wed, Apr 22, 2009 at 1:28 PM, Victor Nazarov
asviraspossi...@gmail.comwrote:


 Ubuntu/Debian policy seems to be installation into /var/lib/cabal . So it's
 clear that the whole hierarchy is managed by single tool cabal. Drawback is
 that you should add /var/lib/cabal/bin into your PATH.


(K)Ubuntu is so far back on GHC releases that I never install anything
haskell from the repositories :(
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problems with Haskell Program Coverage

2009-04-22 Thread Dominic Steinitz
I want to use hpc to check that the ASN.1 library tests cover all the code. 
When I run it with a set of tests that I *know* don't test certain things, it 
reports that they have been covered i.e. there are not coloured in the markup 
that hpc produces. I would have expected a lot of yellow.

It seems to work ok on small amounts of code so I'm not clear what I'm doing 
wrong. I'd be happy to provide the .tix file or put the .html files somewhere 
if that would be helpful.

Here's what I use:

ghc -o NewTest NewTest.hs -fhpc --make

NewTest

hpc markup NewTest

Dominic.

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


Re: [Haskell-cafe] Overriding a Prelude function?

2009-04-22 Thread Dan Weston
Be aware that the do unsugars to (Prelude.), not your (), even if 
you hide (Prelude.):


import Prelude hiding (())
m  f = error Call me!
main = putStrLn . show $ do [3,4]
[5]

The desugaring of the do { [3,4]; [5] } is (Prelude.) [3,4] [5] = 
[5,5], whereas you might have hoped for [3,4]  [5] = error Call me!


Dan

Ross Mellgren wrote:

I think

import Prelude hiding (())

does that.

-Ross

On Apr 22, 2009, at 11:44 AM, michael rice wrote:

I've been working through this example from: 
http://en.wikibooks.org/wiki/Haskell/Understanding_monads


I understand what they're doing all the way up to the definition of 
(), which duplicates Prelude function (). To continue following 
the example, I need to know how to override the Prelude () with the 
() definition in my file rand.hs.


Michael

==

[mich...@localhost ~]$ cat rand.hs
import System.Random

type Seed = Int

randomNext :: Seed - Seed
randomNext rand = if newRand  0 then newRand else newRand + 2147483647
where newRand = 16807 * lo - 2836 * hi
  (hi,lo) = rand `divMod` 127773

toDieRoll :: Seed - Int
toDieRoll seed = (seed `mod` 6) + 1

rollDie :: Seed - (Int, Seed)
rollDie seed = ((seed `mod` 6) + 1, randomNext seed)

sumTwoDice :: Seed - (Int, Seed)
sumTwoDice seed0 =
  let (die1, seed1) = rollDie seed0
  (die2, seed2) = rollDie seed1
  in (die1 + die2, seed2)

() m n = \seed0 -
  let (result1, seed1) = m seed0
  (result2, seed2) = n seed1
  in (result2, seed2)

[mich...@localhost ~]$


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org mailto: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] Overriding a Prelude function?

2009-04-22 Thread Ross Mellgren
True enough -- if you really want to redefine the monadic operator,  
you have to use


{-# LANGUAGE NoImplicitPrelude #-}

import Prelude hiding ((), (=), return)

or something like it, although Michael's example didn't appear to be  
going quite that far.


-Ross

On Apr 22, 2009, at 12:37 PM, Dan Weston wrote:

Be aware that the do unsugars to (Prelude.), not your (), even  
if you hide (Prelude.):


import Prelude hiding (())
m  f = error Call me!
main = putStrLn . show $ do [3,4]
   [5]

The desugaring of the do { [3,4]; [5] } is (Prelude.) [3,4] [5] =  
[5,5], whereas you might have hoped for [3,4]  [5] = error Call  
me!


Dan

Ross Mellgren wrote:

I think
import Prelude hiding (())
does that.
-Ross
On Apr 22, 2009, at 11:44 AM, michael rice wrote:

I've been working through this example from: 
http://en.wikibooks.org/wiki/Haskell/Understanding_monads

I understand what they're doing all the way up to the definition  
of (), which duplicates Prelude function (). To continue  
following the example, I need to know how to override the Prelude  
() with the () definition in my file rand.hs.


Michael

==

[mich...@localhost ~]$ cat rand.hs
import System.Random

type Seed = Int

randomNext :: Seed - Seed
randomNext rand = if newRand  0 then newRand else newRand +  
2147483647

   where newRand = 16807 * lo - 2836 * hi
 (hi,lo) = rand `divMod` 127773

toDieRoll :: Seed - Int
toDieRoll seed = (seed `mod` 6) + 1

rollDie :: Seed - (Int, Seed)
rollDie seed = ((seed `mod` 6) + 1, randomNext seed)

sumTwoDice :: Seed - (Int, Seed)
sumTwoDice seed0 =
 let (die1, seed1) = rollDie seed0
 (die2, seed2) = rollDie seed1
 in (die1 + die2, seed2)

() m n = \seed0 -
 let (result1, seed1) = m seed0
 (result2, seed2) = n seed1
 in (result2, seed2)

[mich...@localhost ~]$


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org mailto: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] astronomy projects in haskell

2009-04-22 Thread Michael Litchard
I remember reading some website, that dons (probably) posted once. I'd
like to find them again for a report I'm doing. So, if you know of any
astronomy websites that talk about projects using haskell, please let
me know.

thanks


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


Re: [Haskell-cafe] astronomy projects in haskell

2009-04-22 Thread Deniz Dogan
2009/4/22 Michael Litchard mich...@schmong.org:
 I remember reading some website, that dons (probably) posted once. I'd
 like to find them again for a report I'm doing. So, if you know of any
 astronomy websites that talk about projects using haskell, please let
 me know.

 thanks


 Michael Litchard

Could this be what you meant?

http://www.absoluteastronomy.com/topics/Haskell_(programming_language)

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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Jason Dusek
2009/04/22 Miguel Mitrofanov miguelim...@yandex.ru:
 It's arrogant and disrespectful on the part of the
 implementors to say that they know better than the committee
 what features should be part of the language.

 It's arrogant and disrespectful on the part of the committee
 to say that they know better than the implementors what
 features should they implement.

  So what is the committee there for? To approve helpful
  suggestions?

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


Re: [Haskell-cafe] Re: Is 78 characters still a good option? Was: breaking too long lines

2009-04-22 Thread Jason Dusek
2009/04/22 Achim Schneider bars...@web.de:
 Jason Dusek jason.du...@gmail.com wrote:
 Really, the whole thing makes me wish we had blasphemy laws.

 I'll definitely add it to the list of questions should I ever
 conduct a job interview. Just to test how much backing people
 have for their zeal.

  I'm sure you'll find plenty of college grads willing to use long
  lines. The decline in religiosity in recent years is a well known
  phenomenon.

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


Re: [Haskell-cafe] haxr build failure from cabal

2009-04-22 Thread Sigbjorn Finne

OK, new release of haxr available via hackage; compilable with ghc-6.10.1
(but may very well have bootstrap issues with 6.10.2 due to 'time' 
dependency)


  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haxr

enjoy
--sigbjorn

Sigbjorn Finne wrote:

Hi Jeff,

I have an updated and _seemingly_ working version of the haxr codebase,
but haven't had a chance to test it more than a gentle poke at the tires.

Will see if I can upload  commit the bits.

--sigbjorn

On 4/22/2009 07:37, Jeff Heard wrote:

haxr will no longer compile from cabal because of the dependency
marked HTTP  1.0.  The current version of the library requires HTTP 
4000.0.0 as it stands.  Can it be updated real quick in hackage?

-- Jeff
___
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] astronomy projects in haskell

2009-04-22 Thread Gwern Branwen
On Wed, Apr 22, 2009 at 1:17 PM, Deniz Dogan deniz.a.m.do...@gmail.com wrote:
 2009/4/22 Michael Litchard mich...@schmong.org:
 Could this be what you meant?

 http://www.absoluteastronomy.com/topics/Haskell_(programming_language)

 Deniz Dogan

That being just a Wikipedia mirror, seems pretty unlikely. (No idea
what the desired result could be. There was a pretty widespread
technical report on using Scheme to control telescopes, which had some
cool tricks in it, but that's obviously not Haskell.)

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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Miguel Mitrofanov


On 22 Apr 2009, at 21:19, Jason Dusek wrote:


2009/04/22 Miguel Mitrofanov miguelim...@yandex.ru:

It's arrogant and disrespectful on the part of the
implementors to say that they know better than the committee
what features should be part of the language.


It's arrogant and disrespectful on the part of the committee
to say that they know better than the implementors what
features should they implement.


 So what is the committee there for? To approve helpful
 suggestions?


To give advice(s). Like, for example, W3C.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread David Leimbach
On Wed, Apr 22, 2009 at 10:19 AM, Jason Dusek jason.du...@gmail.com wrote:

 2009/04/22 Miguel Mitrofanov miguelim...@yandex.ru:
  It's arrogant and disrespectful on the part of the
  implementors to say that they know better than the committee
  what features should be part of the language.
 
  It's arrogant and disrespectful on the part of the committee
  to say that they know better than the implementors what
  features should they implement.

  So what is the committee there for? To approve helpful
  suggestions?


The fun of sharing code is that you get to deal with the peanut gallery...
Oh right, that's why I don't share.




 --
 Jason Dusek
 ___
 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] breaking too long lines

2009-04-22 Thread Luke Palmer
On Mon, Apr 20, 2009 at 8:44 AM, Tillmann Rendel ren...@cs.au.dk wrote:

 However, I would prefer the following Coq-like syntax:

  data Maybe a =
| Just a
| Nothing


Of course, Coq's inductive syntax is just GADT form:

Inductive Maybe a :=
| Just : a - Maybe a
| Nothing : Maybe a.

data Maybe a where
Just :: a - Maybe a
Nothing :: Maybe a

I find GADT syntax much clearer than H98 syntax, so I use it when I'm not
being picky about compatibility.  :-)

(And yes, I know you just meant the optional leading bar)

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


Re: [Haskell-cafe] Overriding a Prelude function?

2009-04-22 Thread Thomas van Noort

You can hide () from the implicit import of Prelude using:

import Prelude hiding (())

Kind regards,
Thomas

michael rice wrote:
I've been working through this example from: 
http://en.wikibooks.org/wiki/Haskell/Understanding_monads


I understand what they're doing all the way up to the definition of 
(), which duplicates Prelude function (). To continue following the 
example, I need to know how to override the Prelude () with the () 
definition in my file rand.hs.


Michael

==

[mich...@localhost ~]$ cat rand.hs
import System.Random

type Seed = Int

randomNext :: Seed - Seed
randomNext rand = if newRand  0 then newRand else newRand + 2147483647
where newRand = 16807 * lo - 2836 * hi
  (hi,lo) = rand `divMod` 127773

toDieRoll :: Seed - Int
toDieRoll seed = (seed `mod` 6) + 1

rollDie :: Seed - (Int, Seed)
rollDie seed = ((seed `mod` 6) + 1, randomNext seed)

sumTwoDice :: Seed - (Int, Seed)
sumTwoDice seed0 =
  let (die1, seed1) = rollDie seed0
  (die2, seed2) = rollDie seed1
  in (die1 + die2, seed2)

() m n = \seed0 -
  let (result1, seed1) = m seed0
  (result2, seed2) = n seed1
  in (result2, seed2)

[mich...@localhost ~]$





___
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] Getting the x out

2009-04-22 Thread Jake McArthur

michael rice wrote:

Got it! I figured there must be some way to unpack it.


If you peek at the thread about getting a value out of IO [1], you will 
see some similarities. If you look at my response [2], you will see that 
the functions I suggested for IO are exactly the same as the functions 
you may want to consider for this case!


fmap, liftA, liftM, ($) :: Functor f = (a - b) - (f a - f b)
(*), ap :: Applicative f = f (a - b) - (f a - f b)
(=) :: Monad m = (a - m b) - (m a - m b)

So, for Maybe, you have:

($) :: (a - b) - (Maybe a - Maybe b)
(*) :: Maybe (a - b) - (Maybe a - Maybe b)
(=) :: (a - Maybe b) - (Maybe a - Maybe b)

You will find that a *lot* of the functions you learn in Haskell are 
actually very general, and once you internalize what they *really* do, 
you will suddenly have entire classes of problems solved by just a few 
functions.


- Jake

[1] http://www.haskell.org/pipermail/haskell-cafe/2009-April/059834.html
[2] http://www.haskell.org/pipermail/haskell-cafe/2009-April/059852.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Overriding a Prelude function?

2009-04-22 Thread michael rice
Here's what I get:

[mich...@localhost ~]$ ghci
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude import Prelude hiding (())

interactive:1:0: parse error on input `import'
Prelude 

=

I was passing seed0 to rollDie and getting back (r1,seed1)
 passing seed1 to rollDie and getting back (r2,seed2)
 passing seed2 to rollDie and getting back (r3,seed3)

Just based on the problem text, I would guess that
    passing rollDie and seed0 to () I would get back (r3,seed3),
losing the intermediate random numbers r1 and r2 along the way, at
least that's what I understood it to say.

So, I know that next I'm probably going to have to do something to 
remedy that, but I haven't gotten to that next step yet. What is unsugar?

Thanks in advance for your patience.

Michael


--- On Wed, 4/22/09, Dan Weston weston...@imageworks.com wrote:

From: Dan Weston weston...@imageworks.com
Subject: Re: [Haskell-cafe] Overriding a Prelude function?
To: Ross Mellgren rmm-hask...@z.odi.ac
Cc: michael rice nowg...@yahoo.com, haskell-cafe@haskell.org 
haskell-cafe@haskell.org
Date: Wednesday, April 22, 2009, 12:37 PM

Be aware that the do unsugars to (Prelude.), not your (), even if you hide 
(Prelude.):

import Prelude hiding (())
m  f = error Call me!
main = putStrLn . show $ do [3,4]
                            [5]

The desugaring of the do { [3,4]; [5] } is (Prelude.) [3,4] [5] = [5,5], 
whereas you might have hoped for [3,4]  [5] = error Call me!

Dan

Ross Mellgren wrote:
 I think
 
 import Prelude hiding (())
 
 does that.
 
 -Ross
 
 On Apr 22, 2009, at 11:44 AM, michael rice wrote:
 
 I've been working through this example from: 
 http://en.wikibooks.org/wiki/Haskell/Understanding_monads
 
 I understand what they're doing all the way up to the definition of (), 
 which duplicates Prelude function (). To continue following the example, I 
 need to know how to override the Prelude () with the () definition in my 
 file rand.hs.
 
 Michael
 
 ==
 
 [mich...@localhost ~]$ cat rand.hs
 import System.Random
 
 type Seed = Int
 
 randomNext :: Seed - Seed
 randomNext rand = if newRand  0 then newRand else newRand + 2147483647
     where newRand = 16807 * lo - 2836 * hi
           (hi,lo) = rand `divMod` 127773
 
 toDieRoll :: Seed - Int
 toDieRoll seed = (seed `mod` 6) + 1
 
 rollDie :: Seed - (Int, Seed)
 rollDie seed = ((seed `mod` 6) + 1, randomNext seed)
 
 sumTwoDice :: Seed - (Int, Seed)
 sumTwoDice seed0 =
   let (die1, seed1) = rollDie seed0
       (die2, seed2) = rollDie seed1
   in (die1 + die2, seed2)
 
 () m n = \seed0 -
   let (result1, seed1) = m seed0
       (result2, seed2) = n seed1
   in (result2, seed2)
 
 [mich...@localhost ~]$
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org mailto: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] ANNOUNCE: dataenc 0.12.1.0

2009-04-22 Thread Magnus Therning
I've just uploaded version 0.12.1.0 of dataenc with the following (visible)
changes compared to the previous version (0.12):

 - implementation of a bunch of new encodings:
   - xxencode
   - hexadecimal
   - quoted-printable
   - python escaping
   - url encoding
 - squashing of a bug in the yEncoding implementation that only
manifested on
   32-bit systems
 - an attempt to conform to the guidelines for the Haskell Platform
   regarding versioning and dependencies

This release brings the full list of encodings to

 - Base16
 - Base32
 - Base32Hex
 - Base64
 - Base64Url
 - Base85
 - Hexadecimal
 - Python string escaping
 - quoted-printable
 - URL encoding
 - uuencoding
 - xxencoding
 - yEncoding

The hackage page[1] now reads:

  Versions  0.9, 0.10.1, 0.10.2, 0.11, 0.11.1, 0.12, 0.12.1.0
  Dependencies  array (=0.2.0  0.3), base (=4.0.0  4.1),
containers (=0.2.0  0.3)
  License   BSD3
  Copyright Magnus Therning, 2007-2009
  AuthorMagnus Therning
  Maintainermag...@therning.org
  Category  Codec
  Home page http://www.haskell.org/haskellwiki/Library/Data_encoding
  Upload date   Wed Apr 22 19:40:22 UTC 2009
  Uploaded by   MagnusTherning

/M

[1]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dataenc

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe

Haskell is an even 'redder' pill than Lisp or Scheme.
 -- PaulPotts



signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Overriding a Prelude function?

2009-04-22 Thread Luke Palmer
On Wed, Apr 22, 2009 at 1:47 PM, michael rice nowg...@yahoo.com wrote:

 Here's what I get:

 [mich...@localhost ~]$ ghci
 GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer ... linking ... done.
 Loading package base ... linking ... done.
 Prelude import Prelude hiding (())


You know, to avoid this nonsense you could just name the operator something
else, like ~, or ~, or $...@**!.  Operators are just names.

Luke




 interactive:1:0: parse error on input `import'
 Prelude

 =

 I was passing seed0 to rollDie and getting back (r1,seed1)
  passing seed1 to rollDie and getting back (r2,seed2)
  passing seed2 to rollDie and getting back (r3,seed3)

 Just based on the problem text, I would guess that
 passing rollDie and seed0 to () I would get back (r3,seed3),
 losing the intermediate random numbers r1 and r2 along the way, at
 least that's what I understood it to say.

 So, I know that next I'm probably going to have to do something to
 remedy that, but I haven't gotten to that next step yet. What is unsugar?

 Thanks in advance for your patience.

 Michael


 --- On *Wed, 4/22/09, Dan Weston weston...@imageworks.com* wrote:


 From: Dan Weston weston...@imageworks.com
 Subject: Re: [Haskell-cafe] Overriding a Prelude function?
 To: Ross Mellgren rmm-hask...@z.odi.ac
 Cc: michael rice nowg...@yahoo.com, haskell-cafe@haskell.org 
 haskell-cafe@haskell.org
 Date: Wednesday, April 22, 2009, 12:37 PM

 Be aware that the do unsugars to (Prelude.), not your (), even if you
 hide (Prelude.):

 import Prelude hiding (())
 m  f = error Call me!
 main = putStrLn . show $ do [3,4]
 [5]

 The desugaring of the do { [3,4]; [5] } is (Prelude.) [3,4] [5] = [5,5],
 whereas you might have hoped for [3,4]  [5] = error Call me!

 Dan

 Ross Mellgren wrote:
  I think
 
  import Prelude hiding (())
 
  does that.
 
  -Ross
 
  On Apr 22, 2009, at 11:44 AM, michael rice wrote:
 
  I've been working through this example from:
 http://en.wikibooks.org/wiki/Haskell/Understanding_monads
 
  I understand what they're doing all the way up to the definition of
 (), which duplicates Prelude function (). To continue following the
 example, I need to know how to override the Prelude () with the ()
 definition in my file rand.hs.
 
  Michael
 
  ==
 
  [mich...@localhost ~]$ cat rand.hs
  import System.Random
 
  type Seed = Int
 
  randomNext :: Seed - Seed
  randomNext rand = if newRand  0 then newRand else newRand + 2147483647
  where newRand = 16807 * lo - 2836 * hi
(hi,lo) = rand `divMod` 127773
 
  toDieRoll :: Seed - Int
  toDieRoll seed = (seed `mod` 6) + 1
 
  rollDie :: Seed - (Int, Seed)
  rollDie seed = ((seed `mod` 6) + 1, randomNext seed)
 
  sumTwoDice :: Seed - (Int, Seed)
  sumTwoDice seed0 =
let (die1, seed1) = rollDie seed0
(die2, seed2) = rollDie seed1
in (die1 + die2, seed2)
 
  () m n = \seed0 -
let (result1, seed1) = m seed0
(result2, seed2) = n seed1
in (result2, seed2)
 
  [mich...@localhost ~]$
 
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.orghttp://mc/compose?to=haskell-c...@haskell.orgmailto:
 Haskell-Cafe@haskell.org http://mc/compose?to=haskell-c...@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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Optimizing unamb by determining the state of a thunk?

2009-04-22 Thread Luke Palmer
On Mon, Apr 20, 2009 at 2:54 PM, Peter Verswyvelen bugf...@gmail.comwrote:

 I find this very confusing. Is the documentation of seq wrong (should be
 weak head normal form)?


Yes.  Weak head normal form is really the only *essential* one.  The popular
runtimes do not know how to reduce under a lambda, so they can't reduce
something to hnf.


 Anyway, so I guess we would actually need a function:

 iswhnf  :: a - IO Bool

 But since the value of this iswhnf function depends on when it is called,
 I feel it has to be in the IO monad; actually multiple threads evaluating it
 have nothing to do with it?


This is an impure function for a few reasons.  I.e. not only does it give
different answers at different times (depending on evaluation order), but it
is not pure in the domain theory; i.e. (\x. x) 42 = 42, but iswhnf gives
different answers for these.

So yes, definitely in IO, as a runtime extension (I wouldn't even expect
this function to be implementable on all runtimes).

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


[Haskell-cafe] GADT on the wiki: I'm lost

2009-04-22 Thread Peter Verswyvelen
I was reading the explanation of GADTs on the
wikihttp://en.wikibooks.org/wiki/Haskell/GADT ,
and but can't make any sense of the examples.
Sure I understand what a GADT is, but I'm looking for practical examples,
and the ones on the wiki seem to show what you *cannot* do with them...

For example, the article gives an alternative approach to the safeHead
function (see code below)

But now that does not work either, since Cons x y never evaluates to
MarkedList x Safe, so safeHead (Cons 1 Nil) will give a type error...

Am I missing something or is this wikibook just confusing?

Does anybody have good links to examples of GADTs?

Yampa surely seems a good example, but it's a bit too advanced.

data NotSafe
data Safe


data MarkedList ::  * - * - * where
  Nil   ::  MarkedList t NotSafe
  Cons  ::  t - MarkedList t y - MarkedList t z


safeHead::  MarkedList x Safe - x
safeHead (Cons x _)  =  x


silly 0  =  Nil
silly 1  =  Cons () Nil
silly n  =  Cons () $ silly (n-1)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GADT on the wiki: I'm lost

2009-04-22 Thread Luke Palmer
On Wed, Apr 22, 2009 at 3:30 PM, Peter Verswyvelen bugf...@gmail.comwrote:

 I was reading the explanation of GADTs on the 
 wikihttp://en.wikibooks.org/wiki/Haskell/GADT ,
 and but can't make any sense of the examples.
 Sure I understand what a GADT is, but I'm looking for practical examples,
 and the ones on the wiki seem to show what you *cannot* do with them...

 For example, the article gives an alternative approach to the safeHead
 function (see code below)

 But now that does not work either, since Cons x y never evaluates to
 MarkedList x Safe, so safeHead (Cons 1 Nil) will give a type error...


Cons  ::  t - MarkedList t y - MarkedList t z


Note the different variables y and z.  Cons 42 y has type MarkedList Int a,
for any type a, including Safe, NotSafe, and ElephantBanana.




 Am I missing something or is this wikibook just confusing?

 Does anybody have good links to examples of GADTs?

 Yampa surely seems a good example, but it's a bit too advanced.

 data NotSafe
 data Safe


 data MarkedList ::  * - * - * where
   Nil   ::  MarkedList t NotSafe
   Cons  ::  t - MarkedList t y - MarkedList t z


 safeHead::  MarkedList x Safe - x
 safeHead (Cons x _)  =  x


 silly 0  =  Nil
 silly 1  =  Cons () Nil
 silly n  =  Cons () $ silly (n-1)


 ___
 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: Trouble with type signatures and type families

2009-04-22 Thread Stephan Friedrichs
Gleb Alexeyev wrote:
 You may want to read the comments at
 http://hackage.haskell.org/trac/ghc/ticket/1897.

Wow that's subtle... Thanks a lot!

-- 

Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

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


[Haskell-cafe] WHNF versus HNF (was: Optimizing unamb by determining the state of a thunk?)

2009-04-22 Thread Peter Verswyvelen
I'm having difficulty to understand the difference between WHNF and HNF.

Is this 
explanationhttp://encyclopedia2.thefreedictionary.com/Weak+Head+Normal+Form
the
correct one? Or is WHNF and HNF equivalent in Haskell land?

The GHC documentation of seq says:
Evaluates its first argument to head normal form, and then returns its
second argument as the result.

Let's try in GHCi

*Main let f = trace \\x $ \x - ((trace \\y $ \y - trace y y + trace
x x) $ trace 2 2)
*Main f `seq` ()
\x
()
*Main

That did not evaluate anything inside the body of the first lambda, so
according to the article, seq reduces to weak head normal form, not hnf...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GADT on the wiki: I'm lost

2009-04-22 Thread Jason Dagit
On Wed, Apr 22, 2009 at 2:30 PM, Peter Verswyvelen bugf...@gmail.com wrote:
 I was reading the explanation of GADTs on the wiki , and but can't make any
 sense of the examples.
 Sure I understand what a GADT is, but I'm looking for practical examples,
 and the ones on the wiki seem to show what you *cannot* do with them...
 For example, the article gives an alternative approach to the safeHead
 function (see code below)
 But now that does not work either, since Cons x y never evaluates to
 MarkedList x Safe, so safeHead (Cons 1 Nil) will give a type error...
 Am I missing something or is this wikibook just confusing?
 Does anybody have good links to examples of GADTs?

Thrists, or type directed lists.  You can find them in the darcs
source code (darcs doesn't use Gabor's terminology):
http://darcs.net/src/Darcs/Ordered.hs
And an explanation of how darcs uses them:
http://blog.codersbase.com/2009/03/25/type-correct-changes-a-safe-approach-to-version-control-implementation/
And Gabor's explanation of how to use Thrists them:
http://www.opendylan.org/~gabor/Thrist-draft-2007-07-16.pdf

If you flip to the appendices of my thesis I do have a brief intro to
GADTs as well as a listing of some operations we defined for our GADT
based lists, and the slides from my defense talk have an example or
two. You can get pdfs of both from the blog link above.

If you're already familiar with type classes, you'll want to try to
figure out how GADTs are similar and different to type classes.  For
example, a type class is an open set of types that share an interface
(the functions in the type class), but once it is defined that
interface is (mostly) closed.  You can only add things on top of the
interface instead of extending it directly.  On the other hand, each
data constructor of the GADT behaves similarly to a type in a type
class.  Except, in the GADT case, the set of types (really data
constructors) is closed and the interface they share (functions on
your GADT) is open.

Another interesting aspect of GADTs is the way in which they allow you
to combine existentially quantified types with phantom types along
side our usual type variables.  Keeping in mind the similarity between
type classes, you might notice that specifying the relationship
between type variables in a GADT data constructor is similar to using
multiparameter type classes and functional dependencies.  If you're
already familiar with the type hackery that people accomplish with
type classes then you should also recognize the power of GADTs.  Some
benefits of GADTs over type class hackery include, GADT type checking
is decidable and at run-time GHC doesn't have to pass dictionaries
AFAIK like it does with type classes.

I hope that helps,
Jason
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GADT on the wiki: I'm lost

2009-04-22 Thread Peter Verswyvelen
Yeah that's what I also thought. I tried it first in GHCi, and I got a type
error. I tried it again, and it works now. I must have forgotten to reload
the file or something, cause I made the wrong conclusion. Duh, mea culpa.
On Wed, Apr 22, 2009 at 11:48 PM, Luke Palmer lrpal...@gmail.com wrote:

 On Wed, Apr 22, 2009 at 3:30 PM, Peter Verswyvelen bugf...@gmail.comwrote:

 I was reading the explanation of GADTs on the 
 wikihttp://en.wikibooks.org/wiki/Haskell/GADT ,
 and but can't make any sense of the examples.
 Sure I understand what a GADT is, but I'm looking for practical examples,
 and the ones on the wiki seem to show what you *cannot* do with them...

 For example, the article gives an alternative approach to the safeHead
 function (see code below)

 But now that does not work either, since Cons x y never evaluates to
 MarkedList x Safe, so safeHead (Cons 1 Nil) will give a type error...


 Cons  ::  t - MarkedList t y - MarkedList t z


 Note the different variables y and z.  Cons 42 y has type MarkedList Int a,
 for any type a, including Safe, NotSafe, and ElephantBanana.




 Am I missing something or is this wikibook just confusing?

 Does anybody have good links to examples of GADTs?

 Yampa surely seems a good example, but it's a bit too advanced.

 data NotSafe
 data Safe


 data MarkedList ::  * - * - * where
   Nil   ::  MarkedList t NotSafe
   Cons  ::  t - MarkedList t y - MarkedList t z


 safeHead::  MarkedList x Safe - x
 safeHead (Cons x _)  =  x


 silly 0  =  Nil
 silly 1  =  Cons () Nil
 silly n  =  Cons () $ silly (n-1)


 ___
 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] Functor and Haskell

2009-04-22 Thread Daryoush Mehrtash
Here F is the identity functor, and G is the list functor. And yes, C=D=
category of (a subset of) Haskell types.


Are you saying the function that goes from list functor to singleton funtor
is a natural transformation?

But aren't they functors to different subset of Haskell Types?

The Haskell Wikibooks also
sayshttp://en.wikibooks.org/wiki/Haskell/Category_theory#Functors_on_Haskthe
same thing:

 Functors in Haskell are from *Hask* to *func*, where *func* is the
 subcategory of *Hask* defined on just that functor's types. E.g. the list
 functor goes from *Hask* to *Lst*, where *Lst* is the category containing
 only *list types*, that is, [T] for any type T. The morphisms in *Lst* are
 functions defined on list types, that is, functions [T] - [U] for types T,
 U.


So in your example there is C that is Hask.  But there are two D's,  D1 that
is all List types, and D2 all singleton types.  In this example I guess,
the  Singleton types are subset of List types which are subset of Hask.
Is that related to natural transformation or unrelated?

Daryoush


On Wed, Apr 22, 2009 at 12:18 AM, Kim-Ee Yeoh a.biurvo...@asuhan.comwrote:



 Daryoush Mehrtash-2 wrote:
 
  I am not sure I follow how the endofunctor gave me the 2nd functor.
 
  As I read the transformation there are two catagories C and D and two
  functors F and G between the same two catagories.  My problem is that I
  only
  have one functor between the Hask and List catagories.  So where does the
  2nd functor come into picture that also maps between the same C and D
  catagories?
 

 Consider
 singleton :: a - [a]
 singleton x = [x]

 Here F is the identity functor, and G is the list functor. And yes, C=D=
 category of (a subset of) Haskell types.

 --
 View this message in context:
 http://www.nabble.com/Functor-and-Haskell-tp23166441p23170956.html
 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




-- 
Daryoush

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


Re: [Haskell-cafe] GADT on the wiki: I'm lost

2009-04-22 Thread Daniel Fischer
Am Mittwoch 22 April 2009 23:30:35 schrieb Peter Verswyvelen:
 I was reading the explanation of GADTs on the
 wikihttp://en.wikibooks.org/wiki/Haskell/GADT ,
 and but can't make any sense of the examples.
 Sure I understand what a GADT is, but I'm looking for practical examples,
 and the ones on the wiki seem to show what you *cannot* do with them...

 For example, the article gives an alternative approach to the safeHead
 function (see code below)

 But now that does not work either, since Cons x y never evaluates to
 MarkedList x Safe, so safeHead (Cons 1 Nil) will give a type error...

No, that works perfectly fine.
*SafeHead safeHead $ Cons 1 Nil
1
*SafeHead safeHead $ Cons () Nil
()

You probably tried something like

*SafeHead safeHead $ silly 2

interactive:1:11:
Couldn't match expected type `Safe' against inferred type `NotSafe'
  Expected type: MarkedList () Safe
  Inferred type: MarkedList () NotSafe
In the second argument of `($)', namely `silly 2'
In the expression: safeHead $ silly 2

???
Well,
*SafeHead :t silly
silly :: (Num t) = t - MarkedList () NotSafe


The case
silly 0 = Nil
makes silly have the return type MarkedList t NotSafe (for some unknown t).
The other equations for silly fix t as (), but nothing can transform the 
NotSafe into 
Safe.
Commenting out the first equation of silly yields
*SafeHead :t silly
silly :: (Num t) = t - MarkedList () z
*SafeHead safeHead $ silly 2
()



 Am I missing something or is this wikibook just confusing?

 Does anybody have good links to examples of GADTs?

 Yampa surely seems a good example, but it's a bit too advanced.

 data NotSafe
 data Safe


 data MarkedList ::  * - * - * where
   Nil   ::  MarkedList t NotSafe
   Cons  ::  t - MarkedList t y - MarkedList t z


 safeHead::  MarkedList x Safe - x
 safeHead (Cons x _)  =  x


 silly 0  =  Nil
 silly 1  =  Cons () Nil
 silly n  =  Cons () $ silly (n-1)

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


Re: [Haskell-cafe] WHNF versus HNF (was: Optimizing unamb by determining the state of a thunk?)

2009-04-22 Thread Daniel Fischer
Am Mittwoch 22 April 2009 23:57:08 schrieb Peter Verswyvelen:
 I'm having difficulty to understand the difference between WHNF and HNF.

 Is this
 explanationhttp://encyclopedia2.thefreedictionary.com/Weak+Head+Normal+For
m the
 correct one? Or is WHNF and HNF equivalent in Haskell land?

 The GHC documentation of seq says:
 Evaluates its first argument to head normal form, and then returns its
 second argument as the result.

 Let's try in GHCi

 *Main let f = trace \\x $ \x - ((trace \\y $ \y - trace y y +
 trace x x) $ trace 2 2)
 *Main f `seq` ()
 \x
 ()
 *Main

 That did not evaluate anything inside the body of the first lambda, so
 according to the article, seq reduces to weak head normal form, not hnf...

Yes, error in the docs. seq evaluates to WHNF, not HNF (unless the two 
coincide).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] WHNF versus HNF (was: Optimizing unamb by determining the state of a thunk?)

2009-04-22 Thread Marcin Kosiba
On Wednesday 22 April 2009, Peter Verswyvelen wrote:
 I'm having difficulty to understand the difference between WHNF and HNF.

 Is this
 explanationhttp://encyclopedia2.thefreedictionary.com/Weak+Head+Normal+For
m the
 correct one? Or is WHNF and HNF equivalent in Haskell land?

 The GHC documentation of seq says:
 Evaluates its first argument to head normal form, and then returns its
 second argument as the result.

 Let's try in GHCi

 *Main let f = trace \\x $ \x - ((trace \\y $ \y - trace y y +
 trace x x) $ trace 2 2)
 *Main f `seq` ()
 \x
 ()
 *Main

 That did not evaluate anything inside the body of the first lambda, so
 according to the article, seq reduces to weak head normal form, not hnf...
Hi,
 Try:

Prelude Debug.Trace (f 0) `seq` ()
\x
\y
y
2
x
()

--
Thanks!
Marcin Kosiba


signature.asc
Description: This is a digitally signed message part.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] WHNF versus HNF

2009-04-22 Thread Tillmann Rendel

Peter Verswyvelen wrote:

The GHC documentation of seq says:
Evaluates its first argument to head normal form, and then returns its
second argument as the result.


I think this should be weak head normal form. I don't think you have 
any means to evaluate under a binder in Haskell.


The weak in weak head normal forms means that evaluation does not go 
under lambda binders. The head in weak head normal form means that 
evaluation does not take place in argument positions.


Note that most programming languages evaluate to weak normal forms, 
because functions are only evaluated when they are called. So the head 
part is much more important then the weak part when explaining Haskell 
semantics, leading to sometimes omitting the weak part.


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


Re: [Haskell-cafe] Functor and Haskell

2009-04-22 Thread Ross Paterson
On Wed, Apr 22, 2009 at 03:14:03PM -0700, Daryoush Mehrtash wrote:
 The Haskell Wikibooks also says the same thing:
 
 Functors in Haskell are from Hask to func, where func is the
 subcategory of Hask defined on just that functor's types. E.g. the
 list functor goes from Hask to Lst, where Lst is the category
 containing only list types, that is, [T] for any type T. The
 morphisms in Lst are functions defined on list types, that is,
 functions [T] - [U] for types T, U.

That's true, but not a particularly helpful view.  Any functor F : C - D
can be viewed as a functor from C to the full subcategory of D on objects
of the form F A for A an object of C.  But then different functors map to
different categories and you can't talk about natural transformations
between them.  Composing functors also becomes impossible.

The simple view is that [], Maybe and Id are all functors from Hask to
Hask.  Then listToMaybe :: [a] - Maybe a is a natural transformation
from [] to Maybe, because

fmap f . listToMaybe = listToMaybe . map f
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Duncan Coutts
On Wed, 2009-04-22 at 13:20 +0200, david48 wrote:
 
 
 On Wed, Apr 22, 2009 at 1:01 PM, Duncan Coutts
 duncan.cou...@worc.ox.ac.uk wrote:
 
 On Wed, 2009-04-22 at 12:21 +0200, david48 wrote:
 
 
 Lines starting with -- are comments. You need to uncomment the
 prefix line for it to have an effect.
 
 Man do I feel dumb now :)

Don't :-) you're not the only one who got tripped up by this. It looked
a lot like -- as in --command-line-flags=. The new text in 0.6.2 makes
it clearer.

Duncan

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


Re: Is 78 characters still a good option? Was: [Haskell-cafe] breaking too long lines

2009-04-22 Thread Richard O'Keefe


On 22 Apr 2009, at 8:09 pm, Jason Dusek wrote:


 Really, the whole thing makes me wish we had blasphemy laws.

   If any person, in speaking or in writing, shall indicate
   a preference for column widths other than 80 or indent
   characters other than spaces (`0x20`) they shall be
   compelled to present some science or be subject to
   imprisonment.


I did find a paper that claimed that 95-character lines were
significantly faster to read than three shorter lengths.  On
closer study, it turned out that they were using the paging
model rather than the scrolling model:  once you came to
the end of a (short) page of text, you had to hit the Next
button to see the next page.  What they had in fact proved
was that hitting the Next Page button takes time...

Now that I have access to a recent Mac laptop, I've found that
in reading plain text, I like to make the lines narrower and
to approximate continuous scrolling: read one paragraph, stroke
the pad to move the next one up, keep on doing it.

There are several important differences between program text
and ordinary running natural language text.  In particular,
program text is two-dimensional in a way that ordinary text
is not.

By the way, in the era of punched cards, while the *cards*
were 80 columns, one's *text area* was not.  Typically the
last 8 columns were used for a sequence number, so that if
you dropped your cards -- yes, this happened -- you could
sort them back into order, and to provide editing facilities.
So people were really programming with 72-column lines.
That seemed to work pretty well, and printers seemed to have
no trouble reproducing it in books.

I do know a psychologist who has done reading studies; I
must see if I can talk him into looking into this.

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


Re: Is 78 characters still a good option? Was: [Haskell-cafe] breaking too long lines

2009-04-22 Thread Jason Dusek
  Some material I've read on typography -- can't find the
  reference now -- suggests ~65 is the best number of characters
  per line. The advice was, if your page is larger than that,
  you should make columns.

  If someone has done some studies with specifically program
  text, I'd of course be really interested to know what they
  discovered; but I really do suspect the issue of line length
  is more about having a convention than having the best one.
  Would people who prefer, for example, 132 character lines
  switch to 66 if that were empirically the best? Probably not.

  The 80 column convention sets a clear expectation for all of
  us; it's not a matter of what anyone likes.

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


Re: [Haskell-cafe] Overriding a Prelude function?

2009-04-22 Thread michael rice
OK, I changed the operator from () to (~). When I try to use it I get this:

[mich...@localhost ~]$ ghci rand
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( rand.hs, interpreted )
Ok, modules loaded: Main.
*Main rollDie ~ (rollDie ~ rollDie)

interactive:1:0:
    No instance for (Show (Seed - (Int, Seed)))
  arising from a use of `print' at interactive:1:0-32
    Possible fix:
  add an instance declaration for (Show (Seed - (Int, Seed)))
    In a stmt of a 'do' expression: print it
*Main 

Michael


--- On Wed, 4/22/09, Luke Palmer lrpal...@gmail.com wrote:

From: Luke Palmer lrpal...@gmail.com
Subject: Re: [Haskell-cafe] Overriding a Prelude function?
To: michael rice nowg...@yahoo.com
Cc: Ross Mellgren rmm-hask...@z.odi.ac, Dan Weston 
weston...@imageworks.com, haskell-cafe@haskell.org 
haskell-cafe@haskell.org
Date: Wednesday, April 22, 2009, 5:02 PM

On Wed, Apr 22, 2009 at 1:47 PM, michael rice nowg...@yahoo.com wrote:

Here's what I get:

[mich...@localhost ~]$ ghci
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help

Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude import Prelude hiding (())

You know, to avoid this nonsense you could just name the operator something 
else, like ~, or ~, or $...@**!.  Operators are just names.
Luke 


interactive:1:0: parse error on input `import'
Prelude 

=

I was passing seed0 to rollDie and getting back (r1,seed1)

 passing seed1 to rollDie and getting back (r2,seed2)
 passing seed2 to rollDie and getting back (r3,seed3)

Just based on the problem text, I would guess that
    passing rollDie and seed0 to () I would get back (r3,seed3),

losing the
 intermediate random numbers r1 and r2 along the way, at
least that's what I understood it to say.

So, I know that next I'm probably going to have to do something to 
remedy that, but I haven't gotten to that next step yet. What is unsugar?


Thanks in advance for your patience.

Michael


--- On Wed, 4/22/09, Dan Weston weston...@imageworks.com wrote:


From: Dan Weston weston...@imageworks.com
Subject: Re: [Haskell-cafe] Overriding a Prelude function?
To: Ross Mellgren rmm-hask...@z.odi.ac

Cc: michael rice nowg...@yahoo.com, haskell-cafe@haskell.org 
haskell-cafe@haskell.org

Date: Wednesday, April 22, 2009, 12:37 PM

Be aware that the do unsugars to (Prelude.), not your (), even if you hide
 (Prelude.):

import Prelude hiding (())
m  f = error Call me!
main = putStrLn . show $ do [3,4]
                            [5]

The desugaring of the do { [3,4]; [5] } is (Prelude.) [3,4] [5] = [5,5], 
whereas you might have hoped for [3,4]  [5] = error Call me!


Dan

Ross Mellgren wrote:
 I think
 
 import Prelude hiding (())
 
 does that.
 
 -Ross
 
 On Apr 22, 2009, at 11:44 AM, michael rice wrote:

 
 I've been working through this example from: 
 http://en.wikibooks.org/wiki/Haskell/Understanding_monads
 

 I understand what they're doing all the way up to the definition of (), 
 which duplicates Prelude
 function (). To continue following the example, I need to know how to 
override the Prelude () with the () definition in my file rand.hs.
 
 Michael
 
 ==

 
 [mich...@localhost ~]$ cat rand.hs
 import System.Random
 
 type Seed = Int
 
 randomNext :: Seed - Seed
 randomNext rand = if newRand  0 then newRand else newRand + 2147483647

     where newRand = 16807 * lo - 2836 * hi
           (hi,lo) = rand `divMod` 127773
 
 toDieRoll :: Seed - Int
 toDieRoll seed = (seed `mod` 6) + 1
 

 rollDie :: Seed - (Int, Seed)
 rollDie seed = ((seed `mod` 6) + 1, randomNext seed)
 
 sumTwoDice :: Seed - (Int,
 Seed)
 sumTwoDice seed0 =
   let (die1, seed1) = rollDie seed0
       (die2, seed2) = rollDie seed1
   in (die1 + die2, seed2)
 
 () m n = \seed0 -

   let (result1, seed1) = m seed0
       (result2, seed2) = n seed1
   in (result2, seed2)
 
 [mich...@localhost ~]$
 
 
 ___

 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org mailto: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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Is 78 characters still a good option? Was: breaking too long lines

2009-04-22 Thread Maurí­cio

P.S.  We really need such a well written style guide for
 haskell.  Python has this nice PEP (Python Enhancement
 Proposals).  Should we start making our own HEP?

We have one: urchin.earth.li/~ian/style/haskell.html


Yes, it's good. We should publicise it more.


Just a tought: I would like to see a guide talking about the
code itself, not about the presentation. Maybe this is ignored
because it's difficult. It's easy to get bad code and make sure
it follows strict layout, doesn't resemble imperative code and
has comments on all functions. It's still bad code.

Good practice, I believe, is more like thinking about every
side of your code: how can I change this so that the reader
will be guided as naturally as possible to understand the way it
works? Maybe prose writers or musicians have something to teach
us: how to present characters, how to organize ideas, how not
to confuse the reader, how to avoid showing something before the
reader has the proper background. Also, when to break the rules,
remove clever things that do not fit in the whole, pretend to
ignore the theory when it confuses instead of helping.

The cons: If we do it well, it makes our code to be
undervalued. If you take two months to make a complicated
thing look simple, all you can claim is that you wrote a simple
program :)

Best,
Maurício

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


[Haskell-cafe] Re: Overriding a Prelude function?

2009-04-22 Thread Achim Schneider
michael rice nowg...@yahoo.com wrote:

 OK, I changed the operator from () to (~). When I try to use it I
 get this:
 
 [mich...@localhost ~]$ ghci rand
 GHCi, version 6.10.1: http://www.haskell.org/ghc/__ :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer ... linking ... done.
 Loading package base ... linking ... done.
 [1 of 1] Compiling Main ( rand.hs, interpreted )
 Ok, modules loaded: Main.
 *Main rollDie ~ (rollDie ~ rollDie)  
 
 interactive:1:0:
 __ No instance for (Show (Seed - (Int, Seed)))
 __ arising from a use of `print' at interactive:1:0-32
 __ Possible fix:
 __ add an instance declaration for (Show (Seed - (Int, Seed)))
 __ In a stmt of a 'do' expression: print it

Well, you obviously need an initial seed:

rollDie 0xdeadbeef ~ (rollDie ~ rollDie)

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


[Haskell-cafe] installing Sqlite3 driver for windows

2009-04-22 Thread Michael P Mossey
I'm working from Real World Haskell, trying to install HDBC and 
the Sqlite3 driver on Windows XP. It was easy enough to use Cabal 
to install HDBC. However, for the Sqlite3 driver things get 
fuzzy. I downloaded hdbc-sqlite3_2.1.0.0.zip, but don't know what 
I'm supposed to do with it.


Also, it wasn't clear what to do with the sqlite3.dll file. On 
this page


http://software.complete.org/software/wiki/hdbc/FrequentlyAskedQuestions

it seems to imply you need to put it in

'gch --print-libdir'\include

and

%windir%\system32

but that page is really about building the driver from source. 
Maybe it only needs to go in the system32 directory.


Thanks,
Mike



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


Re: [Haskell-cafe] Re: Overriding a Prelude function?

2009-04-22 Thread michael rice
I'm just copying code from this web page: 
http://en.wikibooks.org/wiki/Haskell/Understanding_monads



Using their initial seed I get this:

*Main rollDie 362354 ~ (rollDie ~ rollDie)

interactive:1:0:
    Couldn't match expected type `t - (t1, t2)'
   against inferred type `(Int, Seed)'
    In the first argument of `(~)', namely `rollDie 362354'
    In the expression: rollDie 362354 ~ (rollDie ~ rollDie)
    In the definition of `it':
    it = rollDie 362354 ~ (rollDie ~ rollDie)
*Main 

===

Passing their initial seed through successive calls to rollDie:

*Main rollDie 362354
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.1 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
(3,1795116384)
*Main rollDie 1795116384
(1,523309185)
*Main rollDie 523309185
(4,1311937830)  == ISN'T THIS SUPPOSED TO BE THE RESULT?
*Main 

Michael


--- On Wed, 4/22/09, Achim Schneider bars...@web.de wrote:

From: Achim Schneider bars...@web.de
Subject: [Haskell-cafe] Re: Overriding a Prelude function?
To: haskell-cafe@haskell.org
Date: Wednesday, April 22, 2009, 9:52 PM

michael rice nowg...@yahoo.com wrote:

 OK, I changed the operator from () to (~). When I try to use it I
 get this:
 
 [mich...@localhost ~]$ ghci rand
 GHCi, version 6.10.1: http://www.haskell.org/ghc/__ :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer ... linking ... done.
 Loading package base ... linking ... done.
 [1 of 1] Compiling Main ( rand.hs, interpreted )
 Ok, modules loaded: Main.
 *Main rollDie ~ (rollDie ~ rollDie)  
 
 interactive:1:0:
 __ No instance for (Show (Seed - (Int, Seed)))
 __ arising from a use of `print' at interactive:1:0-32
 __ Possible fix:
 __ add an instance declaration for (Show (Seed - (Int, Seed)))
 __ In a stmt of a 'do' expression: print it

Well, you obviously need an initial seed:

rollDie 0xdeadbeef ~ (rollDie ~ rollDie)

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


___
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] Where to Cabal Install (was: Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) --first release)

2009-04-22 Thread wren ng thornton

Claus Reinke wrote:

Installing executable(s) in /home/david/.cabal/bin
why the hell would cabal install binaries in a subdirectory of a
hidden directory. Why not /home/david/bin or /home/david/local/bin ?


Yes, this is clearly suboptimal but getting agreement on where to put it
has not proved easy. There are users that will scream and shout if we
install to $HOME/bin by default.


Having learned from experience that user preferences differ wildly,
even on similar platforms, not to mention a variety of platforms or,
even worse, intentionally different forks of the same platform, and that 
trying to guess what defaults might be sensible, let alone acceptable,

can be a losing game, I'd like to offer an alternative view:

   if there is no universally acceptable default, do not use a default


+1.

Given that cabal has a config file already and so users don't have to 
enter everything on the commandline, this seems like a remarkably 
straightforward solution. The only downside seems like a minor startup 
cost (in exchange for the major restart cost from defaults having been bad).


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Overriding a Prelude function?

2009-04-22 Thread michael rice
I forgot the type signiture on the last last:

(~) :: (Seed - (a,Seed)) - (Seed - (b,Seed)) - (Seed - (b,Seed))
(~) m n = \seed0 -
  let (result1, seed1) = m seed0
  (result2, seed2) = n seed1
  in (result2, seed2)



With it I get this:

*Main rollDie 362354 ~ (rollDie ~ rollDie)



interactive:1:0:

    Couldn't match expected type `Seed - (a, Seed)'

   against inferred type `(Int, Seed)'

    In the first argument of `(~)', namely `rollDie 362354'

    In the expression: rollDie 362354 ~ (rollDie ~ rollDie)

    In the definition of `it':

    it = rollDie 362354 ~ (rollDie ~ rollDie)

*Main 


Michael

--- On Wed, 4/22/09, Achim Schneider bars...@web.de wrote:

From: Achim Schneider bars...@web.de
Subject: [Haskell-cafe] Re: Overriding a Prelude function?
To: haskell-cafe@haskell.org
Date: Wednesday, April 22, 2009, 9:52 PM

michael rice nowg...@yahoo.com wrote:

 OK, I changed the operator from () to (~). When I try to use it I
 get this:
 
 [mich...@localhost ~]$ ghci rand
 GHCi, version 6.10.1: http://www.haskell.org/ghc/__ :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer ... linking ... done.
 Loading package base ... linking ... done.
 [1 of 1] Compiling Main ( rand.hs, interpreted )
 Ok, modules loaded: Main.
 *Main rollDie ~ (rollDie ~ rollDie)  
 
 interactive:1:0:
 __ No instance for (Show (Seed - (Int, Seed)))
 __ arising from a use of `print' at interactive:1:0-32
 __ Possible fix:
 __ add an instance declaration for (Show (Seed - (Int, Seed)))
 __ In a stmt of a 'do' expression: print it

Well, you obviously need an initial seed:

rollDie 0xdeadbeef ~ (rollDie ~ rollDie)

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


___
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: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Richard O'Keefe




It's irrelevant, because I _do_ have root access to my machine,


How nice to be you.
Since the argument is entirely about people who _don't_,
your point it?

It is clear that the only sensible default is no default.
Someone else has said it recently and said it much better.


I think the right question is how many people prefer user installs
over system installs, wrt. their hackage packages?.


No, because the costs are asymmetric.


Endusers, of course, might have other preferences, but cabal doesn't
(IMHO) cater to them, directly: It caters to distribution packages (or
windows installers, or whatever), so cabal's default behaviour is  
quite

irrelevant for those cases.


The clear impression I've received on this mailing list
is that cabal is _also_ for people who are using Haskell
and find that there's a new package reported in HWN that
they'd like to have.  If you are now telling me that I
should ignore it because I'm not making distribution
packages or Windows installers, fine, just tell me what
to use instead.



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


Re: [Haskell-cafe] Re: Is 78 characters still a good option? Was: breaking too long lines

2009-04-22 Thread wren ng thornton

Maurí­cio wrote:

  We have one: urchin.earth.li/~ian/style/haskell.html

 Yes, it's good. We should publicise it more.

Just a tought: I would like to see a guide talking about the
code itself, not about the presentation. Maybe this is ignored
because it's difficult. It's easy to get bad code and make sure
it follows strict layout, doesn't resemble imperative code and
has comments on all functions. It's still bad code.


You've nailed it: this is ignored because it's difficult. It's nothing 
special about Haskell, it holds for style guides for every language I've 
seen.


It's difficult because it's not a question of science, but rather a 
question of aesthetics. And as anyone in the humanities can tell you, 
when it comes to aesthetics people disagree. But the reason they 
disagree is because of this fundamental truth: there's no right answer. 
There are many wrong answers, to be sure, but there's no right answer. 
To put a finer point on it, not everyone likes the same authors. One 
person's clear discussion is another's pedantry or another's logorrhea.


Consider style guides for writing prose. Many of these are full of 
discussion about where to place commas, or when to use a different word 
because of the possibility for confusion, or when to reorder the parts 
of a sentence. What few of them ever discuss are things like how to 
structure an argument, how to introduce characters, when a character 
should be removed, what makes for an interesting plot, etc. Even those 
that discuss such things are typically vague about it and often make 
appeals to intuitions and aesthetics they presuppose.


Good writers and good coders will learn these things over time but they 
learn them by practice just like any artisan. Good style guides are like 
a good instructor: they can teach you how to use a chisel, but they 
can't teach you how to carve. Over time, with enough experience after 
carving many different things, the good sculptor will come to an 
intuitive understanding about what things will work and what things are 
likely to be problematic. They can pass down the lessons, the horror 
stories, a codification of their hunches, but what they can't teach is 
the intuition itself.


Don't get me wrong, I'd love to see more guides that take on these sorts 
of issues. This is why they're so rare, is all.



My job over the last year has been trying to teach a group of colleagues 
---in person--- about what makes good style. In addition to the issues 
mentioned above, there's another one that looms large. Most people 
already have a style ---good, bad, indifferent--- and they often 
perceive any attempts to change that style as (at best) a frivolity or 
(at worst) an attack on their abilities. Books and webpages can 
circumvent this to an extent (thanks to the selection bias of who would 
be reading them anyways), but any guide that is too challenging will be 
thrown out, no matter how right it is. Thus it takes someone who's a 
good writer, speaker, or manager and not just someone who's a good 
coder. Because the author needs to convey not only the intuition, but 
also enough of themselves that the reader will accept their experience 
and listen to what they have to say.


(And folks who are good with both personal and technical arenas can earn 
a lot more elsewhere than writing guides, so they'd have to be 
charitable and generous as well ;)


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Where to install cabal

2009-04-22 Thread Edward Middleton
Richard O'Keefe wrote:
 Endusers, of course, might have other preferences, but cabal doesn't
 (IMHO) cater to them, directly: It caters to distribution packages (or
 windows installers, or whatever), so cabal's default behaviour is quite
 irrelevant for those cases.

 The clear impression I've received on this mailing list
 is that cabal is _also_ for people who are using Haskell
 and find that there's a new package reported in HWN that
 they'd like to have.  If you are now telling me that I
 should ignore it because I'm not making distribution
 packages or Windows installers, fine, just tell me what
 to use instead.

distribution packages.

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


Re: [Haskell-cafe] Functor and Haskell

2009-04-22 Thread Kim-Ee Yeoh


Daryoush Mehrtash-2 wrote:
 
 singleton :: a - [a]
 singleton x = [x]
 
 Here F is the identity functor, and G is the list functor. And yes, C=D=
 category of (a subset of) Haskell types.
 
 Are you saying the function that goes from list functor to singleton
 funtor
 is a natural transformation?
 

Here *singleton* is the natural transformation from the identity functor
to the list functor.


Daryoush Mehrtash-2 wrote:
 
 But aren't they functors to different subset of Haskell Types?
 

They're usually treated as endofunctors on Hask, for reasons
Ross Paterson has given.

-- 
View this message in context: 
http://www.nabble.com/Functor-and-Haskell-tp23166441p23189784.html
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] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Richard O'Keefe


On 23 Apr 2009, at 2:09 am, John A. De Goes wrote:



That's absurd. You have no way to access private source code,


Right.

so any decision on what features to exclude from future versions of  
Haskell must necessarily look at publicly accessible source code.


Wrong.  There is no necessarily about it.  People made decisions
about what to deprecate in the Fortran and COBOL standards without
looking at publicly accessible source code.  The changes made in
producing ECMA Eiffel were _definitely_ done without looking at
publicly accessible source code.

And the decision to remove n+k patterns from Haskell', wrong though
I think it was, was NOT made on a nose-counting basis.  Or if it was,
there is not the slightest evidence of it in
http://hackage.haskell.org/trac/haskell-prime/wiki/RemoveNPlusK

The reasons for the removal are, in order
 - no other data type has it
   (and how many other data types allow [a,b,c] as well as a:b:c:[]?)
 - a somewhat bogus claim about how much of the library you need to
   know how to use it (of COURSE you need to know about integers in
   order to use an integer operation, what's so bad about that?)
 - the claim that + doesn't mean + (this is really an argument about
   the scope of + and could have been dealt with by ruling that n+k
   is only available when the version of + in scope is the one from
   the Prelude)
 - an assertion of personal taste (the side condition that the
   thing is FOR is called 'ugly')
 - a pious hope that something might replace them
 - another assertion of personal taste.

That's *it*.  There is nothing about the operation being *rare*
in any source code, publicly available or otherwise.  There is
no suggestion that commonly used features would not be proposed
for removal.  For example, . as the composition operator, and
~ lazy patterns, have both been proposed for removal.

The only alternative is to continuously add, and never remove,  
features from Haskell, even if no one (that we know) uses them.


Look again at the Haskell' status page,
http://hackage.haskell.org/trac/haskell-prime/wiki/Status

Of all the proposed removals, n+k is the ONLY one to have been
accepted.  It may well be true that someone counted how many
publicly accessible modules use those features, but I cannot
find any evidence in the Haskell' wiki that this is so, or for
that matter that people would have cared very much.  (Meyer
wasn't bothered by the major incompatibilities between ETL3
Eiffel and ECMA Eiffel.)

With this one unique solitary exception, so far Haskell'
*is* just adding features to Haskell.  So if trawling through
publicly available sources is somehow supposed to stop that
happening, I'm sorry, but it hasn't done so yet.



Moreover, the odds that everyone who is using n + k patterns are  
doing so only in private is an untestable hypothesis (i.e.  
unscientific) and extremely unlikely to be true.


It's also a straw man argument.  Nobody says that.
I certainly don't.  What I DO say is that
 - MY code contains n+k
 - MY code is not publicly available (there are many much brighter
   people than me working on Haskell and whenever I have a cool idea
   it has so far always been done, and in any case, much of the
   Haskell code I've written would be of no interest to anyone else)
 - so the nose counting process would certainly miss ME
 - there doesn't seem to be any reason to consider me unique
We simply DON'T KNOW how many people are using n+k patterns
or anything else that people have proposed for removal from Haskell'.
One thing we DO know is that existing Haskell textbooks teach the
use of n+k patterns.

Is there a simple way to download everything from Hackage?
As I've said before, trawling through stuff like that _can_ show
that something is used, but if it doesn't show that, we do NOT
learn that it isn't, but only that we DON'T KNOW.

As someone who is only a Haskell user, I don't really have any
*rights* in the matter.  Using Haskell at all is a privilege,
and if the Haskell committee decide, and Haskell implementors
agree, to remove a feature that I like, then I just have to
live with it.  But let's not pretend that this was ever about
how many people used the feature.




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


Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Richard O'Keefe


On 23 Apr 2009, at 2:24 am, Achim Schneider wrote:


Richard O'Keefe et all wrote:


[n+k patterns]

I'd like to add my two cents: Assuming that UHC's roadmap strives to  
be

H'-compilant in the future, and n+k patterns aren't going to be in H',
why bother implementing them?


Haskell' is a moving target.
There are as yet no programs that are *known* to be Haskell' programs.
There are as yet no Haskell' textbooks.
(I remember someone once wrote a book about Prolog that presented
 Prolog according to the then-current draft of the standard.  The
 next year the draft lurched back towards then-current practice,
 and the book was left describing a language that was never  
implemented.)


If you want to support existing code written by people
trained on the existing textbooks, you support as much of the
existing language as you can.

Otherwise you have to rely on people writing code specifically
for your compiler.


Also, assuming that current H98 code will be ported to H', shouldn't
n+k patterns be removed from existing code, anyway?


Someone who really believed that would surely be recommending
that a compiler accept the feature and generate working code for
it but WARN at each occurrence with a warning that can't be
switched off.  That would be a useful way to help people remove
this clarity from their code.

No, the UHC people can do what they please.  It's _their_ compiler.
It's _great_ that there's another almost-Haskell98 compiler.
It's a little puzzling that section 3 Language extensions and
differences with Haskell98 says nothing whatsoever about n+k
patterns.  It's only in section 4.1, where we learn also that
'default' isn't there and might never be.  We don't yet know
whether 'default' will be in Haskell'.  We also learn from
http://www.cs.uu.nl/wiki/bin/view/Ehc/EhcUserDocumentation
that IO is under construction, Directory, Time, Locale, CPUTime,
and Random are not available.  This is clearly work in progress,
and we can only be thankful for something that's intended to be
read as well as written.  In fact, I've downloaded it, precisely
in order to see how much work it will be to add n+k support.

The thing is that it really seems bizarre to see this one feature
singled out for non-implementation.

If I can do the equivalent of n+k patterns
by programming in the *type system*, why *not* in a pattern?


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