Re: [Haskell-cafe] Roman Numeral Problem

2013-06-24 Thread Roel van Dijk
Hi Christopher,

I made a small library to convert between strings and roman numerals [1].
It didn't use much abstraction. I mainly used some type-classes so multiple
string-like types can be parsed.
The numerals themselves are basically a concatenation of value symbols. The
order from high to low is not even strictly necessary in order to parse a
roman numeral. One insight was to handle exceptions like "IV", "IX", "XL"
etc. as separate symbols.

It would be interesting if you could parse roman numerals using a dedicated
parsing library and come up with something shorter and/or more
elegant/readable than my little library.

Regards,
Roel

1 - http://hackage.haskell.org/package/roman-numerals


On 24 June 2013 08:43, Christopher Howard  wrote:

> Hi. I am working on some practice programming problems, and one is the
> Roman numeral problem: write a program that converts Roman numerals into
> their (arabic) numeral equivalent. I imagine I could hack something
> together, but I was trying to think about the problem a bit more deeply.
> I don't know much about parsing, but I was wondering if this problem
> matched up with some kind of parsing or grammar or other generic
> approach to thinking about the problem. (I once read something about
> Context Free Grammars, which was rather interesting.) I can do more of
> my own research if I can get some initial guidance.
>
> --
> frigidcode.com
>
>
> ___
> 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] putting the result of a function in `infix` declaration

2013-06-23 Thread Roel van Dijk
Related to Karl's Template Haskell suggestion you could also have a look at
quasiquotation:

http://www.haskell.org/haskellwiki/Quasiquotation

The GHC documentation has an example of a expression quoter:

http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.html#th-quasiquotation


On 23 June 2013 22:22, Karl Voelker  wrote:

> On Sun, Jun 23, 2013 at 6:36 AM, TP  wrote:
>
>> In a more general way, let us suppose I have a Haskell library able to
>> perform some calculations: how to use it in a pre-processing step, before
>> compilation of the executable?
>
>
> You are looking for Template Haskell.
>
> http://www.haskell.org/haskellwiki/Template_Haskell
>
> I'm not sure how up-to-date the wiki is, but it should give you the
> general idea.
>
> -Karl V.
>
> ___
> 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] Incrementation fails

2013-05-08 Thread Roel van Dijk
> problem = replaceBasedIdx "X" ["b","d","f"] "aXcXeXgX"
> -- "abcdefg*** Exception: Prelude.(!!): index too large

This problem occurs because you never check if 'counter' is a valid
index in the 'replaceStrList'. You can solve it by not using the !!
operator at all. The solution is to also pass 'replaceStrList' in the
recursion. That way you can check whether you have exhausted all
strings in that list and as a bonus you do not need your counter
anymore:

> replaceBasedIdx :: String -> [String] -> String -> String
> replaceBasedIdx findStr replaceStrList myText = loop replaceStrList myText
>   where
> loop :: [String] -> String -> String
> loop rs [] = []
> -- Check for empty list of replacements
> loop [] text = text
> -- Pattern match on the list of replacements to get both the
> -- entire list rs, the first element r and the tail rs'.
> loop rs@(r:rs') text =
>   let (prefix, rest) = splitAt n text
>   in if findStr == prefix
>  then r ++ loop rs' rest
>  else head text : loop rs (tail text)
>
> n :: Int
> n = length findStr



2013/5/8 Roel van Dijk 

> I stared at the code some more and deduced what I think is the
> intented meaning. Occurences of 'findStr' in 'myText' are replaced
> with the strings in 'replaceStrList'.
>
> So replaceBasedIdx "X" ["b","d","f"] "aXcXeXg" = "abcdefg"
>
> The reason your counter didn't increment is because it was defined as
> an argument to 'replaceBasedIdxSub'. That means its value is fixed
> once you evaluate that function. Its value will not change no matter
> how many times the inner 'loop' function is evaluated. The solution is
> to pass the counter as an argument to said 'loop' function. Now when
> 'loop' enters the recursion you can pass a different value, such as
> counter + 1.
>
> > replaceBasedIdx :: String -> [String] -> String -> String
> > replaceBasedIdx findStr replaceStrList myText = replaceBasedIdxSub
> findStr replaceStrList myText
>
> > replaceBasedIdxSub :: String -> [String] -> String -> String
> > replaceBasedIdxSub findStr replaceStrList myText = loop 0 myText
> >   where
> > loop :: Int -> String -> String
> > loop counter [] = []
> > loop counter myText =
>  >   let (prefix, rest) = splitAt n myText
> >   in if findStr == prefix
> >  then (replaceStrList !! counter) ++ loop (counter + 1) rest
> >  else head myText : loop counter (tail myText)
> >
> > n :: Int
> > n = length findStr
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Incrementation fails

2013-05-08 Thread Roel van Dijk
I stared at the code some more and deduced what I think is the
intented meaning. Occurences of 'findStr' in 'myText' are replaced
with the strings in 'replaceStrList'.

So replaceBasedIdx "X" ["b","d","f"] "aXcXeXg" = "abcdefg"

The reason your counter didn't increment is because it was defined as
an argument to 'replaceBasedIdxSub'. That means its value is fixed
once you evaluate that function. Its value will not change no matter
how many times the inner 'loop' function is evaluated. The solution is
to pass the counter as an argument to said 'loop' function. Now when
'loop' enters the recursion you can pass a different value, such as
counter + 1.

> replaceBasedIdx :: String -> [String] -> String -> String
> replaceBasedIdx findStr replaceStrList myText = replaceBasedIdxSub
findStr replaceStrList myText

> replaceBasedIdxSub :: String -> [String] -> String -> String
> replaceBasedIdxSub findStr replaceStrList myText = loop 0 myText
>   where
> loop :: Int -> String -> String
> loop counter [] = []
> loop counter myText =
>   let (prefix, rest) = splitAt n myText
>   in if findStr == prefix
>  then (replaceStrList !! counter) ++ loop (counter + 1) rest
>  else head myText : loop counter (tail myText)
>
> n :: Int
> n = length findStr
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Incrementation fails

2013-05-08 Thread Roel van Dijk
Hi John,

Can you tell us what your function is supposed to do? It appears to be some
kind of search-and-replace for strings. What is the relationship between
'findStr', 'replaceStrList' and 'myText'?


2013/5/8 John 

> Hello All,
>
> I'm in a big trouble with incrementation of a counter in this code. It
> doesn't increment.
>
> Could you please tell me where the problem ist and how can I solve it?
>
> replaceBasedIdx::  String  ->  [String]  ->  String  ->  String
> replaceBasedIdxfindStr replaceStrList myText = replaceBasedIdxSub
> findStr replaceStrList myText 0
>
> replaceBasedIdxSub  ::  String  ->  [String]  ->  String  -> Int -> String
> replaceBasedIdxSub findStr replaceStrList myText counter = loop myText
>   where
> loop [] = []
> loop myText =
>   let (prefix, rest) = splitAt n myText
>   in
> if findStr == prefix-- found an
> occurrence?
> then (replaceStrList !! (counter+1)) ++ loop rest   -- yes: replace
> it
>
> else head myText : loop (tail myText)   -- no: keep
> looking
> n = length findStr
>
> Thank you very mutch!
>
> Greetings!
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Inject cabal version or VCS version as a CPP macro

2012-02-22 Thread Roel van Dijk
For each package "myPackage" Cabal generates a module containing,
among other things, the package's version as a Haskell value:

> import Paths_myPackage ( version )
> import Data.Version  ( showVersion )
> main = showVersion version

See also "Accessing data files from package code" in
http://www.haskell.org/cabal/users-guide/

I do not now how to expose information from the VCS.

2012/2/22 Eugene Kirpichov :
> Hi,
>
> I'd like my program to print something like "this is $program 1.0.4 git
> 45fea6b" when invoked with --version, or at least just the 1.0.4 part.
>
> Can Cabal expose the version as a preprocessor macro by default, or do I
> have to use Build-Type: Custom and add a preprocessing step of my own?

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


[Haskell-cafe] How to increase performance using concurrency for sequential producer-consumer problem

2012-02-13 Thread Roel van Dijk
Hello,

I have a program which I believe can benefit from concurrency. But I
am wondering if the mechanisms I need already exist somewhere on
Hackage.

Here is a sketch of my program, in literate Haskell:

> module Problem where
> import Control.Monad ( forM_ )

The producer produces values. It blocks until there are now more
values to produce. Each value is given to a callback function.

> type Producer a = (a -> IO ()) -> IO ()

The converter does some work with a value. This work is purely CPU and
it is the bottleneck of the program. The amount of work it has to do
is variable.

> type Converter a b = a -> b

The consumer does something with the value calculated by the
converter. It is very important that the consumer consumes the values
in the same order as they are produced.

> type Consumer b = b -> IO ()

Dummy producer, converter and consumer:

> producer :: Producer Int
> producer callback = forM_ [1..10] callback

> converter :: Converter Int Int
> converter = (*10)

> consumer :: Consumer Int
> consumer = print

A simple driver. Does not exploit concurrency.

> simpleDriver :: Producer a -> Converter a b -> Consumer b -> IO ()
> simpleDriver producer converter consumer = producer (consumer . converter)

> current_situation :: IO ()
> current_situation = simpleDriver producer converter consumer

Ideally I would like a driver that spawns a worker thread for each
core in my system. But the trick is in ensuring that the consumer is
offered results in the same order as they are generated by the
producer.

I can envision that some kind of storage is necessary to keep track of
results which can not yet be offered to the consumer because it is
still waiting for an earlier result.

Is there any package on Haskell that can help me with this problem? Or
do I have to implement it using lower level concurrency primitives?

Regards,
Roel

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


Re: [Haskell-cafe] zlib 0.5.3.2 broken?

2012-02-02 Thread Roel van Dijk
bzlib-0.5.0.2 suffers from the exact same problem. I send a bug report
to the author a few days ago, but I can imagine he's very busy. It
might help if we can send patches that fix the compile error.

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


Re: [Haskell-cafe] How to "show" a utf8 string?

2012-01-10 Thread Roel van Dijk
Have you tried using putStrLn?

Small GHCI example:

  Prelude> putStrLn "\29579"
  王

I believe the Show instances for chars and strings escape all
characters with a codepoint > 127.

2012/1/10 Magicloud Magiclouds :
> Hi,
>  I am using LDAP hackage to do some ldap searching. I am not sure if
> this is its problem. All Chinese chars returned like "\29579".
>  How to convert it to the actual Chinese char? I thought it was my
> terminal's fault, so tried to use System.IO.UTF8 to put the result
> into a file and viewed by firefox, no luck.
> --
> 竹密岂妨流水过
> 山高哪阻野云飞
>
> ___
> 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] ANNOUNCE: vector-bytestring-0.0.0.0

2011-10-18 Thread Roel van Dijk
2011/10/18 Roel van Dijk :
> Maybe we [can] create an example program which would fail with the
> more general type.

Migrating the function "foo" from bytestring to vector-bytestring
would fail with more general types:

> import Data.ByteString
> foo = print empty
Ok, modules loaded: Test.

With vector:
> import Data.Vector.Storable
> foo = print empty
Ambiguous type variable `a0' in the constraints:
  (Show a0) arising from a use of `print'
at /home/roelvandijk/development/test.hs:5:7-11
  (Storable a0) arising from a use of `empty'
at /home/roelvandijk/development/test.hs:5:13-17
Probable fix: add a type signature that fixes these type variable(s)
In the expression: print empty
In an equation for `foo': foo = print empty
Failed, modules loaded: none.

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


Re: [Haskell-cafe] ANNOUNCE: vector-bytestring-0.0.0.0

2011-10-18 Thread Roel van Dijk
2011/10/18 Christian Maeder :
> you could re-export VS.empty, VS.singleton, etc. directly.

The vector singleton and the vector-bytestring singleton don't have
the same type.

vector:
> singleton :: a -> Vector a

vector-bytestring:
> singleton :: Word8 -> Vector Word8

By choosing the more general type you risk that a previously correct
program becomes ambiguous. (When migrating from bytestring to
vector-bytestring).

I'm not sure if this will actually occur in practive or that it holds
for all the little functions that you could theoretically re-export
directly. Maybe we create an example program which would fail with the
more general type. Proving the opposite (that the more general type is
always safe) will be more difficult.

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


Re: [Haskell-cafe] How to compile this example code?

2011-10-03 Thread Roel van Dijk
{- forgot to reply to list -}

This isn't Haskell syntax. Atleast not directly. It is either
hsc2hs[1] or c2hs [2]. Also see [3] for the difference between the
two. Soin order to compile that code you first have to run it through
aspecial preprocessor.
1 - http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/hsc2hs.html2
- http://www.cse.unsw.edu.au/~chak/haskell/c2hs/3 -
http://stackoverflow.com/questions/6009031/difference-between-hsc2hs-and-c2hs
2011/10/3 Magicloud Magiclouds :
> Hi,
>  I am learning to use data-flags, and got this example code:
> import Data.Flags
> newtype MyFlags = MyFlags CInt deriving (Eq, Flags)
> #{enum MyFlags, MyFlags
>  , myFlag1 = C_FLAG1
>  , myFlag2 = C_FLAG2
>  , myFlag3 = C_FLAG3
>  }
>
>  I modified it trying to compile it. Well, I got illegal syntax at "#{e".
>  In fact, I am not quite know the syntax here. Any clue?

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


Re: [Haskell-cafe] hackage library info

2011-09-21 Thread Roel van Dijk
Unfortunately the bifunctor.homelinux.net domain stopped working. The
reverse dependencies can now be found at:

http://revdeps.hackage.haskell.org/

The reverse dependency algorithm needs some love. Some packages have
-1 reverse dependencies, which is somewhat strange.

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


Re: [Haskell-cafe] Strange No instance error with cabal install

2011-09-20 Thread Roel van Dijk
I see the aeson version with the stricter dependency on deepseq < 1.2
is now also released on hackage:

http://hackage.haskell.org/package/aeson-0.3.2.12

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


Re: [Haskell-cafe] Strange No instance error with cabal install

2011-09-20 Thread Roel van Dijk
I believe this is because of aeson depending on *any* version of
deepseq. This was very recently fixed in the development version:

  https://github.com/mailrank/aeson/pull/25

2011/9/20 Rune Harder Bak :
> Sometimes when one of our developers (using Arch-linux) tries to cabal
> install packages he gets
> a "no instance for" error.
> Code that compiles fine on my computer, and other computers I try it
> on. Even some packages on hackage
> (trying to install aeson-native for instance gives Data/Aeson/Types.hs:196:22:
>    No instance for (NFData Object)
>      arising from a use of `rnf'
>    Possible fix: add an instance declaration for (NFData Object)
>    In the expression: rnf o
>    In an equation for `rnf': rnf (Object o) = rnf o
>    In the instance declaration for `NFData Value')
> I tried removing the .ghc and .cabal folder, even reinstalled ghc-7.04
> and cabal-install (most recent), but the problem persisted (might not
> have been a clean install though, I'm no Arch expert)
> I know this is kind of vauge, and not in she shape of filling a bug
> report, heck I can't even reproduce the error on my computer.
> But perhaps somebody else has run in to this strange behavior before?
>
> Best,
> Rune
>
> ___
> 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] ANN: numerals

2011-09-16 Thread Roel van Dijk
> Are you familiar with the Grammatical Framework [1]? It is a Haskell
> library and language for natural language parsing and translation --
> If you need to do a lot of translation or string localization, you
> should take a look at it as much of the complexity has been addressed
> there.

Yes. Someone mentioned it to me in the Haskell IRC channel
approximately a year ago when I was discussing some problems I
had with my numerals package. I am not really in need to
translation or string localization. The numerals package is
merely a hobby project that got a bit out of hand :-)

> That said, the numeral libraries for GF are somewhat limited (and/or
> somewhat undocumented) so there is probably a lot your experience and
> library could bring to that project.

I am interested in the ways the two projects could work
together. Maybe they could check each other's results.

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


[Haskell-cafe] ANN: numerals

2011-09-16 Thread Roel van Dijk
Hello everyone,

I would like to announce the release of the numerals and
numerals-base packages.


* Numerals

The numerals package contains functions to convert numbers to
number words in a number of languages. For now the package only
supports cardinal numbers.

Example:
>>> import qualified Text.Numeral.Language.EN as EN
>>> EN.uk_cardinal 123 :: Maybe String
Just "one hundred and twenty-three"

You can also inspect the underlying structure of a number word:
>>> import Text.Numerals
>>> EN.shortScaleStruct 123 :: Exp
Add (Mul (Lit 1) (Lit 100)) (Add (Mul (Lit 2) (Lit 10)) (Lit 3))

Compare this structure with the number word:
1 (one) * 100 (hundred) + (and) 2 (twen) * 10 (ty) + 3 (three)

The package also comes with a test suite:
>>> cabal configure --enable-tests
>>> cabal build
>>> ./dist/build/test-numerals/test-numerals --hide-successes

I recommend the "--hide-successes" option of test-framework (>=0.4)
because there are many tests (3383).


* Numerals-base

The numerals-base package contains all the machinery upon which
numerals is build. Using this package you can write conversion
functions for your own language(s). It is documented, although
the documentation can be improved. For now the numerals package
is probably the best documentation.


* Resources:

Hackage:
http://hackage.haskell.org/package/numerals
http://hackage.haskell.org/package/numerals-base

Github:
http://github.com/roelvandijk/numerals
http://github.com/roelvandijk/numerals-base


* Help wanted

Currently I support 24 languages. But I only have some experience with
4 of them. The rest is scraped together with information I found
online. For most languages I can find online how to form the first 100
cardinal numbers. But after that information is sparse. You can help
by checking and expanding the test suite. This is very simple because
the test suite consists only of numbers combined with the expected
cardinal number word.


Regards,
Roel van Dijk

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


Re: [Haskell-cafe] TypeOperators and Unicode

2011-09-12 Thread Roel van Dijk
2011/9/12 Brandon Allbery :
> Don't all infix constructors have to start with a colon?

Yes that is true. You can of course use Unicode symbols as infix type variables:

(⋙) :: Category ⇝ => (α ⇝ β) -> (β ⇝ γ) -> α ⇝ γ

But a constructor must always begin with a capital letter or with a colon.

UnicodeSyntax is only required if you want to replace existing Haskell
syntax with Unicode.

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


Re: [Haskell-cafe] Haddock chokes on function arguments

2011-08-25 Thread Roel van Dijk
Does it help if you format it like this:

-- |Apply a given function over all elements of a list and select one of the
-- results.
selector :: (Arbitrary b)
 => [a]   -- ^ Elements to select from
 -> (a -> b)  -- ^ Constructor to apply to selected element
 -> Gen b
selector list ctor = oneof (map (return . ctor) list)

So placing the => and -> before the lines instead of after them?

2011/8/25 Arnaud Bailly :
> Hello,
> while trying to generate Haddock documentation (Haddock version 2.9.2, (c)
> Simon Marlow 2006), it chokes on the following fragment
>
> -- |Apply a given function over all elements of a list and select one of the
> -- results.
> selector :: (Arbitrary b) =>
>     [a]  -> -- ^ Elements to select from
>     (a -> b) -> -- ^ Constructor to apply to selected element
>     Gen b
> selector list ctor = oneof (map (return . ctor) list)
>
> with the following error message:
>
> '   parse error on input `-- ^ Elements to select from
>
> I am puzzled as this is exactly how arguments are supposed to be documented,
> according to http://www.haskell.org/haddock/doc/html/ch03s02.html#id565220
>
> Any clues ?
>
> Arnaud
>
> ___
> 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] The Lisp Curse

2011-05-20 Thread Roel van Dijk
On 20 May 2011 12:46, Markus Läll  wrote:
> What's stopping it from being put on the official hackage? I use it quite a
> lot to find well established packages and/or example code, and am quite fond
> of it. But it is only visible when you know that this exists.

Poor timing. I wrote the patch when there was significant work being
done for the new version of hackage [1]. So the feeling was that the
current hackage (which is a bunch of cgi programs) would soon be
replaced by the new hackage-server (based on happstack). I also stated
in my initial announcement that I would look into writing a version of
my reverse dependencies for the new server. I haven't done that yet.
Since at least July of 2010 the new server has some support for
reverse dependencies.

Unfortunately hackage-server seems to have lost a bit of momentum. It
is now almost 3 years old. Looking at "darcs show authors" I'd say
there are about 4 main contributors, with the main author being Duncan
Coutts. The last patches are from December 2010.

I think the best solution is to get more people contributing to
hackage-server. It is superior to the current hackage in many ways.


1 - http://code.haskell.org/hackage-server/

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


Re: [Haskell-cafe] The Lisp Curse

2011-05-20 Thread Roel van Dijk
On 19 May 2011 20:50, Serguey Zefirov  wrote:
> The solution... I think that some ratings, like "used directly by ###
> packages/projects and indirectly by ###" would be nice, but not much.

Maybe my reverse dependencies mirror of hackage could be useful here:
http://bifunctor.homelinux.net/~roel/hackage/packages/hackage.html

The mirror was intended to show the workings of a patch for the old
(current) hackage. It is updated daily.

The algorithm needs some attention so don't trust it blindly, but in
general it is quite accurate.

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


Re: [Haskell-cafe] Those damned parentheses

2011-05-10 Thread Roel van Dijk
On 10 May 2011 09:47, Andrew Butterfield  wrote:
> Why not indeed ?
> (-->) = flip (.)
> f = Main.id --> show --> (++ " = message received") --> putStrLn

-- (>>>) :: Category cat => cat a b -> cat b c -> cat a c

import Control.Category ( (>>>) )
f = Main.id >>> show >>> (++ " - message received") >>> putStrLn

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


Re: [Haskell-cafe] Storing failing testcases for QuickCheck

2011-04-24 Thread Roel van Dijk
On 24 April 2011 01:49, wren ng thornton  wrote:
> I would *love* there to be a tool which (a) automatically saves failing
> QuickCheck values to disk, and (b) automates using HUnit to load those in
> and test them. I'm not so sure that QuickCheck should be doing the second
> step of that since that'd really mess with the QuickCheck infrastructure;
> once you have the code for reading from disk, it'd be trivial to just use
> HUnit.

Maybe this is a job for test-framework? I think the API's of
QuickCheck and HUnit expose enough information for this to be
possible.

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


Re: [Haskell-cafe] IO and Cont as monads

2011-04-14 Thread Roel van Dijk
On 13 April 2011 21:26, Tim Chevalier  wrote:
> IO doesn't obey the monad laws, due to the presence of seq in Haskell.
> Sad but true...

See also a previous discussion about IO and the Monad laws:

http://www.haskell.org/pipermail/haskell-cafe/2010-March/074001.html

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


Re: [Haskell-cafe] Encoding of Haskell source files

2011-04-05 Thread Roel van Dijk
On 5 April 2011 07:04, Mark Lentczner  wrote:
> I'm not on that mailing list, so I'll comment here:

I recommend joining the prime list. It is very low traffic and the
place where language changes should be discussed.

> My only caveat is that the encoding provision should apply when Haskell
> source is presented to the compiler as a bare stream of octets. Where
> Haskell source is interchanged as a stream of Unicode characters, then
> encoding is not relevant -- but may be likely governed by some outer
> protocol - and hence may not be UTF-8 but nonetheless invisible at the
> Haskell level.

My intention is that every time you need an encoding for Haskell
sources, it must be UTF-8. At least if you want to call it Haskell.
This is not limited to compilers but concerns all tools that process
Haskell sources.

> Two examples where this might come into play are:
> 1) An IDE that stores module source in some database. It would not be
> relevant what encoding that IDE and database choose to store the source in
> if the source is presented to the integrated compiler as Unicode characters.

An IDE and database are free to store sources any way they see fit.
But as soon as you want to exchange that source with some standards
conforming system it must be encoded as UTF-8.

> 2) If a compilation system fetches module source via HTTP (I could imagine a
> compiler that chased down included modules directly off of Hackage, say),
> then HTTP already has a mechanism (via MIME types) of transmitting the
> encoding clearly. As such, there should be no problem if that outer protocol
> (HTTP) transmits the source to the compiler via some other encoding. There
> is no reason (and only potential interoperability restrictions) to enforce
> that UTF-8 be the only legal encoding here.

This is an interesting example. What distinguishes this scenario from
others is that there is a clear understanding between two parties
(client and server) how a file should be interpreted. I could word my
proposal in such a way that it only concerns situations where such a
prior agreement doesn't or can't exist. For example, when storing
source on a file system.

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


Re: [Haskell-cafe] Encoding of Haskell source files

2011-04-04 Thread Roel van Dijk
I made an official proposal on the haskell-prime list:

http://www.haskell.org/pipermail/haskell-prime/2011-April/003368.html

Let's have further discussion there.

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


Re: [Haskell-cafe] Encoding of Haskell source files

2011-04-04 Thread Roel van Dijk
2011/4/4 Ketil Malde :
> I think the safest thing to do is to require source to be ASCII, and
> provide escapes for code points >127...

I do not think that that is the safest option. The safest is just
writing down whatever GHC does. Escape codes for non-ASCII would break
a lot of packages and make programming really painful. Consider the
following, utf-8 encoded, file:

http://code.haskell.org/numerals/test/Text/Numeral/Language/ZH/TestData.hs

I don't want to imagine writing that with escape characters. It would
also be very error prone, not being able to readily read what you
write.

But the overall consensus appears to be UTF-8 as the default encoding.
I will write an official proposal to amend the haskell language
specification. (Probably this evening, utc+1).

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


Re: [Haskell-cafe] Encoding of Haskell source files

2011-04-04 Thread Roel van Dijk
On 4 April 2011 12:22, Michael Snoyman  wrote:
> Firstly, I personally would love to insist on using UTF-8 and be done with
> it. I see no reason to bother with other character encodings.

This is also my preferred choice.

> There *is* an algorithm for determining the encoding of an XML file based on
> a combination of the BOM (Byte Order Marker) and an assumption that the file
> will start with a XML declaration (i.e., ). But this isn't
> capable of determining every possible encoding on the planet, just
> distinguishing amongst varieties of UTF-(8|16|32)/(big|little) endian and
> EBCIDC. It cannot tell the difference between UTF-8, Latin-1, and
> Windows-1255 (Hebrew), for example.

I think I was confused between character encodings in general and
Unicode encodings.

> I think the implication of "Unicode encoding formats" is something in the
> UTF family. An encoding like Latin-1 or Windows-1255 can be losslessly
> translated into Unicode codepoints, but it's not exactly an encoding of
> Unicode, but rather a subset of Unicode.

That would validate Colin's point about there not being that many encodings.

> My guess is that a large subset of Haskell modules start with one of left
> brace (starting with comment or language pragma), m (for starting with
> module), or some whitespace character. So it *might* be feasible to take a
> guess at things. But as I said before: I like UTF-8. Is there anyone out
> there who has a compelling reason for writing their Haskell source in
> EBCDIC?

I think I misinterpreted the word 'leading'. I thought Colin meant
"most used". The set of characters with which Haskell programmes start
is indeed small. But like you I prefer no guessing and just default to
UTF-8.

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


Re: [Haskell-cafe] Encoding of Haskell source files

2011-04-04 Thread Roel van Dijk
2011/4/4 Colin Adams :
> Not from looking with your eyes perhaps. Does that matter? Your text editor,
> and the compiler, can surely figure it out for themselves.
I am not aware of any algorithm that can reliably infer the character
encoding used by just looking at the raw data. Why would people bother
with stuff like  if
automatically figuring out the encoding was easy?

> There aren't many Unicode encoding formats
>From casually scanning some articles about encodings I can count at
least 70 character encodings [1].

> and there aren't very many possibilities for the
> leading characters of a Haskell source file, are there?
Since a Haskell program is a sequence of Unicode code points the
programmer can choose from up to 1,112,064 characters. Many of these
can legitimately be part of the interface of a module, as function
names, operators or names of types.


[1] - http://en.wikipedia.org/wiki/Character_encoding

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


[Haskell-cafe] Encoding of Haskell source files

2011-04-04 Thread Roel van Dijk
Hello,

The Haskell 2010 language specification states that "Haskell uses
the Unicode character set" [1]. I interpret this as saying that,
at the lowest level, a Haskell program is a sequence of Unicode
code points. The standard doesn't say how such a sequence should
be encoded. You can argue that the encoding of source files is
not part of the language. But I think it would be highly
practical to standardise on an encoding scheme.

Strictly speaking it is not possible to reliably exchange Haskell
source files on the byte level. If I download some package from
hackage I can't tell how the source files are encoded from just
looking at the files.

I propose a few solutions:

A - Choose a single encoding for all source files.

This is wat GHC does: "GHC assumes that source files are ASCII or
UTF-8 only, other encodings are not recognised" [2]. UTF-8 seems like
a good candidate for such an encoding.

B - Specify encoding in the source files.

Start each source file with a special comment specifying the encoding
used in that file. See Python for an example of this mechanism in
practice [3]. It would be nice to use already existing facilities to
specify the encoding, for example:
{-# ENCODING  #-}

An interesting idea in the Python PEP is to also allow a form
recognised by most text editors:
# -*- coding:  -*-

C - Option B + Default encoding

Like B, but also choose a default encoding in case no specific
encoding is specified.

I would further like to propose to specify the encoding of haskell
source files in the language standard. Encoding of source files
belongs somewhere between a language specification and specific
implementations. But the language standard seems to be the most
practical place.

This is not an official proposal. I am just interested in what the
Haskell community has to say about this.

Regards,
Roel


[1] - 
http://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-150002.1
[2] - 
http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/separate-compilation.html#source-files
[3] - http://www.python.org/dev/peps/pep-0263/

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


Re: [Haskell-cafe] darcs repo browser

2011-04-02 Thread Roel van Dijk
Nice work!

The view file part seems to have problems with utf-8 encoded files:
http://handra.rampa.sk/dawb/view?repoVURL=http%3A%2F%2Fcode.haskell.org%2Fnumerals&repoVFile=test%2FText%2FNumeral%2FLanguage%2FZH%2FTestData.hs

It is unreadable even when explicitly asking my browser to decode the
document as UTF-8. This makes me suspect the problem is in the code
that processes files to produce the HTML.

I have no solution ready for this problem. Each file could potentially
use a different encoding.

Apart from this inconvenience your tool looks very useful.

Regards,
Roel

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


Re: [Haskell-cafe] [ghci] unknown symbol in base-unicode-symbols-0.2.1.2 ...

2011-03-30 Thread Roel van Dijk
I can reproduce the problem on my system with GHC-7.0.3.

The flag old-base is meant for base libraries before 3.0.3.1 which
didn't export a Control.Category module. It looks like I accidentally
inverted the logic of the flag. What is weird is that is still builds
okay on my system. I would expect that, given the inverted flag logic,
Control.Category.Unicode would be missing from the installed package's
exposed module list.

I fixed the logic of the flag and the bug appears to be gone. I
uploaded the fixed version 0.2.1.3.

Thanks for the bug report!


On 31 March 2011 00:05, John Obbele  wrote:
> On Wed, Mar 30, 2011 at 10:37:47PM +0200, John Obbele wrote:
>> I'm having a problem in GHCi when loading modules relying on the
>> base-unicode-symbols package. My prompt gives me the following
>> message:
>>
>> >> ghci $
>> Loading package base-unicode-symbols-0.2.1.2 ... linking ... : 
>> /home/john/.cabal/lib/base-unicode-symbols-0.2.1.2/ghc-7.0.2/HSbase-unicode-symbols-0.2.1.2.o:
>>  unknown symbol 
>> `__stginit_basezmunicodezmsymbolszm0zi2zi1zi2_ControlziCategoryziUnicode_'
>> ghc: unable to load package `base-unicode-symbols-0.2.1.2'
>
>
> Oki, so I'm answering to myself: the base-unicode-symbols cabal
> file introduces a quirk concerning 'base' version which hides the
> symbols in Control.Category.Unicode.
>
>>> base-unicode-symbols.cabal -- line 42-46
>  if !flag(old-base)
>    build-depends: base >= 3.0 && < 4.4
>  else
>    build-depends: base >= 3.0.3.1 && < 4.4
>    exposed-modules: Control.Category.Unicode
>
> I should contact the maintainer about this …

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


Re: [Haskell-cafe] Data constructor synonyms

2011-03-18 Thread Roel van Dijk
Remember that constructors are functions, except that you can't
pattern match against them.

> data MyType = GeneralConstructor [Double]

> -- GeneralConstructor :: [Double] -> MyType

Note the lower case character, just a plain function:
> specialConstructor :: Double -> MyType
> specialConstructor a = GeneralConstructor (a:[])

> zero :: MyType
> zero = GeneralConstructor [0]

The downside is that you can't pattern-match against these functions.

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


Re: [Haskell-cafe] order of arguments matters

2011-03-18 Thread Roel van Dijk
I checked out the GHC documentation on the GADTs extension [1]:

"The key point about GADTs is that pattern matching causes type
refinement."

So in
  tr2 (Tree Int) (Node _ (t:_)) = Node 1 [t]
the 'a' in 'Type a' is refined to 'Type (Tree a)'.

But in
  tr1 (Node _ (t:_)) (Tree Int) = Node 1 [t]
you want to "generalise" the type 'Tree a' to 'Type (Tree a)', which
is not possible.


1 - 
http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/data-type-extensions.html#gadt

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


Re: [Haskell-cafe] order of arguments matters

2011-03-18 Thread Roel van Dijk
I believe this is caused by type equalities that are introduced by the
Type a argument. In tr2 you get something like a ~ Int or a ~ String,
allowing the function to type check. In tr1 that equality is never
introduced so the type checker thinks a and Int are distinct types.

But I'm sure someone else can provide a better (more correct) explanation.

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


Re: [Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-09 Thread Roel van Dijk
Both your replies where very helpful. I combined both approaches to
get nearer to what I want.

> class Lit α where lit ∷ Integer → α
> class Add α where add ∷ α → α → α

> instance Lit Integer where lit = fromInteger
> instance Add Integer where add = (+)

This time I require TypeSynonymInstances:
> instance Lit String where lit = show
> instance Add String where add x y = "(" ++ x ++ " + " ++ y ++ ")"

Felipe's generalized context type:
> data AddCtx α = Empty
>   | AddL α (AddCtx α)
>   | AddR α (AddCtx α)

Combination of Oleg's tagless transformer and Felipe's CtxInterpB:
> instance (Add α, Add β) ⇒ Add (AddCtx β → α, β) where
> add (xa, xb) (ya, yb) = ( \c → add (xa (AddL yb c))
>(ya (AddR xb c))
> , add xb yb
> )
The previous instance allows me to construct Strings while having
Integers in the context.

Silly interpreter, version 2.0
> instance Lit (AddCtx Integer → String, Integer) where
> lit n = ( \c → case c of
>  AddL 3 _ → "Foo!"
>  _ → lit n
> , lit n
> )

Simple term:
> t1 ∷ (Lit α, Add α) ⇒ α
> t1 = lit 2 `add` lit 3

Interpret as a String:
> bar = let (f, x) = t1 ∷ (AddCtx Integer → String, Integer)
>   in f Empty

>> "(Foo! + 3)"

This is already an improvement to my current code. But I am not
entirely satisfied. I can pick and choose which structures to use in
my terms but the context type is still an ordinary data type. Each
module which extends the expression language with new structures needs
to define a complicated context type.

My plan is to define the context as a type class. Obviously I can't
perform case analysis on a polymorphic type so I'll have to add that
functionality to each context class in some way.

Thank you for your helpful replies!

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


[Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-08 Thread Roel van Dijk
Hello everyone,

I am stuck rewriting some code in the tagless style. My problem can be
thought of as an interpreter for a very simple language:

> data Exp = Lit Integer
>  | Add Exp Exp
>  | Mul Exp Exp
>deriving (Show)

But some complexity is added by the fact that my interpreter also
needs to know the context in which literals appear in an
expression. So given the example

> t1 :: Exp
> t1 = (Lit 3 `Add` Lit 4) `Mul` Lit 2

I want to have access to the fact that the literal 3 appears on
the left side of an addition. Therefore I created a type:

> data Ctx = Empty
>  | AddL Exp Ctx
>  | AddR Exp Ctx
>  | MulL Exp Ctx
>  | MulR Exp Ctx
>deriving (Show)

This is almost a zipper over the Exp type. I left out a context for
literals themselves because it wasn't necessary. Now I can create a
simple evaluation function:

> eval :: (a -> a -> a)
>  -> (a -> a -> a)
>  -> (Integer -> Ctx -> a)
>  -> Exp
>  -> a
> eval add mul lit = go Empty
> where
>   go ctx (Lit n)   = lit n ctx
>   go ctx (Add x y) = let x' = go (AddL y ctx) x
>  y' = go (AddR x ctx) y
>  in x' `add` y'
>   go ctx (Mul x y) = let x' = go (MulL y ctx) x
>  y' = go (MulR x ctx) y
>  in x' `mul` y'

This function can evaluate an expression to any type 'a', but it needs
some additional functions to accomplish that: add, mul and lit. Notice
how the 'lit' function has access to a literal's context. To interpret
an Exp as an Integer I use:

> evalInt :: Exp -> Integer
> evalInt = eval (+) (*) const

Or as a String:

> evalStr1 :: Exp -> String
> evalStr1 = eval addStr mulStr (const . show)

> addStr x y = "(" ++ x ++ " + " ++ y ++ ")"
> mulStr x y = "(" ++ x ++ " * " ++ y ++ ")"

Or a silly example which uses the context:

> evalStr2 :: Exp -> String
> evalStr2 = eval addStr mulStr lit
> where
>   lit _ (AddL (Lit 4) (MulL _ _)) = "Foo!"
>   lit n _ = show n

The silly example replaces a literal with "Foo!" if it appears on the
left side of an addition with 4, and the whole addition is the left
side of a multiplication, like in (x + 4) * ?.

All of this works. But I want to be able to add additional
constructors to the Exp language without changing existing code. This
looks like the expression problem.

Ignoring the zipper-like context I came up with the following:

First define the language:
> class Lit a where lit :: Integer -> a
> class Add a where add :: a -> a -> a
> class Mul a where mul :: a -> a -> a

Integer interpreter:
> instance Lit Integer where lit = fromInteger
> instance Add Integer where add = (+)
> instance Mul Integer where mul = (*)

String interpreter, using a newtype so I don't need
TypeSynonymInstances:
> newtype Str = Str {unS :: String}
> instance Show Str where show = show . unS

> instance Lit Str where lit = Str . show
> instance Add Str where add x y = Str $ addStr (unS x) (unS y)
> instance Mul Str where mul x y = Str $ mulStr (unS x) (unS y)

Same example expression, now polymorphic:
> t1 :: (Lit a, Add a, Mul a) => a
> t1 = (lit 3 `add` lit 4) `mul` lit 2

This expression can now be interpreted in multiple ways:
> t1 :: Integer
>> 14
> t1 :: Str
>> "((3 + 4) * 2)"

This solves the expression problem. I can add new structures to my
language in other modules without having to change existing code. The
necessary parts are mentioned in the type constraint (Lit a, Add a,
Mul a).

But I lost the power of the context! How do I get it back?

Attached are the two approaches, WithTags.hs and Tagless.hs (but
without context).

Any help would be greatly appreciated!
module WithTags where

data Exp = Lit Integer
 | Add Exp Exp
 | Mul Exp Exp
   deriving (Show)

data Ctx = Empty
 | AddL Exp Ctx
 | AddR Exp Ctx
 | MulL Exp Ctx
 | MulR Exp Ctx
   deriving (Show)

eval :: (a -> a -> a)
 -> (a -> a -> a)
 -> (Integer -> Ctx -> a)
 -> Exp
 -> a
eval add mul lit = go Empty
where
  go ctx (Lit n)   = lit n ctx
  go ctx (Add x y) = let x' = go (AddL y ctx) x
 y' = go (AddR x ctx) y
 in x' `add` y'
  go ctx (Mul x y) = let x' = go (MulL y ctx) x
 y' = go (MulR x ctx) y
 in x' `mul` y'

evalInt :: Exp -> Integer
evalInt = eval (+) (*) const

addStr x y = "(" ++ x ++ " + " ++ y ++ ")"
mulStr x y = "(" ++ x ++ " * " ++ y ++ ")"

evalStr1 :: Exp -> String
evalStr1 = eval addStr mulStr (const . show)

evalStr2 :: Exp -> String
evalStr2 = eval addStr mulStr lit
where
  lit _ (AddL (Lit 4) (MulL _ _)) = "Foo!"
  lit n _ = show n

t1 :: Exp
t1 = (Lit 3 `Add` Lit 4) `Mul` Lit 2
module Tagless where

class Lit a where lit :: Integer -> a
class Add a where add :: a -> a -> a
class Mul a where mul :: a -> a -> a

instance Lit In

Re: [Haskell-cafe] Performance difference between ghc and ghci

2011-02-21 Thread Roel van Dijk
In general code compiled with GHC will be a lot faster than code
interpreted by GHCI. You can also call compiled code from within GHCI,
in which case you would hardly see a performance difference.

On 22 February 2011 08:26, C K Kashyap  wrote:
> Hi,
> Is there a runtime performance difference between a haskell program running
> under GHCI vs in its compiled form?
> Especially for a long running program - as in, ignoring the initial setup
> time.
> If I understand right, in both case tree reduction is what is happening and
> performance should be similar.
> Regards,
> Kashyap

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


Re: [Haskell-cafe] Status update on {code, trac, projects, planet, community}.haskell.org

2011-02-17 Thread Roel van Dijk
I believe code.haskell.org has moved to a new machine. Its IP address
also changed, which causes your ssh to issue a warning. You can fix it
by deleting the code.haskell.org entry from your local
~/.ssh/known_hosts file.

On 16 February 2011 18:58, Henning Thielemann
 wrote:
>
> Thank you a lot for bringing code.haskell.org back! I missed it a lot!
> However, I still get
>
> $ ssh code.haskell.org
> @@@
> @       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
> @@@
> The RSA host key for code.haskell.org has changed,
> and the key for the according IP address 178.63.91.44
> is unknown. This could either mean that
> DNS SPOOFING is happening or the IP address for the host
> and its host key have changed at the same time.
> @@@
> @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
> @@@
> IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
> Someone could be eavesdropping on you right now (man-in-the-middle attack)!
> It is also possible that the RSA host key has just been changed.
> ...
>
>
> How can I verify that it is safe to continue logging in?
> Could you restore the old host key?

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


Re: [Haskell-cafe] Byte Histogram

2011-02-07 Thread Roel van Dijk
On 7 February 2011 22:00, Andrew Coppin  wrote:
> I clearly have my languages mixed up.
>
> The language I'm thinking of required all variables (even top-level ones) to
> be declared with "let" - unless the definition is recursive, in which case
> you have to say "letrec" (i.e., the compiler it too stupid to deduce this
> automatically). Apparently that isn't Clean...

You are not necessarily wrong. Clean, like Haskell, is a moving
target. To quote the paper "Exchanging Sources Between Clean and
Haskell" [1]:

  The year of 1987 was a founding one for two pure, lazy, and
  strongly typed functional programming languages. Clean (Brus et
  al., 1987) was presented to the public for the first time and
  the first steps towards a common functional language, later
  named Haskell, were taken (Hudak et al., 2007).

  Clean was conceived at the Radboud University Nijmegen as a core
  language that is directly based on the computational model of
  functional term graph rewriting to generate efficient code. It
  also serves as an intermediate language for the compilation of
  other functional languages (Koopman and Nöcker, 1988;
  Plasmeijer and van Eekelen, 1993). For these reasons, it
  deliberately used a sparse syntax (van Eekelen et al., 1990):
  “... at some points one can clearly recognize that [..] Clean
  is a compromise between a functional programming language and
  an intermediate language used to produce efficient code. For
  instance, a minimal amount of syntactic sugar is added in [..]
  Clean.”. Later, the core language was sugared.

The Clean of 1987—1994 sounds a lot like the language you are
talking about.

1 - 
http://www.cs.ru.nl/~thomas/publications/groj10-exchanging-sources-between.pdf

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


Re: [Haskell-cafe] Byte Histogram

2011-02-06 Thread Roel van Dijk
On 5 February 2011 16:21, Andrew Coppin  wrote:
> I didn't think Clean supported laziness at all? I thought it was a strict
> language.

"CLEAN is a practical applicable general-purpose lazy pure functional
programming language suited for the development
of real world applications." [1]

Haskell en Clean are very much alike. You can even compile Haskell 98
code with the latest (experimental) Clean compiler and having it
interact with Clean code and vice-versa [2]. The main difference is
Clean's use of uniqueness typing.


1 - http://clean.cs.ru.nl/download/Clean20/doc/CleanLangRep.2.1.pdf
2 - 
http://www.cs.ru.nl/~thomas/publications/groj10-exchanging-sources-between.pdf

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


Re: [Haskell-cafe] hmatrix's fitModel function crashes ghc(i)

2010-11-07 Thread Roel van Dijk
Thank you for your reply. I will follow progress on the ticket.

On Mon, Nov 8, 2010 at 3:57 AM, Vivian McPhail
 wrote:
> Here's the ticket:
>
> http://hackage.haskell.org/trac/ghc/ticket/781
>
> They aim to fix the problem (with fPIC) by ghc 7.2.
>
> Cheers,
>
> Vivian
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: hmatrix's fitModel function crashes ghc(i)

2010-11-07 Thread Roel van Dijk
Cool, this means hmatrix is still an option for my fitting problem.
The problem is a bit annoying but I can work with it.

My assumption about the cause of the problem (wrong number of
arguments) made me miss the real problem.

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


[Haskell-cafe] hmatrix's fitModel function crashes ghc(i)

2010-11-06 Thread Roel van Dijk
Hello,

I would like to use hmatrix to do some function fitting with the
Levenberg Marquardt algorithm. As an example I would like to fit the
very simple function "f x = a*x + b" on some data points. The problem
is that executing the 'fitModel' function crashes GHC(i) with a
segmentation fault. This makes debugging difficult. Can anyone spot
what I am doing wrong? Given all the lists of Double's it seems very
easy to make an error regarding the number of arguments with the model
function or the derivative.

Try to evaluate the 'test' function in the small program listed below.
I would expect an output of [1, 0] (y = 1*x + 0) instead of a
segmentation fault.

Relevant versions:
 - hmatrix-0.10.0.0
 - gsl-1.14
 - ghc-6.12.3 (64 bit)


Small program:

module Test where

-- from base:
import Control.Arrow ( second )
import Control.Applicative   ( pure )

-- from hmatrix:
import Data.Packed.Matrix( Matrix )
import Numeric.GSL.Fitting   ( FittingMethod(LevenbergMarquardt), fitModel )


-- input list of (x, y) pairs, output coefficients of "f x = a x * b"
fitLinear :: [(Double, Double)] -> ([Double], Matrix Double)
fitLinear samples = fitModel 1
 1
 10
 (linearModel, linearDer)
 (map (second pure) samples)
 [0, 0]

linearModel :: [Double] -> Double -> [Double]
linearModel [a, b] x = [a*x + b, 0]
linearModel _  x = error "wrong arguments"

linearDer :: [Double] -> Double -> [[Double]]
linearDer [_, _] x = [[x, 0]]
linearDer _  _ = error "wrong arguments"

test = fitLinear [(0,0), (1,1), (2,2)]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] commutativity

2010-11-01 Thread Roel van Dijk
Yes, that would prevent the shadowing. But now you are ignoring the
argument op1. Choosing a name that is more different from 'op' might
be helpful. You can even invent your own operator as an argument to
your commutative function:

  commutative (⊕) = \a b -> (a ⊕ b) == (b ⊕ a)

On Mon, Nov 1, 2010 at 11:15 AM, Patrick Browne  wrote:
> Does the following avoid the shadowing?
>
> infixl 5 `op`
> op :: Int -> Int -> Int
> x `op` y  = (x + y)
> commutative op1 = \a b ->  (a `op` b) == (b `op` a)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bulletproof resource management

2010-10-18 Thread Roel van Dijk
> I think somebody else already mentioned region-based management, which is
> also completely safe AFAIK.

Ben Franksen mentioned my brother's regions package [1]. He's about to
release a new version with simpler type machinery. The list of
packages that make use of the regions package [2] can serve as an
example how to use these lightweight monadic regions [3].

Regards,
Roel

1 - http://hackage.haskell.org/package/regions
2 - 
http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/regions#direct
3 - http://okmij.org/ftp/Haskell/regions.html#light-weight
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Make your Darcs repositories hashed?

2010-10-09 Thread Roel van Dijk
The darcs installed on code.haskell.org is still version 2.02. It
doesn't know about 'optimize --upgrade'. How do I upgrade those
repositories?

On Sat, Oct 9, 2010 at 2:30 PM, Christopher Done
 wrote:
> Every Darcs repository I've pulled this year has always showed me this 
> message:
>
> ***
> Fetching a hashed repository would be faster.  Perhaps you could persuade
> the maintainer to run darcs optimize --upgrade with darcs 2.4.0 or higher?
> ***
>
> Maintainers! Please run darcs optimize --upgrade
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda-case / lambda-if

2010-10-04 Thread Roel van Dijk
I really like the lambda-case. There are dozens of places in my code
where I could use it.

Not so sure about the lambda-if. It is just as easily done using an
ordinary function.

lambda-case: +1
lambda-if: neutral
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Coding conventions for Haskell?

2010-09-30 Thread Roel van Dijk
Here is a list of fonts that support that particular character:
http://www.fileformat.info/info/unicode/char/2237/fontsupport.htm

I think I'll add a little font overview to my unicode-symbols wiki
page. Most Unicode symbols that are useful in Haskell are not terribly
obscure and supported by a wide range of fonts.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Coding conventions for Haskell?

2010-09-30 Thread Roel van Dijk
I align my imports by hand, but your Emacs scripts look useful. I
think I'm going to use them too.

Another extremely useful function for aligning is align-regexp.

On the subject of coding style, I can work with almost any style as
long as it is used somewhat consistently. Personally I try to optimize
my code for ease of reading because I spend much more time reading
code than writing. Aligning stuff vertically makes it easier to spot
differences.

On Thu, Sep 30, 2010 at 4:02 PM, Christopher Done
 wrote:
> FWIW, I align all my module imports up, as seen here:
> http://github.com/chrisdone/amelie/raw/master/src/Web/Codepad.hs  and
> here http://github.com/chrisdone/amelie/raw/master/src/Amelie/HTML.hs
> etc.
>
> I use the following Emacs library to do it for me:
> http://github.com/chrisdone/haskell-mode-exts/raw/master//haskell-align-imports.el
>
> I also sort them with this:
> http://github.com/chrisdone/haskell-mode-exts/blob/master//haskell-sort-imports.el
> but it only works for one-line imports, which I advocate anyway.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haltavista - look for functions by example

2010-09-19 Thread Roel van Dijk
Impressive! I didn't think you could implement it so quickly.

Now someone needs to add this functionality to Leksah or hack
something up for Emacs.

Regards,
Roel

On Sun, Sep 19, 2010 at 8:27 PM, Paul Brauner  wrote:
> It works:
>
> brau...@worf:/tmp$ cat test.hs
> import Test.QuickCheck
> import Test.QuickCheck.Arbitrary
> import Control.Monad(forM_)
>
> intMul :: Integer -> Integer -> Integer
> intMul x n | n <  0 = -(intMul x $ abs n)
>           | n == 0 = 0
>           | n >  0 = x + intMul x (n - 1)
>
> main = do xs <- sample' arbitrary
>          ys <- sample' arbitrary
>          zip xs ys `forM_` \(x,y) ->
>            putStrLn (show x ++ " " ++ show y ++ " " ++ (show $ intMul x y))
>
>
> brau...@worf:/tmp$ runghc test.hs | haltavista
> Prelude (*)
>
> I will include this functionality in the next version. Thank you for
> this nice idea.
>
> Paul
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haltavista - look for functions by example

2010-09-19 Thread Roel van Dijk
In my haste to reply I made an error in my 'newby' multiplication
function. Pesky negative numbers...

  intMul ∷ Integer → Integer → Integer
  intMul x n | n <  0 = -(intMul x $ abs n)
 | n == 0 = 0
 | n >  0 = x + intMul x (n - 1)

I do wonder what happens when haltavista encounters a function that
diverges. Like my original intMul applied to a negative number:
"intMul 2 (-1)".
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haltavista - look for functions by example

2010-09-19 Thread Roel van Dijk
Very interesting!

It got me thinking: if you combine this with the Arbitrary class [1]
of QuickCheck you can use it check if you have defined a function that
is "equal" to an already defined function.

Let's say I write the following function:

  intMul ∷ Integer → Integer → Integer
  intMul x 0 = 0
  intMul x n = x + intMul x (n - 1)

No you can automatically apply this function to a list of 100
generated inputs to get a list of input output pairs. Feed this into
haltavista and it should tell you that you can replace your definition
with Prelude (*). While such an observation is certainly not a proof
it is still useful.

It would be a nice addition to a Haskell editor. Especially for those
new to the language.

Regards,
Roel

1 - 
http://hackage.haskell.org/packages/archive/QuickCheck/2.3/doc/html/Test-QuickCheck-Arbitrary.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] feasability of implementing an awk interpreter.

2010-08-23 Thread Roel van Dijk
On Mon, Aug 23, 2010 at 8:07 AM, Richard O'Keefe  wrote:
> But what _is_ "the core functionality".
> The Single Unix Specification can be browsed on-line.
> There is no part of it labelled "core"; it's all required
> or it isn't AWK.  There are weird little gotchas like
>        File "foo" = '{ prin'
>        File "bar" = 't 2 }'
>        awk -f foo -f bar
> is legal and is required to act the same as
>        awk '{ print 2 }'
> mawk fails this, and I don't blame it, and I don't really _care_.
> Is that "core"?  Who knows?

I say that that behaviour is not part of the language but of the runtime.

> Whatever the "core functionality" might be, YOU will have to define
> what that "core" is.  There's no standard, or even common, sublanguage.

One approach to find the core of a language is to find which parts can
be implemented in terms of other parts. If part B can be expressed in
terms of part A then B doesn't belong in the core.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Roel van Dijk
On Tue, Aug 17, 2010 at 3:53 AM, Richard O'Keefe  wrote:
> On Aug 17, 2010, at 12:37 AM, Roel van Dijk wrote:
>>
>> phi = (1 + sqrt 5) / 2
>> fib n = ((phi ** n) - (1 - phi) ** n) / sqrt 5
>>
>> The use of (**) should make the complexity at least O(n). Please
>> correct me if I'm wrong (or sloppy).
>
> Using the classic
>        x**0 = 1
>        x**1 = x
>        x**(2k+0) = (x**2)**k           k > 0
>        x**(2k+1) = (x**2)**k + x       k > 1
> powers of smallish numbers or matrices can be computed in logarithmic
> time.
That is an interesting trick. So there exists an algorithm that
calculates Fibonacci numbers in O(log n) time.

> Using x**n = exp(n*log(x)) and floating point arithmetic,
> the whole thing can be done in O(1) time, and the price of
> some inaccuracy.
It will calculate a subset of the Fibonacci numbers in O(1) time.
Thinking about it I think you can easily calculate subsets of any
function in O(1) time, as long as the function is guaranteed to
terminate. Simply precompute the answers and store them in an array.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Roel van Dijk
On Sat, Aug 14, 2010 at 5:41 PM, Andrew Coppin
 wrote:
>  (Then again, the Fibonacci numbers can be computed
> in O(1) time, and nobody ever needs Fibonacci numbers in the first place, so
> this is obviously example code.)

A bit off-topic, but I don't think there exists a function that
computes fibonacci numbers in O(1) time. There exists a closed-form
expression to calculate the nth Fibonacci number, but the complexity
of that expression is not O(1):

phi = (1 + sqrt 5) / 2
fib n = ((phi ** n) - (1 - phi) ** n) / sqrt 5

The use of (**) should make the complexity at least O(n). Please
correct me if I'm wrong (or sloppy).

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


Re: [Haskell-cafe] expression problem

2010-08-16 Thread Roel van Dijk
Have you read Wouter Swierstra's "Data Types A La Carte" [1]?

Whether it uses basic and easy parts of Haskell depends on your
mindset. You need to wrap your head around the fixpoint. It requires
at least the MultiParamTypeClasses language extension.

Regards,
Roel

1 - http://www.cs.nott.ac.uk/~wss/Publications/DataTypesALaCarte.pdf

On Mon, Aug 16, 2010 at 12:17 PM, Patrick Browne  wrote:
> Hi,
> The expression problem [1] can be described as the ability to add new
> variants (either constructors or methods) to a data type  without
> changing the existing code. The Haskell and OO language issues are well
> described at [1]
> It seems that the expression problem does not exist in Maude[2].
>
> My question is:
> Using basic and easy parts of the Haskell, does Haskell currently handle
> the expression problem.  In other words I would like to avoid demanding
> and sophisticated coding techniques or non-standard Haskell extensions
> (i.e. it should be easy for the average programmer to use).
> If there is a simple solution could you please point me to an example.
>
> Thanks,
> Pat
>
>
>
> [1] Dr. Ralf Laemmel
> http://channel9.msdn.com/shows/Going+Deep/C9-Lectures-Dr-Ralf-Laemmel-Advanced-Functional-Programming-The-Expression-Problem/
> [2]http://lists.cs.uiuc.edu/pipermail/maude-help/2010-January/000336.html
>
>
> This message has been scanned for content and viruses by the DIT Information 
> Services E-Mail Scanning Service, and is believed to be clean. 
> http://www.dit.ie
> ___
> 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] xemacs newbie question - haskell mode

2010-08-15 Thread Roel van Dijk
Note the following line from the haskell-mode project page: "If it
works on XEmacs, consider yourself lucky." [1]

Regards,
Roel

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


Re: [Haskell-cafe] Недвижимость во Ф ранции, аренда и продажа вилл

2010-05-21 Thread Roel van Dijk
Google translation:
> The office of our company is located in Nice - the heart of the
> Riviera, that gives us an immediate opportunity to offer villas
> for rent and sale in all their diversity, as well as guidance to
> our clients on the most interesting and important events in the
> rich cultural and social life Cote d'Azur. We offer our customers
> a wide choice of luxury villas on the entire length of the Côte
> d'Azur of France - from St Tropez to Monaco, visa support and
> arrange visits to your vending facility at the conclusion of
> contracts for lease or purchase of houses and other real estate

> Mediterranean coast. Dear partners, we offer you our cooperation
> in the acquisition of your clients property in France, Cote
> d'Azur, which has always valued art lovers, connoisseurs of
> history, lovers of fine cuisine and beautiful scenery.

So spam for luxury villa's? I guess Haskell really failed in avoiding success...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wait forever in main thread

2010-05-17 Thread Roel van Dijk
Use our threads package [1].

import Control.Concurrent.Thread ( forkIO, wait_ )

myDBusThingie :: IO ()
myDBusThingie = error "TODO"

main :: IO ()
main = do tid <- forkIO myDBusThingie
  wait_ tid


But like David said, this is only usefull if you plan on multiple
concurrent waits or doing some other work during the wait. Otherwise
you can simply replace the contents of main with myDBusThingie.

Regards,
Roel


1 - http://hackage.haskell.org/package/threads (new, backwards
compatible, version will be released soon)

On Mon, May 17, 2010 at 7:04 PM, DPX-Infinity  wrote:
> Hi,
> I'm writing a program which listens to some D-Bus signals using
> DBus.Client.onSignal function from dbus-client package. This function
> runs IO action in separate haskell thread when signal is received. My
> program does nothing except signal handling, so after setting up
> signals it has to wait indefinitely. Now I'm using not very clean (I
> think so) forever $ threadDelay 1000 . Is there another (I mean,
> correct) method to do this thing?
> ___
> 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] ANN: precis-0.3.1 - Cabal package diff tool

2010-05-13 Thread Roel van Dijk
On Thu, May 13, 2010 at 5:23 PM, Stephen Tetley
 wrote:
> Hi Bas
>
> I'm not entirely surprised...
>
> Do you know if haskell-src-exts can parse files with Unicode syntax
> (and I'm not using enough extensions)?
>
> Thanks
>
> Stephen

Last time I checked it had problems with the ∷ and ∀ characters. I
reported it to Neil Mitchell (it showed up in hlint) who in turn
reported it to Niklas Broberg.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Shorthand method of enumerating a list a gotcha ... or is it just me?

2010-05-07 Thread Roel van Dijk
>From the Haskell 98 report (section 6.3.4):

> For Float and Double, the semantics of the enumFrom  family is given by the 
> rules for Int above, except that the list terminates when the elements become 
> greater than e3+i/2  for positive increment i, or > when they become less 
> than e3+i/2  for negative i.

So yes, it is surprising, but according to the specification. But then
again the very concept of a type like Float having an Enum instance is
a bit weird.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] nun.haskell.org http services down?

2010-05-05 Thread Roel van Dijk
I think it would be nice in general to be able to mirror at least
hackage.haskell.org. Something like rsync would be close to ideal for
this purpose.

Reasons I would like to mirror hackage:
1 - Provide alternative when the main hackage is down
2 - Access to the sources of all uploaded packages for analysis purposes
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-04 Thread Roel van Dijk
Here is my attempt. I tried to avoid higher concepts like folds and
things like the ($) operator. Most recursions are written explicitly.

{ BEGIN CODE }

module Main where

-- Data type representing a door which is either Open or Closed.
data Door = Open | Closed deriving Show

toggle :: Door -> Door
toggle Open   = Closed
toggle Closed = Open

-- Applies the function f to every n'th element of a list.
skipMap :: (a -> a) -> Int -> [a] -> [a]
skipMap f n | n < 1 = error "skipMap: step < 1"
| otherwise = go (n - 1)
  where
-- Apply the function 'f' to an element of the list when the
-- counter reaches 0, otherwise leave the element untouched.
go _ [] = []
go 0 (x:xs) = f x : go (n - 1) xs
go c (x:xs) = x : go (c - 1) xs

-- Calculate the final answer.
run :: Int -> [Door]
run n = go 1 initialDoors -- Start by toggling every door.
  where
-- Initial list of closed doors
initialDoors :: [Door]
initialDoors = replicate n Closed

-- Toggle every c doors, then proceed by toggling every c+1 doors
-- of the result, etcetera... Stops after toggling the n'th door.
go :: Int -> [Door] -> [Door]
go c doors
| c > n = doors
| otherwise = go (c + 1) (skipMap toggle c doors)

-- Print information about a single door.
printDoor :: (Int, Door) -> IO ()
printDoor (n, door) = putStrLn ("Door #" ++ show n ++ " is " ++ show door)

printRun :: Int -> IO ()
printRun n = mapM_ printDoor (zip [1..n] (run n))

-- The program entry point.
main :: IO ()
main = printRun 100

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


Re: [Haskell-cafe] Strict type system allows for a maximum number of programming errors to be caught at compile time.

2010-05-03 Thread Roel van Dijk
In my opinion code is 'right' when it conforms to the specification.
Haskell's type system allows the programmer to express a part of the
specification in the types, which then get checked by the
compiler/type-checker. This is where I see the biggest benefit of a
very expressive statically checked type system.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Threads freezing

2010-04-25 Thread Roel van Dijk
The problem could be in your use of forkIO.

To quote the documentation of forkOS [1]:

>Like forkIO, this sparks off a new thread to run the IO computation passed as 
>the first argument, and returns the ThreadId of the newly created thread.
>However, forkOS creates a bound thread, which is necessary if you need to call 
>foreign (non-Haskell) libraries that make use of thread-local state, such as 
>OpenGL (see Control.Concurrent).

So you have to make sure that all calls to OpenGL originate from a
bound thread and furthermore that all calls to OpenGL originate from
_the same_ thread.

Regards,
Roel


1 - 
http://hackage.haskell.org/packages/archive/base/4.2.0.1/doc/html/Control-Concurrent.html#v%3AforkOS
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-14 Thread Roel van Dijk
On Wed, Apr 14, 2010 at 2:32 AM, Ivan Miljenovic
 wrote:
> Why not use Maybe for func1 in the first place?  Or are you wanting to
> automagically make all uses of head, tail, etc. safe?

In which case there is already the 'safe' package:
http://hackage.haskell.org/package/safe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-14 Thread Roel van Dijk
Can anyone provide an example of an error that is prevented by this
warning? When exactly is it dangerous to ignore a monadic function's
return value?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Hackage accounts and real names

2010-04-06 Thread Roel van Dijk
On Tue, Apr 6, 2010 at 1:08 PM, Serguey Zefirov  wrote:
> http://lambda-the-ultimate.org is one lovely community that has that
> restriction: http://lambda-the-ultimate.org/policies#Policies

LtU has no restriction on user names. From LtU's policy:
> Anonymity and the use of pseudonyms is discouraged.

I'm against *requiring* the use of a "real name" for hackage accounts.
I have no problems with encouraging the use of given/everyday names.

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


Re: [Haskell-cafe] Are there any gay haskelleres?

2010-03-28 Thread Roel van Dijk
Programming in Haskell certainly makes me feel gay.

define gay
cheery: bright and pleasant; promoting a feeling of cheer; "a cheery
hello"; "a gay sunny room"; "a sunny smile"
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Timeouts that don't cause data growth.

2010-03-23 Thread Roel van Dijk
I tried a few things. First I added another timeout to main, so the
program kills itself after a few seconds.

doit :: IO (Maybe ())
doit = timeout 1200 $ {- yield >> -} return ()

main :: IO ()
main = do _ <- timeout 500 $ forever doit
  return ()

This program failed to terminate. But when I compiled -with threaded
and added a yield to doit, it worked (kinda). If the timeout in doit
is not too long, like 200 milliseconds, the program has constant space
usage. But when I increased the timeout in doit to 12 seconds I got a
stack overflow.

I'll investigate further when I have more time.

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


Re: [Haskell-cafe] developing against privately patched libraries, and cabal

2010-03-23 Thread Roel van Dijk
The documentation for Data.Version might be insightful:

http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-Version.html

If Cabal uses the parseVersion function to parse versions then the
following version is valid: "1.2.3-a-b-c". If should result in this
value:

Version {versionBranch = [1,2,3], versionTags = ["a", "b", "c"]}

But I don't know if Cabal allows you to depend on such a version.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Has "Try Haskell! An interactive tutorial in your browser" been announced yet?

2010-03-01 Thread Roel van Dijk
I think these reddit posts are relevant:

First announcement:
http://www.reddit.com/r/haskell/comments/b58rk/try_haskell/

Second announcement:
http://www.reddit.com/r/haskell/comments/b7dil/try_haskell_now_with_t_and_wip_interactive/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Testing and module export lists

2010-02-25 Thread Roel van Dijk
What I usually do in such a case is create a separate internal
module. The internal module exports everything. Then create a
module which defines the public interface. This module simple
reexports symbols from the internal module. Now you can create a
Test module which has full access to all internal symbols.

module Internal where
a = 1
b = 2
secret = 42

module Public ( a, b ) where
import Internal ( a, b )

module Test where
import Internal ( secret )
test = assert $ isUltimateAnswer secret



On Wed, Feb 24, 2010 at 10:17 AM, Magnus Therning  wrote:
> How do people who like unit testing / property testing deal with export lists?
>
> I often find that I do want an export list to reduce clutter in the
> finished code, but for testing I'd like to expose everything in a
> module.  Is there a nice way to deal with this (using the C
> pre-processor would not qualify as "nice" ;-)?
> Maybe there's a switch that causes GHC to simply ignore the export
> list of a module and export everything?
>
> /M
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: concurrent-extra-0.2

2010-02-22 Thread Roel van Dijk
Hello,

We would like to announce an update of concurrent-extra [1].

Bug fixes:
 - A bug in RLock.acquire (thanks to Felipe Lessa).

New features:

 - Broadcast: Wake multiple threads by broadcasting a value. This
   is a generalisation of Event.
 - Thread: Threads extended with the ability to wait for their
   termination.
 - delay: Arbitrarily long thread delays.
 - timeout: Wait arbitrarily long for an IO computation to finish.

The lightweight thread wrapper was inspired by the threadmanager
package [2]. The main advantage of our implementation is that we
don't maintain an internal mapping from ThreadId to
ThreadStatus. Instead we rely on the forked thread to broadcast
its status to interested listeners. This should result in better
performance (no lookup required).

Every exported symbol is now documented.


Regards,
Roel & Bas van Dijk

[1] http://hackage.haskell.org/package/concurrent-extra-0.2
[2] http://hackage.haskell.org/package/threadmanager-0.1.3
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: concurrent-extra-0.1

2010-02-17 Thread Roel van Dijk
On Wed, Feb 17, 2010 at 3:27 PM, Felipe Lessa  wrote:
> In acquire (l. 111), if the lock was already acquired it goes by
>
>        | otherwise   → do putMVar mv mb
>                           Lock.acquire lock
>
> So it puts back the information about the owner of the RLock and
> waits for its release in the normal Lock.  And then... nothing?
> Shouldn't it need to put into mv information about itself?

Well spotted! In order to fix this we changed the structure of an
RLock a bit. The inner lock isn't contained in a Maybe anymore
but directly in the MVar. So now there is only 1 Lock associated
with an RLock. This makes reasoning about the control flow a bit
simpler.

We also added a test case which fails on the original code but
succeeds with the new version.

> In release (l. 142) Nothing is put into mv
>
>                        then do Lock.release lock
>                                putMVar mv Nothing

I'm not sure if that was a bug in the original. In the new
version we put the lock back inside the MVar.

Current version: http://hackage.haskell.org/package/concurrent-extra-0.1.0.1

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


[Haskell-cafe] ANN: concurrent-extra-0.1

2010-02-17 Thread Roel van Dijk
Hello,

We would like to announce the release of concurrent-extra [1]. A
library which offers a few extra synchronization primitives. These
primitives are found in the standard libraries of languages like Java
and Python, but not in Haskell.

Quick overview:

* Lock: Enforce exclusive access to a resource. Also known as a mutex
  or a binary semaphore.

* RLock: A lock which can be acquired multiple times by the same
  thread. Also known as a reentrant mutex.

* Event: Wake multiple threads by signaling an event. Includes both
  pessimistic and optimistic versions.

* ReadWriteLock: Multiple-reader, single-writer locks. Used to protect
  shared resources which may be concurrently read, but only
  sequentially written.

* ReadWriteVar: Concurrent read, sequential write variables.

Plug & Play:
  cabal install concurrent-extra
Darcs:
  darcs get http://code.haskell.org/~roelvandijk/code/concurrent-extra/

Thanks to Neil Brown and Simon Marlow for an initial review. Comments
are still more than welcome!

Regards,
Roel & Bas van Dijk


[1] http://hackage.haskell.org/package/concurrent-extra
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] RFC: concurrent-extra

2010-02-17 Thread Roel van Dijk
2010/2/17 Neil Brown :
> You don't need to do use ThreadId: MVar has an Eq instance, so you could
> make your Lock type derive an Eq instance, and then you can just compare the
> Locks to remove it after the timeout occurs (e.g. using delete to take it
> out of the list; it should be quite near the head of the list anyway).  In
> fact, you may as well make most of your types derive an Eq instance where
> possible, as this can be useful sometimes.

Now I am wondering why I didn't think of that before. It's an elegant
solution. Thanks!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: RFC: concurrent-extra

2010-02-17 Thread Roel van Dijk
2010/2/16 Simon Marlow :
> You might want to take a look at the concurrency part of the GHC test suite:
>
> http://darcs.haskell.org/testsuite/tests/ghc-regress/concurrent/should_run/
>
> Not that we've really solved the problem you're talking about, but you might
> get some ideas.

The method of testing appears to be similar to what I do now using
unit tests. But the contents of the tests are interesting. I'll see if
they are applicable to our primitives.

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


Re: [Haskell-cafe] RFC: concurrent-extra

2010-02-17 Thread Roel van Dijk
2010/2/16 Neil Brown :
> I had a look at the code for Event (both versions) and Lock (but not the
> others just yet) and it seemed fine.  If you do lots of calls to waitTimeout
> before a set you will accumulate old locks in the list, but that won't cause
> any error that I can see, so it would only be a problem in pathological
> cases.

I think I can fix the garbage locks on waitTimeout by tupling each
lock with the ThreadId of the thread that created it. When a timeout
occurs I can then simply remove the unnecessary lock from the list.
The extra overhead would be the construction of a tuple and acquiring
a ThreadId each time you wait for an event.

> I'm not sure there is a good way to test MVar algorithms.  One way to do it
> (which the Concurrent Haskell Debugger did online, IIRC:
> http://www.informatik.uni-kiel.de/~fhu/chd/) is to reimplement IO to explore
> different interleavings of the various MVar calls to look for deadlocks.  If
> you're testing STM, generally you can look to capture invariants of your
> transactions and check that they hold after each transaction (e.g. that if
> the state is Set, there shouldn't be any locks waiting with an event).

Interesting. It reminds me of Wouter Swierstra's recent paper "Beauty
in the Beast":
http://www.cs.nott.ac.uk/~txa/publ/beast.pdf

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


[Haskell-cafe] RFC: concurrent-extra

2010-02-16 Thread Roel van Dijk
Hello,

We wrote a small library (1) which offers a few extra synchronization
primitives. These primitives are found in the standard libraries of
languages like Java and Python, but not in Haskell.

Before releasing concurrent-extra on hackage, we would like some
comments on its name, design, implementation, documentation (2) and
general usefulness.

All primitives are implemented with MVars and IORefs, except for
Control.Concurrent.STM.Event.

There is a small test suite which tests some properties:

  cabal configure -ftest
  cabal build
  cabal test

The test suite still needs to be expanded a great deal. We found that
testing concurrent algorithms is really hard. Now we test things like
"this shouldn't deadlock" by checking if it doesn't take too long. But
that doesn't feel very formal. Is there a more principled approach to
testing concurrent algorithms in Haskell?

After writing our version of a read-write lock we noticed the package
rwlock (3) on hackage. But there is a difference: rwlock is
implemented with STM while our version is implemented entirely with
MVars.


Regards,
Roel & Bas van Dijk


1 - http://code.haskell.org/~roelvandijk/code/concurrent-extra/
2 - 
http://code.haskell.org/~roelvandijk/code/concurrent-extra/doc/html/concurrent-extra/index.html
3 - http://hackage.haskell.org/package/rwlock
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: ftdi-0.1

2010-01-25 Thread Roel van Dijk
Hello,

I just released a very early version of my 'ftdi' library [1]. It
is a small layer on top of the usb package [2] that enables you
to communicate with FTDI [3] devices.

Its design is based on the C-library libftdi [4], but it
implemented completely in Haskell. Most functionality is
untested. I only have access to an FT2232C chip, so testing other
chips is not possible at the moment. Furthermore, the only thing
I do with that chip is perform bulk reads and the
occasional small (1 byte) bulk write. The good news is that it is
quite good a bulk reads. It outperformed both libftdi-0.16 and
the official driver [5] by about 40% for my use case. Although to
be fair, both C libraries used the old libusb-0.1 library. This
library is ultimately linked with libusb-1.0.* which is a complete
rewrite.


To play with the library either
  cabal install ftdi
or
  darcs get http://code.haskell.org/~roelvandijk/code/ftdi


Regards,
Roel van Dijk


1 - http://hackage.haskell.org/package/ftdi
2 - http://ftdichip.com/
3 - http://hackage.haskell.org/package/usb
4 - http://www.intra2net.com/en/developer/libftdi/
5 - http://www.ftdichip.com/Drivers/D2XX.htm
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haddock - 'could not find link destination"

2010-01-22 Thread Roel van Dijk
On Thu, Jan 21, 2010 at 3:06 PM, Daniel Fischer
 wrote:
> But I find it easier to let Cabal deal with haddock, make a Cabal package,
>
> runghc ./Setup.hs configure --user --prefix=$HOME
> runghc ./Setup.hs haddock --hyperlink-source

If you use a Cabal package in conjunction with cabal-install it saves
you even more typing:

cabal configure
cabal haddock --hyperlink-source
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Conditional code for Haddock

2010-01-20 Thread Roel van Dijk
On Wed, Jan 20, 2010 at 12:57 PM, Sean Leather  wrote:
> I did some conditional Haddocking in EMGM. See, for example:
> http://hackage.haskell.org/packages/archive/emgm/0.3.1/doc/html/src/Generics-EMGM-Data-Bool.html

At first I didn't see what you did differently. Until I checked your
Setup.lhs. It does exactly what I want! Plus a few other things which
I am going to borrow (runtests hook, nolib flag and hpc program
coverage).

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


Re: [Haskell-cafe] Conditional code for Haddock

2010-01-20 Thread Roel van Dijk
> Doesn't haddock define __HADDOCK__ by itself?

That appears to be a common misconception. The discussion on this
ticket [1] indicates that haddock does *not* define __HADDOCK__. So I
can not rely on it being defined. Therefore I would like to define it
myself, but only in the case that haddock is being run on my code.


1 - http://trac.haskell.org/haddock/ticket/76
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Conditional code for Haddock

2010-01-20 Thread Roel van Dijk
I want to generate documentation for the following code snippet:

> import qualified Data.ByteString as BS ( ByteString, length )
>
> -- | Foo 'BS.empty' equals 0
> foo ∷ BS.ByteString → Int
> foo = BS.length

Because I do not explicitly import BS.empty haddock will not generate
a nice link.
I can fix it by adding:

> import qualified Data.ByteString as BS ( empty )

But now the compiler rightly warns me:

> Warning: Imported from `Data.ByteString' but not used: `BS.empty'

There is a ticket related to this problem [1], but I do not think making
haddock 'magically' find BS.empty is the right answer. What I would like to
do is:

> #ifdef __DOC__
> import qualified Data.ByteString as BS ( empty )
> #endif

Because I use additional symbols in my comments it feels natural to also
have special imports for them.

I know that cabal used to define the __HADDOCK__ macro. Is it possible to
manually define a preprocessor macro when haddock is run? Perhaps an
equivalent to ghc-options: haddock-options?

Ideally I want only have to add the following to my .cabal file:

> haddock-options: -D__DOC__

Regards,
Roel van Dijk


1 - http://trac.haskell.org/haddock/ticket/78
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: AlternativePrelude extension

2010-01-17 Thread Roel van Dijk
On Sun, Jan 17, 2010 at 12:27 PM, Ketil Malde  wrote:
> I think there might be justification for doing it multiple places.  The
> cabal file tells you what is required to build the package, the pragmas
> what is required to build each source file.
>
> Perhaps cabal should complain when source files use pragmas not
> declared in the cabal file, and perhaps also warn about options in the
> cabal file not used in any source file.

The "extensions" field in a cabal package description is a bit tricky.
The documentation states "A list of Haskell extensions used by every
module". This might give the impression that it documents the various
extensions used in a package. What it actually does is enable those
extensions for every module.

Duncan's comments on this ticket are enlightening:
http://hackage.haskell.org/trac/hackage/ticket/370

I think the idea of adding a new field "used-extensions" warrants a
separate ticket.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hackage strangeness

2010-01-15 Thread Roel van Dijk
> It's in the process of moving to a new (and hopefully more reliable) host.

That is good news. Nice work!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Hackage strangeness

2010-01-15 Thread Roel van Dijk
I wrote a small cronjob to update my hackage reverse-deps. When
checking if it worked I noticed that my hackage appears to be more
up-to-date than the real thing!

Compare the "What's new" of both:

Real hackage: http://hackage.haskell.org/packages/archive/recent.html
Play thing: 
http://bifunctor.homelinux.net/~roel/hackage/packages/archive/recent.html

At the time of writing this message the newest package on Hackage is
dated Tue Jan 12 16:24:18 UTC 2010.
The newest on my mirror is Thu Jan 14 20:07:04 UTC 2010.

I thought that possibly the recent.html page wasn't being built, but
when I follow an actual package, like vacuum-opengl the most recent
version on hackage is 0.0.2 while on my mirror it is 0.0.3.

Is this a case of data loss or something else?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language simplicity

2010-01-14 Thread Roel van Dijk
On Thu, Jan 14, 2010 at 12:47 PM, Colin Paul Adams
 wrote:
>>>>>> "Roel" == Roel van Dijk  writes:
>
>    Roel> I think it is time for an Obfuscated Haskell Contest :-)
>
> Are you allowed to use obsolete scripts for your identifiers? :-)

Sure, I'll consider bonus points if you write your program entirely in
cuneiform.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language simplicity

2010-01-14 Thread Roel van Dijk
> Thus speaketh the report (http://haskell.org/onlinereport/lexemes.html):
>
> symbol   ->      ascSymbol | uniSymbol
> ascSymbol       ->      ! | # | $ | % | & | * | + | . | / | < | = | > | ? | @
>        |       \ | ^ | | | - | ~
> uniSymbol        ->      any Unicode symbol or punctuation
>
> Punctuation characters are legitimate for operators.

Aha, didn't know that (or forgot it). Also kind of obvious when you
consider that '.' and ':' are punctuation characters.

I think it is time for an Obfuscated Haskell Contest :-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Language simplicity

2010-01-14 Thread Roel van Dijk
2010/1/14 Evan Laforge :
> Wow, that's kind of cute:
>
> {-# LANGUAGE UnicodeSyntax #-}
> (*) = (*)
> (/) = (/)
> 公式 高 中 低 = 高 * 中 * 低 / 整數
> 整數 = 123

That code snippet is also perfectly legal Haskell without the
UnicodeSyntax language extension. You use UnicodeSyntax if you want to
write code like this:

{-# LANGUAGE UnicodeSyntax, ScopedTypeVariables #-}
swap ∷ ∀ α β. (α, β) → (β, α)
swap = uncurry $ flip (,)

> Oddly, if I change the order of these definitions I get syntax
> errors.  Very mysterious.  Nice how it knows that * is a symbol,
> but I'm not sure how I'm supposed to name a type.

I was a bit surprised that you could use * as an operator since it is
a punctuation character. Maybe there are some corner cases with
fullwidth characters or with composition of characters.

> Unicode identifiers are fun but this is a good point.  The line has
> to be somewhere, so it might as well be in the historical position
> unless there are widely agreed on benefits to moving it.

I have already crossed that line:

http://hackage.haskell.org/package/base-unicode-symbols
http://hackage.haskell.org/package/containers-unicode-symbols

But I am aware that there is a point beyond which unicode symbols only
make your code harder to understand. So I try to be conservative in my
use of them. Still, there are a lot of useful and acceptable symbols
which are not part of the historic ASCII set: ∈, ≤, ∪, ∧, ¬, ∘ to name
a few.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hackage down

2010-01-06 Thread Roel van Dijk
I have downloaded the torrent with the hackage archive from 19 oktober
2009 and put it on my server. This means you can now download all the
packages contained in that archive (only the latest versions at that
date).

Happy hacking,
Roel

On Wed, Jan 6, 2010 at 11:57 AM, Roel van Dijk  wrote:
> If you are desperate for some hackage you can at least browse packages
> on my reverse dependencies thingie:
>
> http://bifunctor.homelinux.net/~roel/hackage/packages/hackage.html
>
> The last update was the 4th of january. But it doesn't have the actual
> packages, so it is probably not so useful in this case.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hackage down

2010-01-06 Thread Roel van Dijk
If you are desperate for some hackage you can at least browse packages
on my reverse dependencies thingie:

http://bifunctor.homelinux.net/~roel/hackage/packages/hackage.html

The last update was the 4th of january. But it doesn't have the actual
packages, so it is probably not so useful in this case.

On Wed, Jan 6, 2010 at 11:50 AM, Daniel Fischer
 wrote:
> Just a heads up, hackage is down, doesn't respond to ping even, cabal update
> says
>
> cabal: : resource vanished
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Mysterious factorial

2009-12-30 Thread Roel van Dijk
I can't offer much insight but could the answer lie in the Integer
type? I suspect that with a sufficiently large fixed Int type (2^14
bits?) the performance of the two functions would be almost equal.

Could it be that the second function delays the multiplication of
large numbers as long as possible? The divide-and-conquer approach?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: unicode-symbols-0.1.1

2009-12-10 Thread Roel van Dijk
2009/12/10 Richard O'Keefe :
> On Dec 10, 2009, at 2:58 AM, Roel van Dijk wrote:
>> I tried to be conservative with the choice of unicode symbols. I have
>> defined the division sign (÷) to be (/). But it could just as well be
>> defined as 'div'.
>
> No it couldn't.  One expects 3÷2 to be 1½, not 1.
> You will, for example, find this text on the web:
> "Mathematically, the division sign is equivalent to the forward slash.
> Thus, for example, 4 ÷ 5 = 4/5 = 0.8"
> This is actually historically backwards.  When I was a nipper,
> 1/6 meant "one and six" or "eighteen pence" or at least three
> loaves of good bread.  As far as I'm aware, the use of "/"
> instead of "÷" is a computerism introduced in the days of 6 bit
> character sets.

Ok, this makes me happy I choose (/) instead of 'div'.

>> Another choice that could lead to some discussion is the definition of
>> (⊂) to be 'Data.Set.isProperSubsetOf' and (⊆) to be
>> 'Data.Set.isSubsetOf'. An alternative choice would be to have (⊊) for
>> 'isProperSubsetOf' and (⊂) for 'isSubsetOf'.
>
> Mathematicians may use the plain horseshoe for either subset or
> proper subset, depending on the author.  But I've never ever seen
> anyone use the horseshoe with an equals bar for proper subset;
> that would really make no sense.

As James Hall pointed out there is actually a tiny slash trough the
equal bar underneath the horseshoe. The fact that this is hard to see
is another reason why I choose the first option.

> I suggest that you take the Z formal specification language as your
> guide (plain horseshoe is proper subset, horseshoe with equal bar is
> subset-or-equal).  If you don't like Z, try B:  same thing.

Yes, this is how I have defined things in the current version.

Thank you for your comments,
Roel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: usb-0.3

2009-12-09 Thread Roel van Dijk
On Wed, Dec 9, 2009 at 4:20 PM, stefan kersten  wrote:
> looks great, thanks! do you happen to have some example code for working with
> HID devices (mice, keyboards, etc.)?

The usb package does not support the various device classes directly.
You won't find a function like "isKeyPressed ∷ Device → KeyCode → IO
Bool". But you could write it based solely on functions from the usb
package. Enumerate the devices connected to your system, find your HID
device, open a handle (or enter a safe region), choose an interface
and an alternative and finally send some sort of control request
encoded in a ByteString. The actual bytes you need to send in order to
discover if some key on your USB keyboard is pressed is defined
somewhere in the USB HID device class specification.

If you really need that kind of functionality then you could create a
package "usb-hid" that offers an abstraction over the HID device
class. But if you just want to know if some key is pressed then a much
simpler solution would be to use a library like SDL or GLUT.

Keep in mind that all functions in the usb package run in *client
side*. To actually use a device (communication) you need the proper
permissions, which in practice implies super-user privileges.
Libraries like SDL interface with the kernel drivers and do not need
such permissions (correct me if I'm wrong).

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


[Haskell-cafe] ANNOUNCE: unicode-symbols-0.1.1

2009-12-09 Thread Roel van Dijk
Hello,

I would like the announce the release of my package unicode-symbols:
http://hackage.haskell.org/package/unicode-symbols

It offers alternative symbols for a number of common functions and
operators from the base and containers packages. When used in
combination with the language extension UnicodeSyntax you can write
really nice code. The only thing missing is a nice λ symbol.

The documentation on hackage should be pretty self explanatory. For
each symbol the documentation gives its exact definition. The source
code however, probably due to a bug in hscolour, is totally
unreadable. To view the sources simply download the package and use a
text editor.

I tried to be conservative with the choice of unicode symbols. I have
defined the division sign (÷) to be (/). But it could just as well be
defined as 'div'. I do not know what would be the logical choice.

Another choice that could lead to some discussion is the definition of
(⊂) to be 'Data.Set.isProperSubsetOf' and (⊆) to be
'Data.Set.isSubsetOf'. An alternative choice would be to have (⊊) for
'isProperSubsetOf' and (⊂) for 'isSubsetOf'. I choose the former
because it is more symmetrical with (<) and (≤).

This package was inspired by unicode-prelude from Péter Diviánszky:
http://hackage.haskell.org/package/unicode-prelude

Regards,
Roel van Dijk
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: ls-usb-0.1.0.2

2009-12-09 Thread Roel van Dijk
Hello everyone,

I have released a minor update of my ls-usb program:

http://hackage.haskell.org/package/ls-usb

This small utility lists USB devices connected to your system. It can
also show you the device descriptors, interface descriptors, vendor
and product identifiers and various other things. All in wonderful
colours of course.

The only major change is that it now depends on usb-0.3.*

Regards,
Roel van Dijk
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread Roel van Dijk
On Mon, Dec 7, 2009 at 10:24 AM, Lyndon Maydwell  wrote:
> I had heard that Hoogle actually compiled any type-signatures, where
> as Hayoo just did a text comparison.
>
> I'm not actually sure if this is true or not though.
>
> If it is, it would mean that "[q] -> [r] -> [(q,r)]" would return zip
> in Hoogle, but not Hayoo.
>
> Am I right about this?

You are right:

http://haskell.org/hoogle/?hoogle=[q]%20-%3E%20[r]%20-%3E%20[%28q%2Cr%29]

But Hayoo searches all of hackage while Hoogle also searches a lot,
but not all. If I'm searching for a function that is probably in base
or containers, I use hoogle. Otherwise I use hayoo. In short: They are
both very useful.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


  1   2   >