Re: [Haskell-cafe] Quick-check: how to generate arbitrary complex data?

2013-07-13 Thread martin
Am 07/12/2013 09:18 AM, schrieb Roman Cheplyaka:

 QuickCheck's Gen is a functor. So you can generate a list, and then
 use fmap to add a hash to it.
 
   instance Arbitrary HashedList where
 arbitrary = addHashToList $ arbitrary
 

This requires HashedList to be a new type, right? So far my code only
used type synonyms.

Does this mean I have to convert type synonyms into types in order to
use QuickCheck?

Does this mean I have to plan for QuickCheck when I design my types?



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


[Haskell-cafe] Quick-check: how to generate arbitrary complex data?

2013-07-12 Thread martin
Hello all,

I have a type (Mail) which consists of hash and a list, where the hash
keeps some redundant data of the list for faster access. I can add and
remove elements to values of this type using custom functions, called
push and pop.

Now I wanted to write some quick checks, but I have no clue how to
generate arbitrary values of this type. It will certainly no suffice to
write arbitrary instances for the underlying types (Int and Char),
because the hash and the list need to be synchronized.

Currently Mail it is only a type synonym. I suppose as a prerequisite
I need to wrap it into a type constructor. But then what?

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


[Haskell-cafe] GSoC - A Cabal Project

2013-04-30 Thread Martin Ruderer
Hi,

I am proposing a GSoC project on Cabal. It aims to open up the dependency solver
for debugging purposes.

The details are here: https://gist.github.com/mr-/7995081f89cff38e9443

I would really like to hear what you think about it.

Best regards, Martin

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


Re: [Haskell-cafe] What pattern is this (Something.T - IO a) in Sound.ALSA.Sequencer

2013-03-04 Thread Martin Drautzburg
On Sunday, 3. March 2013 21:11:21 Roman Cheplyaka wrote:

 Admittedly, programming with callbacks is not very pleasant. So we have
 an excellent alternative — the continuation monad transformer!
 
 This nested code
 
   something1 $ \x - do
   something2 $ \y - do
   something3 $ \z - do
 
 can be equivalently rewritten as this linear code
 
   import Control.Monad.Cont
 
   flip runContT return $ do
 x - ContT something1
 y - ContT something2
 z - ContT something3
 lift $ do
   ...

Mind-blowing. Thanks a lot. Before I dig into the continuation monad 
transformer, one more question (demonstrating my ignorance):

The initialization actually starts with

main = (do
  SndSeq.withDefault SndSeq.Block $ \h - do
  Client.setName (h :: SndSeq.T SndSeq.DuplexMode) Haskell-Melody
  Port.withSimple h out
 (Port.caps [Port.capRead, Port.capSubsRead, Port.capWrite])
 (Port.types [Port.typeMidiGeneric, Port.typeApplication]) $ \p - do


So there are some plain actions like Client.setName and Port.withSimple 
before it gets to the next do block. How would I write this in ContT style?


-- 
Martin

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


[Haskell-cafe] What pattern is this (Something.T - IO a) in Sound.ALSA.Sequencer

2013-03-03 Thread Martin Drautzburg
Hello all,

this was previously posted on Haskell Beginners, but only partially answered.

In Sound.ALSA.Sequencer, there are a number of functions which together set up 
a midi environement (client, port, queue). They all have a type, where the 
last argument has a type like:

(something.T - IO a)

i.e.

*Main :t SndSeq.withDefault
SndSeq.withDefault
  :: SndSeq.OpenMode mode =
 SndSeq.BlockMode - (SndSeq.T mode - IO a) - IO a

*Main :t Port.withSimple
Port.withSimple
  :: SndSeq.T mode
 - String - Port.Cap - Port.Type - (Port.T - IO a) - IO a

*Main :t Queue.with
Queue.with :: SndSeq.T mode - (Queue.T - IO a) - IO a

There is example code, where a full setup is created by a number of nested 
do blocks. The repeating pattern there is:

something1 $ \x - do
something2 $ \y - do
something3 $ \z - do


What is this all about? I particularly would like to understand, when this 
parttern is needed and what determines the the number of nested do blocks. 

-- 
Martin

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


Re: [Haskell-cafe] Parser left recursion

2013-02-26 Thread Martin Drautzburg
On Sunday, 24. February 2013 16:04:11 Tillmann Rendel wrote:

 Both approaches are essentially equivalent, of course: Before
 considering the very same nonterminal again, we should have consumed at
 least one token.

I see. Thanks

So for the laymen:

expr ::= expr + expr

is a problem, because the parser considers expr again without having consumed 
any input.

expr ::= literal pluses
pluses ::= many (+ expr)

is not a problem, because by the time the parser gets to the rightmost expr is 
has consumes at least one +.

Instead of literal we can put anything which promises not to be left-recursive

expr ::= exprNonLr + expr
exprNonLr := ...

As exprNonLr gets more complicated, we may end up with a whole set of nonLr 
parsers.

I wonder if I can enforce the nonNr property somehow, i.e. enforce the rule 
will not consider the same nonterminal again without having consumed any 
input.
 


-- 
Martin

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


Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Martin Drautzburg
On Wednesday, 20. February 2013 09:59:47 Tillmann Rendel wrote:

 
 So the grammar is:
 
Exp ::= Int
 
 |  Exp + Exp
  
  My naive parser enters an infinite recursion, when I try to parse 1+2.
  I do understand why:
  
  hmm, this expression could be a plus, but then it must start with an
  expression, lets check.
  
  and it tries to parse expression again and again considers Plus.
 
 Indeed.
 
  Twan van Laarhoven told me that:
  Left-recursion is always a problem for recursive-descend parsers.
 
 Note that the left recursion is already visible in the grammar above, no
 need to convert to parser combinators. The problem is that the
 nonterminal Exp occurs at the left of a rule for itself.

Just a silly quick question: why isn't right-recursion a similar problem?

-- 
Martin

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


Re: [Haskell-cafe] Parser left recursion

2013-02-20 Thread Martin Drautzburg
Thank you very much. 

To clarify: I am not in need of a parser, I just wanted to understand why left 
recursion is an issue (that was easy) and what techniques help to circumvent 
the problem. So your answer was spot-on (though I haven't implemented it yet)

On Wednesday, 20. February 2013 09:59:47 Tillmann Rendel wrote:
 Hi,
 
 Martin Drautzburg wrote:
  As an exercise I am writing a parser roughly following the expamples in
  Graham Hutton's book. The language contains things like:
  
  data Exp = Lit Int -- literal integer
  
| Plus Exp Exp
 
 So the grammar is:
 
Exp ::= Int
 
 |  Exp + Exp
  
  My naive parser enters an infinite recursion, when I try to parse 1+2.
  I do understand why:
  
  hmm, this expression could be a plus, but then it must start with an
  expression, lets check.
  
  and it tries to parse expression again and again considers Plus.
 
 Indeed.
 
  Twan van Laarhoven told me that:
  Left-recursion is always a problem for recursive-descend parsers.
 
 Note that the left recursion is already visible in the grammar above, no
 need to convert to parser combinators. The problem is that the
 nonterminal Exp occurs at the left of a rule for itself.
 
 One way to fix this problem is to refactor the grammar in order to avoid
 left recursion. So let's distinguish expressions that can start with
 expressions and expressions that cannot start with expressions:
 
Exp-norec ::= Int
Exp-rec   ::= Exp-norec
 
   |  Exp-norec + Exp-rec
 
 Note that Exp-rec describes a list of Exp-norec with + in-between, so
 you can implement it with the combinator many.
 
 Now if you want to add a rule like
 
Exp ::= ( Exp )
 
 you need to figure out whether to add it to Exp-norec or Exp-rec. Since
 the new rule is not left recursive, you can add it to Exp-norec:
 
Exp-norec ::= Int
 
   |  ( Exp-rec )
 
Exp-rec   ::= Exp-norec
 
   |  Exp-norec + Exp-rec
 
 If you implement this grammar with parser combinators, you should be
 able to parse (1+2)+3 just fine.
 
Tillmann
 
 PS. Try adding multiplication to your grammar. You will need a similar
 trick to get the priorities right.

-- 
Martin

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


[Haskell-cafe] Parser left recursion

2013-02-19 Thread Martin Drautzburg
Hello all,

this was previously asked on haskell-beginners, but only partially answered.

As an exercise I am writing a parser roughly following the expamples in Graham 
Hutton's book. The language contains things like:

data Exp = Lit Int -- literal integer
 | Plus Exp Exp

My naive parser enters an infinite recursion, when I try to parse 1+2. I do 
understand why:

hmm, this expression could be a plus, but then it must start with an 
expression, lets check. 

and it tries to parse expression again and again considers Plus.
  
Twan van Laarhoven told me that:

 Left-recursion is always a problem for recursive-descend parsers.

and suggested to do something like:

 parseExp = do
   lit - parseLit
   pluses - many (parsePlusToken * parseLit)
   return (combinePlusesWithLit lit pluses)

 combinePlusesWithLit = foldr Plus -- or foldl

This indeed does the trick, but only when the first token is a Lit (literal 
integer). 

I then added the possibility to optionally put things in parentheses. But then  
I cannot parse (1+2)+3. The original code fails, because (1+2) is not a 
Lit and when I allow an expression as the first argument to + I get infinite 
recursion again.

I am generally confused, that saying a plus expression is an integer followed 
by many plus somethings is not what the language says. So this requires a 
lot of paying attention to get right. I'd much rather say a plus expression 
is two expressions with a '+' in between.

I do know for sure, that it is possible to parse (1+2)+3 (ghci does it just 
fine). But I seem to be missing a trick.

Can anyone shed some light on this?

-- 
Martin

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


[Haskell-cafe] Text.JSON and utf8

2013-02-11 Thread Martin Hilbig

hi,

tl;dr: i propose this patch to Text/JSON/String.hs and would like to
know why it is needed:

@@ -375,7 +375,7 @@
   where
   go s1 =
 case s1 of
-  (x   :xs) | x  '\x20' || x  '\x7e' - '\\' : encControl x (go xs)
+  (x   :xs) | x  '\x20' - '\\' : encControl x (go xs)
   ('' :xs)  - '\\' : ''  : go xs
   ('\\':xs)  - '\\' : '\\' : go xs
   (x   :xs)  - x: go xs


i recently stumbled upon CouchDB telling me i'm sending invalid json.

i basically read lines from a utf8 file with german umlauts and send
them to CouchDB using Text.JSON and Database.CouchDB.

  $ file lines.txt
  lines.txt: UTF-8 Unicode text

lets take 'ö' as an example. i use LANG=de_DE.utf8

ghci tells

 'ö'
'\246'

 putChar '\246'
ö

 putChar 'ö'
ö

 :m + Text.JSON Database.CouchDB
 runCouchDB' $ newNamedDoc (db foo) (doc bar) (showJSON $ 
toJSObject [(test,ö)])

*** Exception: HTTP/1.1 400 Bad Request
Server: CouchDB/1.2.1 (Erlang OTP/R15B03)
Date: Mon, 11 Feb 2013 13:24:49 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 48
Cache-Control: must-revalidate

couchdb log says:

  Invalid JSON: {{error,{10,lexical error: invalid bytes in UTF8 
string.\n}},{\test\:\F6\}}


this is indeed hex ö:

 :m + Numeric
 putChar $ toEnum $ fst $ head $ readHex f6
ö

if i apply the above patch and reinstall JSON and CouchDB the doc
creation works:

 runCouchDB' $ newNamedDoc (db db) (doc foo) (showJSON $ 
toJSObject [(test, ö)])

Right someRev

but i dont get back the ö i expected:

 Just (_,_,x) -runCouchDB' $ getDoc (db foo) (doc bar) :: IO 
(Maybe (Doc,Rev,JSObject String))

 let Ok y = valFromObj test = readJSON x :: Result String
 y
\195\188
 putStrLn y
ü

apperently with curl everything works fine:

$ curl localhost:5984/db/foo -XPUT -d '{test: ö}'
{ok:true,id:foo,rev:someOtherRev}
$ curl localhost:5984/db/foo
{_id:bars,_rev:someOtherRev,test:ö}

so how can i get my precious ö back? what am i doing wrong or does 
Text.JSON need another patch?


another question: why does encControl in Text/JSON/String.hs handle the
cases x  '\x100' and x  '\x1000' even though they can never be
reached with the old predicate in encJSString (x  '\x20')

finally: is '\x7e' the right literal for the job?

thanks for reading

have fun
martin

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


[Haskell-cafe] Hint's setImports usage

2012-12-20 Thread Martin Hilbig

hi,

how to use Language.Haskell.Interpreter.setImports?

i use it like:

  setImports [My.Module]

so that my interpreted modules don't need to:

  import My.Module

But i still get:

  Not in scope: data constructor `MyType'

What am i doing wrong?

Thanks in advance.

have fun
martin

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


Re: [Haskell-cafe] Hint's setImports usage

2012-12-20 Thread Martin Hilbig

ok, i figured it out so far (just after hitting send ;)

'setImports' makes 'My.Modules' stuff available to the interpreted code 
itself (a call to some of my wrapper functions) but not to my module 
My.Interpreted.Module where which i use via


  setTopLevelModule [My.Interpreted.Module]

So i guess there is no way to add the import to the 
'My.Interpreted.Module' for convenience.


Sorry for the noise.

have fun
martin

On 21.12.2012 00:35, Martin Hilbig wrote:

hi,

how to use Language.Haskell.Interpreter.setImports?

i use it like:

   setImports [My.Module]

so that my interpreted modules don't need to:

   import My.Module

But i still get:

   Not in scope: data constructor `MyType'

What am i doing wrong?

Thanks in advance.

have fun
martin

___
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] Hint's setImports usage

2012-12-20 Thread Martin Hilbig

oh that's neat!

but what to do if MyPrelude is provided by some package?

i get this error:

  module `MyPrelude' is a package module

and neither

  set [languageExtensions := [PackageImports]]

nor

  {-# LANGUAGE PackageImports #-}

helps.

have fun
martin

On 21.12.2012 00:55, Michael Sloan wrote:

Hello!

Try doing this first:

   loadModules [My.Module]

You may also need to set the searchPath - it defaults to the current
director.  Another good function to know about is setTopLevelModules,
which is just like using :load in ghci - it imports everything in the
module, including its imports.  So, I often do:

   loadModules [MyPrelude]
   setTopLevelModules [MyPrelude]

And stick all of the things that I want to be in scope into MyPrelude.hs.

-Michael


On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig li...@mhilbig.de
mailto:li...@mhilbig.de wrote:

hi,

how to use Language.Haskell.Interpreter.__setImports?

i use it like:

   setImports [My.Module]

so that my interpreted modules don't need to:

   import My.Module

But i still get:

   Not in scope: data constructor `MyType'

What am i doing wrong?

Thanks in advance.

have fun
martin

_
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org
http://www.haskell.org/__mailman/listinfo/haskell-cafe
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] Hint's setImports usage

2012-12-20 Thread Martin Hilbig

On 21.12.2012 01:23, Michael Sloan wrote:

Yeah, I've run into that too..

It does seem like there ought to be a better way, but in order to get
around that, I just define the imports (or generate) MyPrelude.hs in
the current directory.


what do you do with the file then? neither loadModules, setImports,
setTopLevelModules helped me :/

have fun
martin


That file can just consist of import
OtherPackage.MyPrelude.

-Michael


On Thu, Dec 20, 2012 at 4:12 PM, Martin Hilbig li...@mhilbig.de
mailto:li...@mhilbig.de wrote:

oh that's neat!

but what to do if MyPrelude is provided by some package?

i get this error:

   module `MyPrelude' is a package module

and neither

   set [languageExtensions := [PackageImports]]

nor

   {-# LANGUAGE PackageImports #-}

helps.

have fun
martin


On 21.12.2012 00:55, Michael Sloan wrote:

Hello!

Try doing this first:

loadModules [My.Module]

You may also need to set the searchPath - it defaults to the
current
director.  Another good function to know about is
setTopLevelModules,
which is just like using :load in ghci - it imports everything
in the
module, including its imports.  So, I often do:

loadModules [MyPrelude]
setTopLevelModules [MyPrelude]

And stick all of the things that I want to be in scope into
MyPrelude.hs.

-Michael


On Thu, Dec 20, 2012 at 3:35 PM, Martin Hilbig li...@mhilbig.de
mailto:li...@mhilbig.de
mailto:li...@mhilbig.de mailto:li...@mhilbig.de wrote:

 hi,

 how to use Language.Haskell.Interpreter.setImports?


 i use it like:

setImports [My.Module]

 so that my interpreted modules don't need to:

import My.Module

 But i still get:

Not in scope: data constructor `MyType'

 What am i doing wrong?

 Thanks in advance.

 have fun
 martin

 ___
 Haskell-Cafe mailing list
Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org
mailto:Haskell-Cafe@haskell.__org
mailto:Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
http://www.haskell.org/__mailman/listinfo/haskell-cafe
 http://www.haskell.org/__mailman/listinfo/haskell-cafe
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] Can Haskell outperform C++?

2012-05-21 Thread Sam Martin

 Yes, this seems to be a separate disease.  Not just using low-level langs, 
 per se, 
 but using them for *everything*.  I have worked at places in industry where 
 teams 
 automatically use C++ for everything.  For example, they use it for building 
 all 
 complete GUI applications, which surprises me a little bit.  I would have 
 thought 
 in recent years that almost everyone was using *something* else (Java,Python, 
 whatever) to do much of the performance-non-critical portions of their 
 application logic.

I think disease might be overstating this somewhat :) In defence of using C++ 
for everything: Interfacing different languages is not exactly trivial, and in 
some cases, impossible.

If you are writing a program or system that has significant performance 
requirements, you might just be better off doing the whole thing in C/C++ and 
living with the annoyance of doing GUIs, or whatever, in C++. The overhead of 
pulling in another language may simply outweigh the convenience. 

In addition, it's pretty much impossible for me to use Haskell to write 
portions (or all of) a game that would include a console version. This is 
largely for build system and platform support issues. Doing everything in C++ 
is nearly the only option here.

This situation could be improved though, by making it far easier to embed 
Haskell within C/C++. It's not difficult by design, but there are large 
engineering obstacles in the way, and it's hard to see where the effort to 
remove these could come from. But then it would be more plausible to argue that 
people are missing out by not using a mix of C++ and Haskell.

Cheers,
Sam


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


[Haskell-cafe] How to use Jacobian from levmar lib?

2012-05-15 Thread Martin Hilbig

hi,

i'm using the nice levmar package like this [1].

why is there such a big difference in 'infNorm2E' between using/not 
using the Jacobian?


thanks in advance
martin hilbig

[1]: http://hpaste.org/68537

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


Re: [Haskell-cafe] Data.Array.Accelerate initialization timings

2012-02-22 Thread Martin Dybdal
On 20 February 2012 16:39, Paul Sujkov psuj...@gmail.com wrote:
 Ah, it seems that I see now what's going wrong way. I'm not using the 'run'
 function from the CUDA backend, and so by default I guess the code is
 interpreted (the test backend used for semantics check). However, it's not
 perfectly clear how to use CUDA backend explicitly.

Neither the interpreter or the CUDA code are used in your example.
Everything in Data.Array.Accelerate are front-end stuff, your arrays
are allocated on the host, so it is here there is an inefficiency.

The use method inserts a statement in the syntax tree generated by
the front-end, which the back-end can use as a hint to transfer that
array to the GPU, while compiling the rest of the program into CUDA
code. The Data.Array.Accelerate.CUDA.run function is the one that
actually moves the arrays to the GPU.

I haven't tried executing your code and I'm not sure why the front-end
is that slow.

-- 
Martin Dybdal

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


[Haskell-cafe] implementing a text editor swap file

2012-01-17 Thread Martin DeMello
I'm writing a gtk2hs-based text editor, and would like to implement
continuous (swap-file based) autosave the way vim and emacs do it. Any
suggestions for how to implement this in a cross-platform manner?

Also, is there a library that returns standard config file locations
on a per-platform basis?

martin

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


Re: [Haskell-cafe] implementing a text editor swap file

2012-01-17 Thread Martin DeMello
Says posix only. But googling for it brought up System.IO.MMap, which
does seem to be cross-platform.

martin

On Tue, Jan 17, 2012 at 5:46 PM, Matthew Farkas-Dyck
strake...@gmail.com wrote:
 http://hackage.haskell.org/package/bytestring-mmap


 On 17/01/2012, Martin DeMello martindeme...@gmail.com wrote:
 I'm writing a gtk2hs-based text editor, and would like to implement
 continuous (swap-file based) autosave the way vim and emacs do it. Any
 suggestions for how to implement this in a cross-platform manner?

 Also, is there a library that returns standard config file locations
 on a per-platform basis?

 martin

 ___
 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] implementing a text editor swap file

2012-01-17 Thread Martin DeMello
On Tue, Jan 17, 2012 at 5:49 PM, Erik de Castro Lopo
mle...@mega-nerd.com wrote:
 Matthew Farkas-Dyck wrote:

 http://hackage.haskell.org/package/bytestring-mmap

 Since he's editing text, its a pity there isn't a text-mmap
 package :-).

Further question - my internal data representation is a vector of
strings (it's a line-based editor). Is there a more efficient strategy
to keep an mmap buffer in sync with the vector than simply allocating
some large fixed size per line?

martin

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


Re: [Haskell-cafe] implementing a text editor swap file

2012-01-17 Thread Martin DeMello
On Tue, Jan 17, 2012 at 6:24 PM, Erik de Castro Lopo
mle...@mega-nerd.com wrote:
 Martin DeMello wrote:

 Further question - my internal data representation is a vector of
 strings (it's a line-based editor).

 String or ByteString or Text?

 If its either of the first two, I think you should definitely look at
 Text.

Just plain String, mostly because it's what Gtk.Entry works with. I'll
take a look at Text.

martin

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


[Haskell-cafe] typeclass and functional dependency problem

2012-01-10 Thread Martin DeMello
I'm writing a Gtk2hs app, and I have several custom widgets that are
composite objects represented by records, one field of which is a
container widget. I am trying to write a replacement for gtk2hs's
boxPackStart

boxPackStart :: (BoxClass self, WidgetClass child) = self - child -
Packing - Int - IO ()

that will accept either a gtk widget or one of my custom widgets to
place in the box, and do the right thing. Here's my attempt at it;
what I want to know is why the commented out bit didn't work and I had
to individually add instances of widgets instead:

-
-- packable objects
class WidgetClass w = Packable a w | a - w where
widgetOf :: a - w

--instance WidgetClass w = Packable w w where
--widgetOf = id

instance Packable Button Button where
widgetOf = id

instance Packable Entry Entry where
widgetOf = id

instance Packable Label Label where
widgetOf = id

instance Packable Notebook Notebook where
widgetOf = id

instance Packable HBox HBox where
widgetOf = id

-- add widget to box
boxPackS :: (BoxClass b, WidgetClass w, Packable a w) = b - a -
Packing - Int - IO ()
boxPackS box child p i = boxPackStart box (widgetOf child) p i

-

If I try to use

instance WidgetClass w = Packable w w where
widgetOf = id

instead, I get the compilation error

Editor.hs:23:10:
Functional dependencies conflict between instance declarations:
  instance Packable PairBox VBox -- Defined at Editor.hs:23:10-30
  instance WidgetClass w = Packable w w
-- Defined at GuiUtils.hs:13:10-38

even though PairBox does not belong to WidgetClass.

martin

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


[Haskell-cafe] Twidge using hashtags

2011-12-30 Thread Martin de Bruin
Hello!

fairly new to twidge. Got it installed and have it setting status etc etc .
I'm maintaing a local website supporting the eating of a seasonal pastry in
a highly competitve fashion. A race of sorts. The contestant eating the
most from january first to good friday wins. To keep the eating as
transparent as possible one must report each pastry on the web. However, I
feel this is not very 2012.

I'm thinking about going about the new version allowing reporting to be
done via twitter and picking it up with Twidge. To keep everything as much
in the open as possible I'd like to have all contestants twittering the
eating of a pastry mentioning the official twitter account of the website
and throw in a hashtag like #report and then some comment.

I'll then read the feed periodically via cron on the server and update the
highscore database.

Am I making sense? The longer I typed the above the more I started thinkng
about just doing something in PHP...

Any thoughts?

Cheers

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


Re: [Haskell-cafe] How hard is it to start a web startup using Haskell?

2011-12-27 Thread Martin DeMello
A good compromise might be opa (not used it myself, but I've been
reading up on it as a possible candidate for any personal web projects
I might want to do). It is not haskell, but it is ML-derived, and
specifically for webapps. It has some example apps available, though
nothing near the volume of apps rails or django would have.

martin

On Mon, Dec 26, 2011 at 6:17 PM, Haisheng Wu fre...@gmail.com wrote:

 Turns out that those guys doing start-up with Haskell are already expert at
 Haskell.
 Hence choosing Haskell is more straightforward.

 I'm thinking of using Haskell since it looks cool and beautiful.
 However I have little experience and will move slowly at certain begging
 period.
 This sounds not good to a startup company.

 Comparing with Django in Python, Rails in Ruby, yesod and snap looks not
 that mature.
 Also, for instance, I'd like to build up a CRM application company, I
 could leverage some open source projects in other languages.  In Haskell, we
 need to build from scratch basically.

 Appreciate your suggestions/comments.

 -Simon



 On Wed, Dec 21, 2011 at 2:30 AM, David Pollak
 feeder.of.the.be...@gmail.com wrote:



 On Mon, Dec 19, 2011 at 2:36 PM, Yves Parès limestr...@gmail.com wrote:

  Haskell is a mature platform that provides lots of goodies that I might
  otherwise have to write (like the goodies I wrote in Lift including an
  Actors library)

 I don't get it: Actors are at the core of Scala concurrency model,


 Actors as implemented in the Scala distribution were (and probably still
 are) horrid.  They have poor performance, memory retention issues, and an
 overall poor design.  When Lift relied on Scala's Actors, a Lift-comet site
 needed to be restarted every few weeks because of pent-up memory issues.  On
 the other hand, with Lift Actors, http://demo.liftweb.net has been running
 since July 7th.


 and are expanded for distributed programming through Akka for instance.


 Actually, no.  Scala's Actors are not expanded by Akka (although Akka
 Actors may replace the existing Actor implementation in the Scala library).
  Akka is yet another replacement for Scala's Actor library and Akka's
 distributed capabilities are weak and brittle.  Also, Lift's Actor library
 and Martin Odersky's flames about it paved the way for Akka because I took
 the heat that might have driven Jonas out of the Scala community when Akka
 was a small project.


 To me it'd be the other way around: you'd have to develop Actors in
 Haskell, don't you?


 I've come to understand that Actors are a weak concurrency/distribution
 paradigm.  Anything that has a type signature Any = Unit is not composable
 and will lead to the same kinds of issues that we're looking for the
 compiler in Haskell to help us with (put another way, if you like Smalltalk
 and Ruby, then Actors seem pretty cool.)

 On the other hand, many of Haskell's libraries (STM, Iteratees, etc.) have
 a much more composable set of concurrency primitives.


 Or maybe you don't mean the same thing by 'Actor'?


 2011/12/19 David Pollak feeder.of.the.be...@gmail.com

 On Mon, Dec 19, 2011 at 2:04 AM, Ivan Perez
 ivanperezdoming...@gmail.com wrote:

 I'm actually trying to make a list of companies and people using
 Haskell
 for for-profit real world software development.

 I'd like to know the names of those startups, if possible.


 I am building http://visi.pro on Haskell.  I am doing it for a number of
 reasons:

 Haskell is a mature platform that provides lots of goodies that I might
 otherwise have to write (like the goodies I wrote in Lift including an
 Actors library)
 Haskell allows a lot of nice things that make building a language and
 associated tools easier (like laziness)
 Haskell is a filter for team members. Just like Foursquare uses Scala as
 a filter for candidates in recruiting, I'm using Haskell as a filter... if
 you have some good Haskell open source code, it's a way to indicate to me
 that you're a strong developer.




 -- Ivan

 On 18 December 2011 18:42, Michael Snoyman mich...@snoyman.com wrote:
  On Sun, Dec 18, 2011 at 6:57 PM, Gracjan Polak
  gracjanpo...@gmail.com wrote:
 
  Hi all,
 
  The question 'How hard is it to start a technical startup with
  Haskell?'
  happened a couple of times on this list. Sometimes it was in the
  form 'How hard
  is to find Haskell programmers?' or 'Are there any Haskell jobs?'.
 
  I'd like to provide one data point as an answer:
 
 
  http://www.reddit.com/r/haskell/comments/ngbbp/haskell_only_esigning_startup_closes_second_angel/
 
  Full disclosure: I'm one of two that founded this startup.
 
  How are others doing businesses using Haskell doing these days?
 
  I don't run a startup myself, but I know of at least three startups
  using Haskell for web development (through Yesod), and my company is
  basing its new web products on Yesod as well. I think there are
  plenty
  of highly qualified Haskell programmers out there, especially if
  you're willing to let someone work

Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2011-12-20 Thread Martin DeMello
On Tue, Dec 20, 2011 at 3:10 PM, Chris Wong
chrisyco+haskell-c...@gmail.com wrote:

 Why not expand it even further?

 class Monoid m where
    (•) :: m - m - m
    (∅) :: m

 (∈) :: (Foldable t, Eq a) = a - t a - Bool

 (∘) :: (b - c) - (a - b) - (a - c)

 (∧) :: Bool - Bool - Bool

 etc.

 We can write a whole Haskell library full of these aliases --
 syntactic-heroin perhaps? ;)

Why would you go that far and still not have → ? (:

martin

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


Re: [Haskell-cafe] indentation blues

2011-12-13 Thread Martin DeMello
On Tue, Dec 13, 2011 at 2:34 AM, Adrien Haxaire adr...@haxaire.org wrote:

 Regarding, your question whether this is worth switching from vim to
 emacs. I've been using both editors for some years and I very much
 doubt, that you wouldn't spend much time learning emacs. If you are
 comfortable with vim, stick with it, unless you are interested in
 Emacs or one of its really great modes: org and auctex/reftex.

 Regarding, the vi emulations, I'd say they are nice should you ever
 be forced to use emacs for some time. But I don't recommend them, I've
 tried them all. They are not the real thing. Most of them are vi not
 vim emulators. And they always feel like second class citizens in
 emacs land. YMMW.

 Thanks for your feedback. I've never tried vim so I couldn't tell precisely.

 I thought the emulations were nice enough to save time learning emacs. If
 they are second class citizens, I agree it would be wiser to stick with vim
 then.

yeah, i was assuming the emulations were nice enough to support my vim
habits too. if they aren't, not even a good haskell mode would make
emacs comfortable enough to use given my years of ingrained vim.

martin

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


[Haskell-cafe] indentation blues

2011-12-12 Thread Martin DeMello
The vim autoindent for haskell is really bad :( Is there a better
indent.hs file floating around somewhere? Alternatively, is the emacs
haskell mode better enough that it's worth my time learning my way
around emacs and evil?

martin

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


[Haskell-cafe] minor refactoring problem

2011-11-29 Thread Martin DeMello
I have the following functions:

makePair :: (String, String) - IO PairBox

parseFile :: String - [(String, String)]

importFile :: Editor - String - IO ()
importFile ed path = do
  s - readFile path
  ps - mapM (\x - makePair (x, )) (lines s)
  es - return $ V.fromList ps
  writeIORef ed es

loadFile :: Editor - String - IO ()
loadFile ed path = do
  s - readFile path
  ps - mapM makePair (parseFile s)
  es - return $ V.fromList ps
  writeIORef ed es

The problem is that loadFile and importFile are so similar it seems a
shame not to combine them somehow, but anything I can think of doing
leaves the code looking more rather than less messy. Any nice ideas?

martin

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


Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Martin DeMello
On Tue, Nov 29, 2011 at 12:35 AM, Stefan Holdermans
ste...@vectorfabrics.com wrote:

 Have you considered abstracting over the bits in which importFile and 
 loadFile differ? For example:

  processFile :: (String - IO [PairBox]) - Editor - String - IO ()
  processFile f ed path = do
    s - readFile path
    ps - f s
    es - return $ V.fromList ps
    writeIORef ed es

  importFile = processFile (mapM (\x - makePair (x, )) . lines)
  loadFile   = processFile (mapM makePair . parseFile)

This was what I had tried; my issue was that the resulting code looked
harder rather than easier to read, so it felt more like golfing than
refactoring.

 Or, alternatively:

  processFile :: (String - [a]) - (a - IO PairBox) - Editor - String - 
 IO ()
  processFile f g ed path = do
    s - readFile path
    ps - mapM g (f s)
    es - return $ V.fromList ps
    writeIORef ed es

  importFile = processFile lines (\x - makePair (x, ))
  loadFile   = processFile parseFile makePair

This does look significantly nicer - I hadn't thought of splitting it
into two functions rather than one, but it makes the code look much
less cluttered. (The trick with `flip` is tempting, but again at the
cost of having to peer rather too closely at the implementation of
processFile when reading the code). Thanks!

martin

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


Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Martin DeMello
On Tue, Nov 29, 2011 at 12:55 AM, Stefan Holdermans
ste...@vectorfabrics.com wrote:
 Martin,

 (The trick with `flip` is tempting, but again at the
 cost of having to peer rather too closely at the implementation of
 processFile when reading the code).

 That trick is of course completely orthogonal. One could just as well write:

  processFile :: (String - [a]) - (a - (String, String)) - Editor - 
 String - IO ()
  processFile f g ed path = do
    s - readFile path
    ps - mapM (makePair . g) (f s)
    es - return $ V.fromList ps
    writeIORef ed es

  importFile = processFile lines (\x - (x, ))
  loadFile   = processFile parseFile id

good point :) though i ended up writing a new function parseImport =
(map $ \x - (x, )) . lines, so that i could drop the second
argument and have everything look nice and neat.

martin

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


Re: [Haskell-cafe] ANN: OpenCL 1.0.1.3 package

2011-10-21 Thread Martin Dybdal
On 17 October 2011 22:47, Judah Jacobson judah.jacob...@gmail.com wrote:
 On Mon, Oct 17, 2011 at 2:56 AM, Luis Cabellos cabel...@ifca.unican.es 
 wrote:

 Other issues to solve,
 How to compile in hackage server to generate documentation online?
 opencl.h isn't in the server so I getting errors.


 In my experience, the nicest way to work around this problem is to
 just generate the documentation manually and host it somewhere off of
 Hackage.  http://community.haskell.org/admin/ is a decent place to
 host something like this; you end up with a URL
 http://projects.haskell.org/yourproject which you can link to from the
 .cabal file description.

That is an acceptable solution. The documentation of hopencl is now
hosted at http://projects.haskell.org/hopencl/

Thanks for the pointer.

-- 
Martin Dybdal

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


Re: [Haskell-cafe] ANN: OpenCL 1.0.1.3 package

2011-10-19 Thread Martin Dybdal
On 17 October 2011 11:56, Luis Cabellos cabel...@ifca.unican.es wrote:
 My own library is available at https://github.com/HIPERFIT/hopencl and
 will be released on hackage very soon (next week probably). Please
 take a look at it. It is currently tested on x86_64 Linux with both
 the AMD x86/x86_64 bindings and NVIDIAs CUDA bindings. They will
 probably not work on Windows in their present state, and I don't have
 access to a Windows machine to test it on.

 As Jason Dagit say, I put the stdcall call convention option in OpenCL
 for windows:
 https://github.com/zhensydow/opencl/blob/master/OpenCL.cabal

Thanks. I have implemented the same thing in my library now. I would
be happy if someone could test that it compiles, and the unit tests
runs on a Windows installation.

-- 
Martin Dybdal

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


Re: [Haskell-cafe] ANN: OpenCL 1.0.1.3 package

2011-10-17 Thread Martin Dybdal
On 17 October 2011 11:56, Luis Cabellos cabel...@ifca.unican.es wrote:
 On Thu, Oct 13, 2011 at 9:13 PM, Martin Dybdal dyb...@dybber.dk wrote:
 My own library is available at https://github.com/HIPERFIT/hopencl and
 will be released on hackage very soon (next week probably). Please
 take a look at it. It is currently tested on x86_64 Linux with both
 the AMD x86/x86_64 bindings and NVIDIAs CUDA bindings. They will
 probably not work on Windows in their present state, and I don't have
 access to a Windows machine to test it on.

 As Jason Dagit say, I put the stdcall call convention option in OpenCL
 for windows:
 https://github.com/zhensydow/opencl/blob/master/OpenCL.cabal

 Other issues to solve,
 How to compile in hackage server to generate documentation online?
 opencl.h isn't in the server so I getting errors.

For now I have bundled the OpenCL header files with my package. That
is not the right way either, as the header files can contain some
platform specific information, for instance information about the
calling conventions, which would be a way to handle the problem above
(and the only way possible with c2hs, as far as I know).

-- 
Martin Dybdal

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


Re: [Haskell-cafe] ANN: OpenCL 1.0.1.3 package

2011-10-13 Thread Martin Dybdal
On 3 October 2011 12:56, Luis Cabellos cabel...@ifca.unican.es wrote:
 Hello, all.
 I want to show you the OpenCL package. I have done this using Jeff Heard
 OpenCLRaw package, but I create a new one due the lack of updates of the
 former.
 # Where to get it
 * Hackage page (http://hackage.haskell.org/package/OpenCL)
 * Repository (https://github.com/zhensydow/opencl)
 * Bugs (https://github.com/zhensydow/opencl/issues)
 * Examples (https://github.com/zhensydow/opencl/tree/master/examples).
 # Things:
 * I write it's high-level binding to OpenCL libraries, but only because I
 added more types to hide most of the alloc/free of the API, and hide the
 enums using c2hs enums.
 * The worst problem of the OpenCLRaw is the bad types it use, I learn to fix
 32/64 bits issues with c2hs, and test it on linux machines.
 * Tested on Linux + NVidia only.
 * Jason Dagit is helping with Windows, OSX testing in own fork, also the
 call-conv fork in github has changes to work on Windows
 Please, Consider it's on experimental status but it works, I need lots of
 feedbacks for detect posible errors,
 Thanks,

Hi everyone

I just found this thread today, as I don't read Haskell-cafe that
often (too bad, I know). I have been working on a set of OpenCL
bindings for the last months myself, which I'm using to implement an
OpenCL backend to the Data.Array.Accelerate library. The work is done
at the HIPERFIT research center, Uni. Copenhagen.

My bindings are even further from the naming conventions of the OpenCL
library, but I really can't see the problem with that. People which
are used to programming OpenCL from C/C++ might have to learn how the
naming conventions of the Haskell library are, but they only need to
do this once. When the mapping between the old and the new naming
conventions are learned, they will benefit from having a more clean
interface for all future times. (No Haskell hacker should have a
problem with a steep learning curve.)

It is somewhat troubling that we now have five different interfaces to
OpenCL (that I know of), and I think we should join efforts and make
one library that is as stable as possible. The five libraries are:

 * OpenCL
 * OpenCLRaw
 * HsOpenCL
 * hopencl
 * The library presented by Benedict Gaster at AMD (yet to be released)
  ( 
http://developer.amd.com/zones/OpenCLZone/publications/assets/MakingOpenCLSimplewithHaskell.pdf
)

My own library is available at https://github.com/HIPERFIT/hopencl and
will be released on hackage very soon (next week probably). Please
take a look at it. It is currently tested on x86_64 Linux with both
the AMD x86/x86_64 bindings and NVIDIAs CUDA bindings. They will
probably not work on Windows in their present state, and I don't have
access to a Windows machine to test it on.

-- 
Martin Dybdal

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


[Haskell-cafe] Trying to experiment with tangible values using GuiTV

2011-10-03 Thread Martin Baldan
Hello all,

I'm very new to Haskell, but still I'd like to play with tangible values,
which I find really intriguing. After getting some kind help in
haskell-beginners, I managed to compile and run a small example. Which is as
follows:

--


{-# LANGUAGE OverlappingInstances, UndecidableInstances
   , IncoherentInstances, FlexibleContexts
   , TypeSynonymInstances, FlexibleInstances
   , MultiParamTypeClasses
   #-}
-- For ghc 6.6 compatibility
{-# OPTIONS -fglasgow-exts -fallow-overlapping-instances
-fallow-incoherent-instances #-}


 Some GuiTV examples.  See also the examples in TV.

import Data.List (sort)

-- my addition
import Data.Monoid
-- end my addition

import Interface.TV.UI
import Control.Arrow.DeepArrow
import Data.FunArr

-- TypeCompose
import Data.Title

-- To pick up the FunArr instance for OFun.
import Interface.TV.OFun()

reverseT :: CTV (String - String)
reverseT = tv (oTitle reverse defaultOut) reverse

main = runUI reverseT


---

There were some warnings during compilation:

-
[1 of 1] Compiling Main ( myexample.hs, myexample.o )

myexample.hs:7:11:
   Warning: -fallow-overlapping-instances is deprecated: use
-XOverlappingInstances or pragma {-# LANGUAGE OverlappingInstances #-}
instead

myexample.hs:7:11:
   Warning: -fallow-incoherent-instances is deprecated: use
-XIncoherentInstances or pragma {-# LANGUAGE IncoherentInstances #-}
instead
Linking myexample ...
martin@martin-desktop:/media/
ext4logicaUnTera/cosas_linux/programs/haskell/TV/examples/src/miejemplo$
ghc --make myexample.hs

myexample.hs:7:11:
   Warning: -fallow-overlapping-instances is deprecated: use
-XOverlappingInstances or pragma {-# LANGUAGE OverlappingInstances #-}
instead

myexample.hs:7:11:
   Warning: -fallow-incoherent-instances is deprecated: use
-XIncoherentInstances or pragma {-# LANGUAGE IncoherentInstances #-}
instead

-


When I run it, I get a little window with the reverse title and two
textboxes. However, when I write something in the upper box, nothing
happens. I must say that when I use runIO instead of runUI in this little
program, the interactive program does work. Only the GUI version doesn't.

So, the person who helped me (Brandon Allbery) said it's probably because of
a GuiTV being a bit too old. He recommended me to ask about the issue here,
at haskell-cafe.

Any suggestions? Maybe I should use GtkTV istead of GuiTV? Thanks in
advance!


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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-19 Thread Sam Martin
 My conclusion was that GLFW-b (on hackage) is the best we have right
 now.  I think we could do even better than the C libraries out there
 by writing the GLUT/GLFW/etc implementation purely in Haskell.  We
 already have x11 and gtk bindings for the linux support.  We have
 win32 api bindings for windows support.  What we are lacking is good
 low level support for OSX GUI programming.  Once we have that it's not
 too much of a stretch to use cabal to glue it together into a cross
 platform library.  I believe that's the right way to go for the long
 term.  Improving GLFW-b is a good short-term route.

I agree with your approach. Although getting a window on screen really isn't 
much code, so I'd vote for going straight to a Haskell replacement for GLUT et 
al. 

 And just to say it one more time, I can use all the help I can get.

I don't have much time, but if someone started a github project for a Haskell 
GLUT replacement I could probably chip in here and there. 

Ta,
Sam

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


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-05-18 Thread Sam Martin
Is there a library that satisfies 2 of your 3 points?

* Works with ghci
* Supports OpenGL.

I've struggled to get:

* A window with opengl
* Running interactively from ghci
* Working cross platform

Anyone know of a solution for that?

If there's a library that handles that, then there's at least a sensible base 
to build a pure functional GUI system on.

Cheers,
Sam

From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Conal Elliott
Sent: 18 May 2011 00:24
To: Haskell Cafe
Subject: [Haskell-cafe] Status of Haskell + Mac + GUIs  graphics

I still haven't found any way to do GUIs or interactive graphics in Haskell on 
a Mac that isn't plagued one or more of the following serious problems:

* Incompatible with ghci, e.g., fails to make a window frame or kills the 
process the second time one opens a top-level window,
* Goes through the X server, and so doesn't look or act like a Mac app,
* Doesn't support OpenGL.

A year or two ago, I put my Haskell GUI  graphics work on hold while waiting  
hoping for a functioning pathway to open. So far I haven't heard of one.

If anyone has found a solution, I'd love to hear!

  - Conal

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


Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Martin Erwig

All the previous solutions seem to assume that the list of numbers is already 
sorted. In cases where this assumption cannot be made, an alternative solution 
is to simply insert the numbers into a diet.

eecs.oregonstate.edu/~erwig/papers/abstracts.html#JFP98
eecs.oregonstate.edu/~erwig/diet


--
Martin


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


Re: [Haskell-cafe] Unix emulation

2010-08-22 Thread Martin DeMello
On Sun, Aug 22, 2010 at 5:04 PM, Stephen Tetley
stephen.tet...@gmail.com wrote:
 Andrew, I was going to chastise you for being the only Windows
 developer who has problems with MinGW / MSYS and spreading that
 unpleasant internet commodity FUD. However, I've just gone back to
 mingw.org and its gone from somewhat confusing circa the last time I
 installed (Christmas 2009) to frankly abysmal. So while is was easy
 to install MinGW / MSys a year ago I'll willing concede that it is
 difficult now.

Agreed. I tried to set up an msys development environment to compile
chicken scheme a couple of weeks ago, and, quite frankly, gave up. I
settled for installing mingw and putting the mingw bin directory first
in my cygwin path. This worked very well indeed, even though it isn't
an officially supported chicken build environment, so it's worth
experimenting with for haskell as well. (Note that it needs a reboot
of windows after setting up the cygwin environment variables; I never
figured out why).

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


[Haskell-cafe] Anything like Mythryx in Haskell?

2010-08-18 Thread Martin DeMello
Mythryl [http://mythryl.org/] is an ML dialect that mostly puts an
Algolish syntax and some good posix interoperability atop SML/NJ. More
than the language (which doesn't seem to be as tastefully designed as
Haskell, particularly in terms of syntax - what do people have against
MLish syntax anyway?) I like the goals of the associated Mythryx
project [http://mythryl.org/my-Mythryx.html], namely, to develop a
well-engineered unixy ecosystem in a strongly typed functional
language. Has anyone attempted something like this in Haskell?

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


Re: [Haskell-cafe] Database.CouchDB broken?

2010-07-31 Thread Martin Hilbig

hi,

try it this way:

http://gist.github.com/501951

note the type annotations and the added req param include_docs=true for
getAllDocs.

the first error is created by ghci, since it dont know the specific type

Database.CouchDB :t runCouchDB' $ getDoc (db test) (doc xyz) 
runCouchDB' $ getDoc (db test) (doc xyz)

  :: (JSON a) = IO (Maybe (Doc, Rev, a))

but why doesnt it complain about the ambiguous type variable `a', like
in `read 124`?

the addition of the include_docs=true request parameter really should be
in the getAllDocs function itself.

i'll fix this and put it in my own haskell-couchdb repo, as well as the
simple bulk and attachment apis i implemented, stay tuned ;)

have fun
martin

On 19.07.2010 19:08, Moritz Ulrich wrote:

Hello,

I'm currently learning Haskell and I want to write a small tool to
collect some data in a CouchDB-Database Sadly, the Database.CouchDB
module from hackage (and from git) seems broken. It looks like a bug
 deep in the JSON handling of the lib.

Some examples can be found in this gist:
http://gist.github.com/475323 ('test' is a database with two simple
documents, the doc with the id '8e9112011580882422393f6291000f7d'
exists)

I filed an issue, but the maintainer hasn't responded in 5 days. Is
there anything I missed?

Thanks in advance!


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


Re: [Haskell-cafe] Actors and message-passing a la Erlang

2010-07-26 Thread Martin Sulzmann
Not distributed (yet) but concurrent:
http://hackage.haskell.org/package/actor

The paper  Actors with Multi-headed Message Receive Patterns. COORDINATION
2008http://www.informatik.uni-trier.de/%7Eley/db/conf/coordination/coordination2008.html#SulzmannLW08:
describes the design rationale.

Cheers,
  Martin

On Sun, Jul 25, 2010 at 10:55 PM, Yves Parès limestr...@gmail.com wrote:

 Hello !

 I've been studying Erlang and Scala, and I was wondering if someone has
 already implemented an actors and message passing framework for concurrent
 and distributed programs in Haskell.

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


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


Re: [Haskell-cafe] Re: Hot-Swap with Haskell

2010-07-16 Thread Martin Hilbig

hi,

if been thinking about an haskell interpreter to, because of erlang's 
otp. its syntax is a mess, but its scalability is win.


since erlang runs in its vm (interpreted) is there a need for a real 
haskell interpreter, or can there be a compiled haskell/otp with 
hotswapping, scaling and stuff?


now back on topic, i wrote real haskell interpreter because there is 
the hint[1] package, which wrappes the ghc api.


now i dont know what more the plugin package provides, but i thought 
hint is like is successor (since lambdabot used plugins and now uses 
mueval, which in turn uses hint ;). please correct me.


have fun
martin

[1]: http://hackage.haskell.org/package/hint

On 16.07.2010 06:06, Andy Stewart wrote:

Don Stewartd...@galois.com  writes:


lazycat.manatee:

Hi all,

I'm research to build a hot-swap Haskell program to developing itself in
Runtime, like Emacs.

Essentially, Yi/Xmonad/dyre solution is replace currently executing
technology:

re-compile new code with new binary entry

when re-compile success
   $ do
   save state before re-launch new entry
   replace current entry with new binary entry (executeFile)
   store state after re-launch new entry

There are some problems with re-compile solution:

1) You can't save *all* state with some FFI code, such as gtk2hs, you
can't save state of GTK+ widget. You will lost some state after
re-launch new entry.

2) Sometimes re-execute is un-acceptable, example, you running some command
in temrinal before you re-compile, you need re-execute command to
restore state after re-launch, in this situation re-execute command is 
un-acceptable.

I wonder have a better way that hot-swapping new code without
re-compile/reboot.



Well, the other approach to reloadable modules, using either object code
plugins, or bytecode plugins, giving you module-level granularity.

Thanks for your reply.

I have read your papers : Dynamic Application From the Group Up and  Plugging 
Haskell In

In Dynamic Application From the Group Up, you introduction how to use
re-compile technology implement source-code level hot-swapping.

In Plugging Haskell In, you introduction to how to buld hot-swapping
with object-code level.

Yes, Dynamic linking can add new code to a running program, but how to
replace existing binding with new ones?
Looks you still need some reboot when you do *replace* and not just *add*.

Infact, reboot is okay, only problem is *keep state*, some *static state*
is easier to re-build, example, if you want restore editor buffer state, you
just need save (filepath, cursorPosition), you can re-open file and
restore cursor position after reboot process.

Difficult is *Stream State*, such as:
   delete operation in file-manager
   command running in temrinal
   network communications in browser
It's really difficult to restore those state, and re-execute is
un-acceptable sometimes.

You can found the screenshot of my project at 
http://www.flickr.com/photos/48809...@n02/

Currently, the closest library to implement dynamic linking is your
plugins package (http://hackage.haskell.org/package/plugins-1.4.1),
i really want to write some code to test it, unfortunately, it's
broken with Cabal-1.8.0.4 that can't compile with ghc-6.12.x/ghc-6.12.3,
can you fix it if you have time? It's so great package...

I'm looking for some paper about Haskell and hot-swapping.
Any paper or suggestion are welcome!

   -- Andy





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

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


Re: [Haskell-cafe] Re: ANNOUNCE: fgl-5.4.2.3

2010-07-12 Thread Martin Hilbig

On 12.07.2010 09:25, Ivan Lazar Miljenovic wrote:

A couple of points I meant to make here but forgot (I was busy hacking
on this and my other three graph-related packages for over a week now,
and especially this past weekend it cut into my sleeping...):

* Apart from bug-fixes, I don't intend on touching the 5.4 series any
   more.  That said, I believe that this version is suitable for
   replacing 5.4.2.2 in the platform (what's the process on that?).

* After I get my generic graph class sorted out at AusHac this coming
   weekend, I intend to make a 5.5.0.0 release which extends the classes
   in this new library; this will probably _not_ be suitable for the
   platform and is intended to serve as a stepping stone to the
   replacement library Thomas Bereknyei and I are working on.

With that last point: Thomas and I are willing to call this new
version/replacement something like inductive-graphs if that is the
preference of the community.  Does anyone know of a website that would
let us have a survey we can use to determine which option people would
prefer?


how about http://doodle.com?

have fun, keep hacking.
martin


 Note that even if we give it a new name (rather than just a new
major version number), we still intend on using the Data.Graph.Inductive
module namespace (as it makes even more sense with the new name), so
there will still be clashes between this new version and fgl.

Ivan Lazar Miljenovicivan.miljeno...@gmail.com  writes:


I'm pleased to present the first new release of fgl [1] since Thomas
Bereknyei took over maintaining it from Martin Erwig.

[1] http://hackage.haskell.org/package/fgl

Before people start panicking, rioting, etc., please check the version
number: this is just a bug-fix release, and not the complete re-write
version which we've been talking about (since we got a little
sidetracked, etc.).  As such, the API hasn't changed, and this should
fit right in to packages already using fgl (sorry to all those people
who followed my advice and put fgl == 5.4.2.2 in the build-depends
fields of their packages' .cabal files, but I didn't expect to make
another 5.4.y release).

The exact change that has been made is to fix a bug pointed out to me by
Tristan Allwood, in that Data.Graph.Inductive.PatriciaTree didn't
support multiple edges (and furthermore this wasn't specified in the
documentation).  This has now been rectified.  As an indication of what
these changes mean, see this sample call graph produced by my
SourceGraph program; when using PatriciaTree from fgl-5.4.2.2 the lines
were all the same thickness; now there is among other things a loop of
width 32 on getExp and a line of width 7 from getExp to maybeEnt.



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


RE: [Haskell-cafe] Re: Float instance of Data.Bits

2010-07-10 Thread Sam Martin

 Note that the Haskell report does not require IEEE 754 binary encodings.
 In fact, it permits 'Float' to be a decimal floating point type.

True. Although I don't really understand why? Or rather, I don't understand why 
it can't be at least slightly more specific and at least state that Float is a 
32-bit floating point value and Double is a 64-bit floating point value. The 
exact handling of various exceptions and denormals tends to vary across 
hardware, but this at least allows you to get at the representation. 

I realise it'll be platform-specific (assuming isIEEE returns false), but then 
so is the behaviour of your code if you don't require IEEE support.  

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


[Haskell-cafe] Float instance of Data.Bits

2010-07-09 Thread Sam Martin
Hi,

Is there a particular reason Float, Double, etc do not have instances of 
Data.Bits in the standard libraries? I note the Haskell 2010 report doesn't 
include them either.

In fact, I'm not actually sure how you'd implement the instance for floating 
point types without having some kind of compiler-specific extension, or a 
c-binding.

Could anyone fill in my missing knowledge here?

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


RE: [Haskell-cafe] Re: Float instance of Data.Bits

2010-07-09 Thread Sam Martin
 Some operations wouldn't make much sense with Float, for instance the
 'complement' function.  What should it return?  Also note that bit
 manipulation functions could cover only a small window of the value
 range.  So it could happen that x .|. y = x, even though y is nonzero.
 Also rotation would be a destructive operation.

Perhaps I can illustrate this with an example. It's very common with SSE
code to interpret a float as both a mask and a number. You can exchange
the two freely.

For instance, in c-like pseudo code, you can write:
float mask = myval == 0 ? 0x : 0x
float temp = 5 / myval
float result = mask .. temp

Which returns 0 or the result of 5 / myval. Each line above turns into a
single sse instruction, and there are no branches. Bit wise operations
on Floats should operate as if you had reinterpreted the Float as an
unsigned integer.

There are plenty of other examples of bit twiddling floats. Floats have
a well defined bit representation (if a slightly complex one) so it's
perfectly reasonable to be able to manipulate it. A complement operation
on a float returns a float, and is well defined, if the output bit
pattern is one you want.

An alternative way to model this would be to provide ways to reinterpret
a float as a word32, which helps enforce static typing. I don't know of
any way of doing this in Haskell though.

Does that make more sense?

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


Re: [Haskell-cafe] checking types with type families

2010-07-01 Thread Martin Sulzmann
On Thu, Jul 1, 2010 at 7:54 PM, Simon Peyton-Jones simo...@microsoft.comwrote:


 |  Also, what is the difference between fundeps and type families
 |  wrt local type constraints? I had always assumed them to be
 |  equivalent, if fully implemented. Similar to logic vs functional
 |  programming, where Haskellers tend to find the latter more
 |  convenient. Functional logic programming shows that there
 |  are some tricks missing if one just drops the logic part.

 Until now, no one has know how to combine fundeps and local constraints.
  For example

  class C a b | a-b where
op :: a - b

   instance C Int Bool where
 op n = n0

  data T a where
T1 :: T a
T2 :: T Int

  -- Does this typecheck?
  f :: C a b = T a - Bool
  f T1 = True
  f T2 = op 3

 The function f should typecheck because inside the T2 branch we know that
 (a~Int), and hence by the fundep (b~Bool).  But we have no formal type
 system for fundeps that describes this, and GHC's implementation certainly
 rejects it.


Martin Sulzmann, Jeremy
Waznyhttp://www.informatik.uni-trier.de/%7Eley/db/indices/a-tree/w/Wazny:Jeremy.html,
Peter J. 
Stuckeyhttp://www.informatik.uni-trier.de/%7Eley/db/indices/a-tree/s/Stuckey:Peter_J=.html:
A Framework for Extended Algebraic Data Types. FLOPS
2006http://www.informatik.uni-trier.de/%7Eley/db/conf/flops/flops2006.html#SulzmannWS06:
47-64

describes such a system, fully implemented in Chameleon, but this
system is no longer maintained.

Type families and Fundeps are equivalent in expressive power and it's
not too hard to show how to encode one in terms of the other.
Local constraints are an orthogonal extension. In terms of type inference,
type families + local constraints and fundeps + local constraints pose the
same
challenges.

Probably, Simon is refrerring to the 'unresolved' issue of providing a
System F style translation for fundeps + local constraints. Well, the point
is that System FC
is geared toward type families. The two possible solutions are (a) either
consider fundeps as syntactic sugar for type families (doesn't quite work
once
you throw in overlapping instances), (b) design a variant System FC_fundep
which has built-in support for fundeps.

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


Re: [Haskell-cafe] GHCi and State

2010-06-28 Thread Martin Hilbig

hi,

On 25.06.2010 11:07, corentin.dup...@ext.mpsa.com wrote:



Another couple of reflexions (sorry for monopolizing):

1. Since i am making a Nomic game, players will have to submit rules. These
rules will be written in a sub-set of haskell.
Instead of writing my own reader/interpreter, i'd like to use GHC to compil
them on the fly, and then add them to the current legislation.
What would you suggest me to do that? Any pointers?


check out hint, a nice wrapper around the ghc api [1].

have fun
martin

[1]: http://hackage.haskell.org/package/hint


2. For now, the game is more or less playable in GHCi. But my concern is:
When you use GHCi, you are in the IO monad, right? How to had state to this
monad?
I would like that the player can compose his rule in GHCi, and when he is
done, he can submit it in GHCi with something like:

*Nomic  submitRulemyrule

And then the game takes the rule, possibly modify the current legislation,
and give the hand back to GHCi.
So the current legislation has to be a state of the GHCi's loop. Is this
possible at all?
submitRule would have a type more or less like that (GameState contains the
legislation):

submitRule :: Rule -  StateT GameState IO ()


Thanks for  your attention! I know this is a bit confused!

Best,
Corentin


___
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] When the unknown is unknown

2010-06-24 Thread Martin Drautzburg
On Thursday, 24. June 2010 00:04:18 Alexander Solla wrote:
 On Jun 23, 2010, at 1:50 PM, Martin Drautzburg wrote:
  I said that a rhythm is a series of Moments (or Beats), each
  expressed as
  fractions of a bar. But each Moment also has volume. So I could
  model rhythm
  as Pairs of (Moment, Volume). However I certanly do not want to
  specify both
  the Moments and the Volume, but rather compute one from the other.

 How about something like:

 type RhythmScheme = [(Maybe Moment, Maybe Volume)]
 type Rhythm   = [(Moment, Volume)]

 -- The resolution function will then be a function with type:

 rhythm_from_scheme :: RhythmScheme - Rhythm

 -- Though you might want something like
 -- rhythm_from_scheme :: RhythmScheme - IO Rhythm
 -- or
 -- rhythm_from_scheme :: Seed - RhythmScheme - Rhythm
 -- so that you can get and use random numbers, for example.


 I guess the point of my suggestion is to let pattern matching in
 function definitions deal with unification of constraints.  Beta
 reduction and unification are two sides of a coin.

Nice. 

But what if I have three or more values (and not just two). Then inside the 
rhythm_from_scheme function I will probably have functions like
a-b-c, i.e. if two values are known I can compute the third. If only one 
value is known the result would be a partially applied function and I would 
need additional information to compute the result. So I will need more than 
just a Mabye, because I can either have Nothing, a value or a function. 

However I will need one such function for each permutation. The function 
a-b-c will not help me much if either b or c is known. This means I cannot 
stuff too many unknowns together, but I will have to layer the problem 
somehow, such that a 9tuple of unknowns is unified as three triples. I am 
still uncertain how to do this, but I believe it basically matches musical 
thinking. A composer cannot juggle 9 unknowns either without grouping them 
somehow.

Another question is: how much past and future knowledge do I need. (I believe 
the fundamental property of music is that things are ordered).  In order to 
compute Volumes from Moments I can get pretty much away without the past, but 
computing Moments from Volumes definitely requires knowing where I am, 
because each new Moment has to be placed after a preceding Moment.

Any ideas?










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


Re: [Haskell-cafe] Haskell Bangalore

2010-06-24 Thread Martin DeMello
Sure, sounds like fun :) I keep trying to learn Haskell and getting
nowhere, but the thing is I keep trying!

martin

On Mon, Jun 21, 2010 at 10:00 AM, C K Kashyap ckkash...@gmail.com wrote:
 Hi,
 I was wondering if it would be a good idea for the folks interested in
 Haskell in Bangalore to get together. Especially if there are folks at EGL,
 perhaps we could just meet up at pyramid.
 I've been trying to learn Haskell for a while and currently am trying to
 work through SPJ's implementation of Functional Programming languages. It
 would be good to bounce off ideas (in person) with like minded folks.
 --
 Regards,
 Kashyap
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


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


[Haskell-cafe] When the unknown is unknown

2010-06-23 Thread Martin Drautzburg
Hello all,

I am currently playing with Paul Hudak's Euterpea (a music program, formely 
called Haskore) and I am trying to teach it about rhythm.

I said that a rhythm is a series of Moments (or Beats), each expressed as 
fractions of a bar. But each Moment also has volume. So I could model rhythm 
as Pairs of (Moment, Volume). However I certanly do not want to specify both 
the Moments and the Volume, but rather compute one from the other.

Often the Moments are known and I need to compute the Volumes, but this is not 
always the case. I might as well start with the volume and compute the 
moments. The latter would be particularly interesting when trying to find 
rhythms which are suitable for certain lyrics. In that case I must even be 
prepared to find more than one series-of-moments which fit to the given 
series-of-volumes.

There are countless other problems like this, e.g. when trying to match 
harmony, melody and tension. In that case I even have three variables and I 
may want to specify tension first, then melody and have the harmony computed. 

At first glance this looks like a Prolog-like problem to me. I could say that 
certain things are always true for [(Moment, Volume)] and let an inference 
engine figure out the options which are still in consideration.

From which angle would you approach problems like this? Should I get my hands 
on a prolog-in-haskel implementation (which indeed seems to exist)? Or should 
I roll my own poor-man's prolog? Or is this a 
constraint-satisfaction-problem? Or is there even a more straight-forward 
more haskellish pattern, which solves such problems?

Any pointers would be much appreciated.


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


[Haskell-cafe] Mapping a list of functions

2010-06-17 Thread Martin Drautzburg
Hello all

The standard map function applies a single function to a list of arguments. 
But what if I want to apply a list of functions to a single argument. I can 
of course write such a function, but I wonder if there is a standard way of 
doing this,

Related to that is the problem, that the function in map may require more than 
one argument, so I need to apply it partially to some value(s) first. But 
what if I want to fix its second and third argument and not its first 
argument? Can flip help?

Thanks

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


Re: [Haskell-cafe] Vague: Assembly line process

2010-06-16 Thread Martin Drautzburg
On Tuesday, 15. June 2010 19:43:26 Steve Schafer wrote:
 On Tue, 15 Jun 2010 19:23:35 +0200, you wrote:
 When I know my supplies I want to know what I can produce. When I know
  what I want to produce I want to know what supplies I need for that. Both
  kinds of questions should be answered by a singe Process thingy.
 
 I want to be able to chain processes and the whole thing should still act
  like a Process.

 This is a type of constraint network. If you have access to _Structure
 and Interpretation of Computer Programs_, there is a section therein
 devoted to constraint networks. 

Will check this out. I was hoping that something simpler would suffice. I am 
afraid of CSPs.

Today I was playing with a matrix representation. I mean the one you learn in 
school for linear optimization problems. Usually the matrix is written so it 
tells you how much of each supply you need to produce a unit of outputs. 

So when you know the outputs you can compute what you need as a minimum. You 
can invert the matrix and it'll work on the oppsite direction: when you know 
the inputs it'll tell you what you can produce at most.

Then I thought, what if I replace the (*) and (+) operations which are applied 
when I multipy the matrix with a vector (i.e. a vector if inputs or outputs) 
by something more general. So I replaced (+) by function application and my 
matrix was now a matrix of functions. But then I got lost trying to find a 
way to invert such a matrix.

FWIW: while googeling around how to invert a matrix of functions I stumbeled 
across the Process Specification Language. At least they defined an 
ontology, but there isn't much of computing stuff there. 
http://www.mel.nist.gov/psl/





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


Re: [Haskell-cafe] Vague: Assembly line process

2010-06-15 Thread Martin Drautzburg
On Tuesday, 15. June 2010 01:40:03 Luke Palmer wrote:
 So hang on, what is the problem?  You have described something like a
 vague model, but what information are you trying to get?  Say,
 perhaps, a set of possible output lists from a given input list?

When I know my supplies I want to know what I can produce. When I know what I 
want to produce I want to know what supplies I need for that. Both kinds of 
questions should be answered by a singe Process thingy.

I want to be able to chain processes and the whole thing should still act like 
a Process.

 Luke

 On Mon, Jun 14, 2010 at 11:16 AM, Martin Drautzburg

 martin.drautzb...@web.de wrote:
  Hello all,
 
  this is a problem which has haunted me for some time. If this is simply
  hillarious, please tell me so. Or it may be some well known unsolvable
  problem...
 
  An assembly process takes inputs and produces outputs. I could say a
  Process is a function
 
  canProduce :: [Input]-[Output]-Bool
 
  which tells me if the outputs can be produced from the inputs
 
  There may be a similar function which tells me if the inputs are
  completely consumed to procude the output.
 
  The inputs do not determine the exact outputs. Think of a Process which
  combines a List of Ints into pairs, such that the input ints are consumed
  and each input Int occurs in only one position in the output. There are
  many ways to do this. Still for any set of input Ints and output pairs I
  could decide if the output can be produced from the input.
 
  Likewise the Input is not determined by the output. There may be lots of
  choices from what I could build my output (buy from different vendors).
 
  When I know more about the inputs and outputs my choices get more and
  more limited. I would like to to pass inputs and/or outputs to
  something and I would like to get a something which is more
  restricted, but still essentially a thing which tells me if the outputs
  can be produced from the inputs.
 
  I just cannot find a way to even THINK about this problem in a reasonable
  general way.
 
  --
  Martin
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe



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


[Haskell-cafe] Vague: Assembly line process

2010-06-14 Thread Martin Drautzburg
Hello all,

this is a problem which has haunted me for some time. If this is simply 
hillarious, please tell me so. Or it may be some well known unsolvable 
problem...

An assembly process takes inputs and produces outputs. I could say a Process 
is a function

canProduce :: [Input]-[Output]-Bool

which tells me if the outputs can be produced from the inputs

There may be a similar function which tells me if the inputs are completely 
consumed to procude the output.

The inputs do not determine the exact outputs. Think of a Process which 
combines a List of Ints into pairs, such that the input ints are consumed and 
each input Int occurs in only one position in the output. There are many ways 
to do this. Still for any set of input Ints and output pairs I could decide 
if the output can be produced from the input.

Likewise the Input is not determined by the output. There may be lots of 
choices from what I could build my output (buy from different vendors).

When I know more about the inputs and outputs my choices get more and more 
limited. I would like to to pass inputs and/or outputs to something and I 
would like to get a something which is more restricted, but still 
essentially a thing which tells me if the outputs can be produced from the 
inputs.

I just cannot find a way to even THINK about this problem in a reasonable 
general way.

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


[Haskell-cafe] How to browse code written by others

2010-06-13 Thread Martin Drautzburg
Hello all,

I need your advice about how to browse code which was written by someone else 
(Paul Hudak's Euterpea, to be precise, apx. 1 LOC). I had set some hopes 
on leksah, and it indeed shows me the interfaces, but I have not yet 
convinced it to show me more than that.

I ran haddock over the sources, and again I could not see more that just 
signatures.

I would be very happy with something like a Smalltalk browser. Something that 
would let me zoom down to the source code, but with search and hyperlink 
capabilities (senders and implementers in Smalltalk).

Anyways, how do you guys do it, i.e. how to you dive into non-trivial foreign 
code?


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


[Haskell-cafe] Literate programming

2010-06-12 Thread Martin Drautzburg
Hello all,

Is literate programming something you guys actually do (I only know that Paul 
Hudak does), or is it basically a nice idea from days gone by?

In case you do, then how do you do it? Do you use lhs2TeX or what? Do you 
use bird style of full-blown LaTeX?

Does any of you use leksah? I failed to see any support for literate 
programming in leksah. It candies the backslashes in e.g. 
\documentclass{article} to λdocumentclass{article}.

In case you don't, then how do you document your code? If you write a paper 
which explains what your code does, then how do you do that?

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


Re: [Haskell-cafe] Literate programming

2010-06-12 Thread Martin Drautzburg
On Saturday, 12. June 2010 19:06:39 Darrin Chandler wrote:
 On Sat, Jun 12, 2010 at 12:34:37PM -0400, aditya siram wrote:
  It's weird I was just thinking about LP in Haskell this morning. Check
  out John Milliken's dbus-core [1] written entirely in noweb. 

Okay I'll check out noweb.

My personal opionion as a haskell newbie is that I love literate programming. 
I can write down my train of thoughts along with the source code, then I read 
the generated document an I can find flaws in it much more easily than when 
reading the bare source. I understand that this becomes less of an issue when 
you become more experienced with haskell. Still it will always be a good way 
to promote haskel-style solutions.

I don't have any problems with LaTeX, but a less verbose solution would do 
just fine. 

My biggest problem is actually literate programming in conjunction with 
leksah. Can anybody comment on this issue? Do you guys use leskah at all? 

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


Re: [Haskell-cafe] How to Show an Operation?

2010-06-10 Thread Martin Drautzburg
On Thursday, 10. June 2010 00:08:34 Luke Palmer wrote:

 Or just:

 apply = val_of

 So, to summarize:  if you have something that isn't a function and you
 want to use it like a function, convert it to a function (using
 another function :-P).  That's all.  No syntax magic, just say what
 you're doing.

Thanks Luke

The reason I was asking is the following: suppose I have some code which uses 
some functions, and what it primarily does with those functions is CALL them 
in different orders.

Now at a later point in time I decide I need to give names to  those functions 
because at the end I need to print information about the functions which 
together solved a certain problem. Think of my problem as In which order do 
I have to call f,g,h such that (f.g.h) 42 = 42?.

I don't want to change all places where those functions are called 
into apply style. Therefore I was looking for some idiom like the python 
__call__() method, which, when present, can turn just about anything into a 
callable.

I could change the *definition* of my original functions into apply style 
and the rest of the code would not notice any difference. But that does not 
really help, because in the end I want to Show something like [g,h,f], but my 
functions would no longer carry names.

Alternatively I could associate functions with names in some association 
function, but that function simply has to know to much for my taste.

The thing is, I only need the names at the very end. Throughout the majority 
of the computation they should stay out of the way.


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


Re: [Haskell-cafe] Re: How to Show an Operation?

2010-06-10 Thread Martin Drautzburg
On Thursday, 10. June 2010 22:10:08 Maciej Piechotka wrote:

Wow!

this is somewhat above my level. I guess I need to go back to the books. I'll 
document my ignorance nontheless.

 data Named a = Named String a

 instance Functor Named where
 f `fmap` (Named s v) = Named s (f v)

okay so far

 instance Applicative Named where
 pure x = Named  x
 (Named s f) * (Named t v) = Named (s ++ ( ++ t ++ )) (f v)

Applicative. Need to study that
Control.Applicative (*) :: Applicative f = f (a - b) - f a - f b

So in our case the Applicative is a Named. When I apply a Named to a 
function, then I get a function between the corresponding Named types. When I 
pass it an Int-Char function, I get a Named Int - Named Char function.

But here it is applied to another Named ... is that the (a-b)? Puzzeled.

 instance Eq a = Eq (Named a) where
 (Named _ x) == (Named _ y) = x == y

 instance Show (Named a) where
 show (Named s _) = s


Understood.

 namedPure :: Show a = a - Named a
 namedPure x = Named (show x) x

When I can show something I can always name it so its name is what 'show' 
would return. Okay I guess I got it. This turns a showable into a Named.


 test :: Num a
  = (a - a) - (a - a) - (a - a) - [String]
 test f g h = do
 [f', g', h'] - permutations [Named f f, Named g g, Named h h]

According to Hoogle permutations should be in Data.List. Mine (GHCI 6.8.2) 
does not seem to have it. Seems to have something to do with base, whatever 
that is.

 guard $ namedPure 42 == f' * g' * h' * namedPure 42

Ah, the 42 needs namedPure.
Again this * operator... 
I believe the whole thing is using a List Monad. 

 return $ show f' ++  .  ++ show g' ++  .  ++ show h'

I wonder if the thing returns just one string or a list of strings. I 
guess return cannot return anything more unwrapped than a List, so it must 
be a List. But does it contain just the first match or all of them? All of 
them! And how many brackets are around them?

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


Re: [Haskell-cafe] Re: How to Show an Operation?

2010-06-10 Thread Martin Drautzburg
On Friday, 11. June 2010 00:12:03 Daniel Fischer wrote:

Thanks Daniel. 

 Upgrade. We're at 6.12 now!

Did that. Everything is available now.

I am still having trouble with the test function. First it seems I need 
braces, so I can mix == and *.
test :: Num a
 = (a - a) - (a - a) - (a - a) - [String]
test f g h = do
[f', g', h'] - permutations [Named f f, Named g g, Named h h]
guard $ namedPure 42 == (f' * g' * h' * namedPure 42)
return $ show f' ++  .  ++ show g' ++  .  ++ show h'

But this leads to

Occurs check: cannot construct the infinite type:
  a = (a - a) - a1 - t
When generalising the type(s) for `test'

This error message is still the maximum penalty for me (along with Corba 
marshall exception in J2EE and Missing right parenthesis in Oracle SQL)

Then generally speaking, I have the feeling that this code does not 
allow namifying existing code either. In this respect it does not seem to 
do better than the apply method pattern discussed earlier in this thread.

The problem it solves is very simple and therefore using (*) and namedPure 
isn't much of a drawback. But if I had tons of code to namify I would still 
have to do significant changes to it, right?





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


Re: [Haskell-cafe] How to Show an Operation?

2010-06-09 Thread Martin Drautzburg
On Monday, 7. June 2010 23:28:08 Evan Laforge wrote:

 I just meant you could add instances:

 instance Functor (Named a) where fmap f named = named { val_of = f
 (val_of named) }
 instance Applicative (Named a) where ... likewise, but maybe not a
 great fit unless you have a no name for 'pure'

So far so good. However my Named things are all functions and I don't see I 
ever want to map over any of them. But what I'd like to do is use them like 
ordinary functions as in:

f::Named (Int-Int)
f x

Is there a way to do this, other than writing

apply::Named Int -Int
apply n x = (val_of n) x


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


Re: [Haskell-cafe] How to Show an Operation?

2010-06-07 Thread Martin Drautzburg
On Friday, 4. June 2010 18:02:15 Daniel Fischer wrote:
 On Friday 04 June 2010 17:37:16, Martin Drautzburg wrote:
  Dear all,
 
  If I have a problem where I have to select from a set of operations, how
  would I print the result?
 
  Example: If I can chose from (x+y), (x*y), (x^2+y)...
  and I feed them all into my problem solver
  and it finds that (x*y) is right, how can I print that string?

 You'd have to pass the description string to the problem solver too.
 If it was previously

 solver :: Num a = Whatever - [a - a - a] - Result

 it would become for example

 solver :: Num a = Whatever - [(a - a - a, String)] - Result

Thanks to Ozgur Akgun for his suggestion. However I really wanted a human 
readable name, but admittedly I haven't said so.

About this one:

The only thing I miss in this solution, is that the name is identified by its 
position in the Pair. In this case this is certainly not a problem. But 
anyways, I tried to give it a name, using record syntax. 

This worked well until I wanted to define a different set of operations, which 
should also be named. It turned out that the name function, which was 
implicitly created (using record syntax) cannot be used again.

How should I work around that. I could use two different name function, but 
I don't like this. Would I have to define a typeclass namedFunction which 
all have a name function? 

I guess my mind is still a bit stuck in the OO world.

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


[Haskell-cafe] How to name a mapped function?

2010-06-07 Thread Martin Drautzburg
Hello all,

I like some of the naming conventions in haskell quite a lot, like calling a 
list of something xs, or function which takes a function as a 
parameter ..By as in sortBy or groupBy.

If I have a function, say compute whose last parameter is some value ...
and I create another function, which applies compute to a list of values, 
how would I call this function?

I was tempted to use all, but my original function already returns a list, 
so this would be misleading. Also note that the mapped version, does some 
additional things (remove duplicates), otherwise a new function would hardly 
be justified.


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


[Haskell-cafe] How to Show an Operation?

2010-06-04 Thread Martin Drautzburg
Dear all,

If I have a problem where I have to select from a set of operations, how would 
I print the result?

Example: If I can chose from (x+y), (x*y), (x^2+y)...
and I feed them all into my problem solver
and it finds that (x*y) is right, how can I print that string?

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


Re: [Haskell-cafe] Language Shootout reverse-complement benchmark

2010-06-03 Thread Martin Drautzburg
Inspired by this post I looked at the language shootout. There is one thing 
which strikes me: On

http://shootout.alioth.debian.org/u64/performance.php?test=spectralnorm#about
 
It sais for the spectralnorm benchmark that both Haskel GHC #4 and HaskellGHC 
produce bad output. For GHC I connt see what's wrong because 1.274224153 
seems to be the correct result. But there really seems to be something wrong 
with GHC#4.

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


RE: [Haskell-cafe] [reactive] A pong and integrate

2010-05-26 Thread Sam Martin
I work in the games industry and I'm also not convinced of the Haskell+FRP path 
for games, but for different reasons. I am very fond of Haskell for games 
however, and think it is achievable. 

 

Regarding FRP, I don't think it is the right framework to base a game on. It's 
great for some stuff, particularly the kind of problem Peter demonstrated, but 
games are a lot more varied than that and efficiency concerns aside, it's just 
not the right approach for everything. I see it more as a useful tool for some 
elements than a framework that should form the backbone of a game.

 

Functional programming on the other hand is a big thing. Games look a lot more 
functional now days than they ever did before, and C++ doesn't have the right 
vocabulary to allow you to scratch this itch properly. EDSLs, parallelism, 
composability, higher order functions, and static typing are really where it's 
at, and Haskell excels at this. There's a lot of missed opportunities for more 
elegant and powerful architectures going by at the moment simple because it's 
not realistic to attempt them in C/C++. 

 

One area where Haskell is not so hot and needs a bit of TLC is it's 
'embedability'. A large cross-platform 100% Haskell game is not on the cards at 
the moment, but Haskell could start getting its hands dirty, if only it could 
be sensibly embedded within an otherwise C++ app. This would allow people to 
start to take advantage of it, without some wholesale switch over. However, to 
do this, Haskell implementations at least need to be more compiler and platform 
agnostic, and we would probably need a lot more control over the Haskell 
runtime itself, particularly wrt memory handling. Lua (which is very popular in 
the games industry) and ATS (which isn't used to my knowledge, but has 
excellent interaction with C) are good examples of languages where this kind of 
thing is considerably easier. Haskell would have to fit in differently to this, 
but that's the kind of idea.

 

Interesting things to note are that in this scenario, you could probably ditch 
IO altogether and just embed 'pure' Haskell. Games have very limited IO which 
would likely be best handed in C++ anyway.

 

Laziness/space leaks, garbage collection and general performance concerns are 
obviously also issues, but that's for another day J

 

Cheers,

Sam

 

From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Limestraël
Sent: 26 May 2010 08:52
To: Peter Verswyvelen
Cc: haskell-cafe@haskell.org; Patai Gergely
Subject: Re: [Haskell-cafe] [reactive] A pong and integrate

 

 The GHC bugs are now fixed, so it might be stable enough for
 another adventure like that, but I don't think I would bet on it
 again.

GHC bugs are corrected, but Reactive still have some. (See my previous posts)

 IMO Haskell is great for writing small clean prototypes, doing
 interesting research, and maybe making some fun little games, but I
 wouldn't use it for production reactive game coding, not yet at least.

Tim Sweeney (from Epic Games) has another perspective about that [1].
Besides, FRP is not mandatory. You can always make games in Haskell by using a 
more regular style (more imperative, would some say).
For now, the main problem is the small number of Haskell libraries for games 
when compared to the huge numbers of those which exist in C++, which prevents, 
for now, Haskell to be used as the main language for big commercial games.
But for smaller scale games (like indie), which have less needs, I think it's 
worth it.


[1] 
http://www.scribd.com/doc/5687/The-Next-Mainstream-Programming-Language-A-Game-Developers-Perspective-by-Tim-Sweeney

2010/5/25 Peter Verswyvelen bugf...@gmail.com

Well, first of all, I did not make these PS3 visualization, my former
colleagues and I just made the editor, language and runtime that
allowed video game artists to do the job for us in a couple of weeks
time :-)

I wouldn't use Yampa, for performance reasons, and difficulty to get
it running on alien platforms (it is well known it performs relatively
badly, although the work done by Paul Liu and co on Causal Commutative
Arrows looks very promising, but does not support dynamic switching
yet). After all, Yampa models a synchronous dataflow language, and
compilers for these languages are relatively easy to make IMO.

My previous - now defunct -  company Anygma spent a lot of money on
trying to use Haskell and Reactive for game programming, which
unfortunately ended in some nasty GHC bugs popping up (see
http://www.haskell.org/haskellwiki/Unamb), and not all problems with
Reactive got fixed; it is amazing how difficult this all turned out to
be. The GHC bugs are now fixed, so it might be stable enough for
another adventure like that, but I don't think I would bet on it
again.

IMO Haskell is great for writing small clean prototypes, doing
interesting research, and maybe making some fun little games, but I
wouldn't use it for production reactive 

RE: [Haskell-cafe] Best way to instance Fix?

2010-05-24 Thread Sam Martin

That's great, thanks. Looks like FlexibleContexts is redundant (effectively a 
subset of UndecidableInstances?).

Ivan, I hadn't realised, but I had FlexibleInstances on before for other 
reasons. I guess that's why I ccould get the workaround to compile. 

Cheers,
Sam

-Original Message-
From: Reid Barton [mailto:rwbar...@math.harvard.edu]
Sent: Mon 24/05/2010 02:28
To: Sam Martin
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Best way to instance Fix?
 
On Mon, May 24, 2010 at 02:13:32AM +0100, Sam Martin wrote:
 
 Hi!
 
 I'm trying to work out the best way to generate (ideally derive) instances 
 for the Fix type. Here's a cut down example:
 
 data Greet x = AlloAllo x x | AuRevoir deriving Show
 newtype Fix f = In { out :: f (Fix f) } -- deriving Show -- DOESN'T COMPILE
 
 -- workaround
 instance Show (Fix Greet) where show (In i) = In  ++ show i
 
 In other words, given a number of parametised types that I can derive, say, 
 Ord, Eq and Show for, how should I go about getting the instances for the 
 Fix-d version of them as well? I've tried a few things, but no luck so far. 
 
 Any clues?

You can use GHC's standalone deriving mechanism for this, described at
http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/deriving.html


{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-}

data Greet x = AlloAllo x x | AuRevoir deriving Show
newtype Fix f = In { out :: f (Fix f) }

deriving instance Show (f (Fix f)) = Show (Fix f)


Regards,
Reid Barton

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


[Haskell-cafe] Best way to instance Fix?

2010-05-23 Thread Sam Martin

Hi!

I'm trying to work out the best way to generate (ideally derive) instances for 
the Fix type. Here's a cut down example:

data Greet x = AlloAllo x x | AuRevoir deriving Show
newtype Fix f = In { out :: f (Fix f) } -- deriving Show -- DOESN'T COMPILE

-- workaround
instance Show (Fix Greet) where show (In i) = In  ++ show i

In other words, given a number of parametised types that I can derive, say, 
Ord, Eq and Show for, how should I go about getting the instances for the Fix-d 
version of them as well? I've tried a few things, but no luck so far. 

Any clues?

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


Re: [Haskell-cafe] making the GHC Api not write to stderr

2010-05-20 Thread Martin Hilbig

hi,

i tried this too, but i did not get it. a very nice workaround is to use 
hint [1].


have fun
martin

[1]: http://hackage.haskell.org/package/hint

On 20.05.2010 20:05, Phyx wrote:

I was wondering how to forcibly quiet down the API. I have a custom
handler in place, but when I call the function on failure both my
handler gets called and somewhere somehow errors get printed to the
stderr, which I really need to avoid.

My current code looks like

getModInfo :: Bool - String - String - IO (ApiResults ModuleInfo)

getModInfo qual file path = handleSourceError processErrors $

runGhc (Just libdir) $ do

dflags - getSessionDynFlags

setSessionDynFlags $ configureDynFlags dflags

target - guessTarget file Nothing

addTarget target

setSessionDynFlags $ dflags { importPaths = [path] }

load LoadAllTargets

graph - depanal [] False

let modifier = moduleName . ms_mod

modName = modifier $ head graph

includes = includePaths dflags

imports = importPaths dflags

dflags' - Debug.trace (moduleNameString modName) getSessionDynFlags

setSessionDynFlags $ dflags' { includePaths = path:includes

, importPaths = path:imports

}

parsed - parse modName

checked - typecheckModule parsed



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

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


[Haskell-cafe] corner case in Text.JSON 0.4.3

2010-05-12 Thread Martin Hilbig

hi,

since i got no answer from the maintainer, maybe someone else can take 
care of it, or at least point out, what i did wrong.


so, i recently stumbled upon some error while using Text.JSON 0.4.3 [1]:

  Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case

indeed ghc warned:

  [5 of 7] Compiling Text.JSON.String ( Text/JSON/String.hs, 
dist/build/Text/JSON/String.o )


  Text/JSON/String.hs:127:4:
  Warning: Pattern match(es) are non-exhaustive
   In a case alternative: Patterns not matched: []

from looking at the code i couldn't see how this would ever happen, but 
you can reproduce it be running the files from [2]:


  $ ./test  problem
  Ok (JSArray [JSString (JSONString {fromJSString = this}),JSString 
(JSONString {fromJSString = is}),JSString (JSONString {fromJSString = 
some}),JSString (JSONString {fromJSString = json}),JSObject 
(JSONObject {fromJSObject = [(that,JSString (JSONString {fromJSString 
= works}))]})])

test: Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case

the patch i put there fixes it (at least for me) to return an Error 
instead of dying:


  $ ./test  problem
  Ok (JSArray [JSString (JSONString {fromJSString = this}),JSString 
(JSONString {fromJSString = is}),JSString (JSONString {fromJSString = 
some}),JSString (JSONString {fromJSString = json}),JSObject 
(JSONObject {fromJSObject = [(that,JSString (JSONString {fromJSString 
= works}))]})])

  Error Unexpected end of String: does
  Error Malformed JSON: invalid token in this context not\]
  test: stdin: hGetLine: end of file

have fun
martin hilbig

[1]: http://hackage.haskell.org/package/json
[2]: http://friendpaste.com/3IvnChRMoczf0mIKpOtrYE
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell and scripting

2010-05-03 Thread Martin Erwig
One of my students has worked on scripting approach in Haskell:

http://web.engr.oregonstate.edu/~erwig/papers/abstracts.html#SLE09

-- 
Martin 


On May 3, 2010, at 9:51 AM, Limestraël wrote:

 Hello Café,
 
 I don't know if you know conky. It's a well-known open-source system monitor 
 (a software that displays information on the desktop, like CPU frequency, 
 disk usage, network rate, etc.).
 It is quite good, but it's very descriptive, and even if you can call shell 
 commands it's clearly not made for being scripted.
 What I would do is to make a similar system monitor, which base would be 
 compiled Haskell code, but that would be scriptable with some DSL, or already 
 existing interpreted language.
 I've thought about a Lisp/Scheme language, since those languages are 
 functional, dynamically typed and simple (so enable a quick scripting) and 
 I'm not very keen on making my own DSL
 
 What I would like to know is:
 1) If you have other solutions
 2) How do haskellers usually script their applications
 ___
 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] Haskell and scripting

2010-05-03 Thread Martin Erwig

On May 3, 2010, at 3:45 PM, Limestraël wrote:

 Thank you all, that's very interesting.
 
 Martin, I've started reading the paper, I like the way you think about what a 
 scripting language should provide (traceability, error handling and a type 
 system).
 But, hold me if I'm wrong, but at no moment in the paper you made you own 
 language? It's a EDSL, not a DSL,

That's correct. We have defined a DSEL, but in my view this is still a DSL; the 
E only refers to a specific way of implementing it.

 so I don't see where is the scripting, since the program will always have to 
 be recompiled, won't it?

I may have misunderstood your goals and what you mean by scripting. Our DSEL 
is intended to be used for expressing all kinds of scripting tasks.


--
Martin


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


Haskell+Cassandra was: RE: [Haskell-cafe] Re: Haskell.org re-design

2010-04-06 Thread Dr . Martin Grabmüller
Maybe a bit off-topic, but as Johan mentioned the Cassandra web site...

Are there any Haskellers out there using Cassandra with Haskell?

Thanks,
  Martin

 -Original Message-
 From: haskell-cafe-boun...@haskell.org 
 [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Johan Tibell
 Sent: Tuesday, April 06, 2010 11:36 AM
 To: Simon Michael
 Cc: haskell-cafe@haskell.org
 Subject: Re: [Haskell-cafe] Re: Haskell.org re-design
 
 On Tue, Apr 6, 2010 at 5:24 AM, Simon Michael 
 si...@joyful.com wrote:
  On 4/2/10 5:28 AM, Thomas Schilling wrote:
 
  How about something more colourful?
 
  http://i.imgur.com/7jCPq.png
 
 I really like the simplicity of the Cassandra page:
 
 http://cassandra.apache.org/
 ___
 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] Haskell at Indian Universities?

2010-03-30 Thread Martin DeMello
On Tue, Mar 30, 2010 at 2:07 AM, Joachim Breitner
m...@joachim-breitner.de wrote:
 I’m a computer science student in Germany and I’d like to spend one
 semester as an exchange student in India. I have no specific plans yet
 where I want to go, and I’m wondering if there are universities in India
 where Haskell is basis for research or at least used as a tool. Haskell
 and functional programming is quite underrepresented at my university,
 so maybe this might be a good opportunity for me to combine Haskell and
 academia.

Here's a prof at IIT-Bombay who's into Haskell; you could write to him
for further suggestions.

http://www.cse.iitb.ac.in/~as

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


Re: [Haskell-cafe] Happstack basic question

2010-03-11 Thread Martin Kiefel
Hi Dmitry,

On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
 Hello haskellers,
 
 I want to host a simple happstack application behind a reverse proxy. So 
 ideally would be to bind it to localhost only.
 
 According to
 http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/Happstack-Server-HTTP-Types.html#t%3AConf
 Conf datatyle has only Port field. Does it mean, there is currently no 
 way to prevent binding happstack to all available interfaces?

I think you are looking for simpleHTTPWithSocket [1]. You can use
whatever socket you like.

 
 Regards,
 Dmitry

Cheers,
Martin

[1] 
http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.html#v%3AsimpleHTTPWithSocket
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Happstack basic question

2010-03-11 Thread Martin Kiefel
On Thu, Mar 11, 2010 at 09:24:05AM -0500, Kyle Murphy wrote:
 You misunderstand his question. He's trying to setup happstack behind a
 reverse proxy running on the same system, so he needs to be able to bind it
 only to the loopback interface (127.0.0.1), as opposed to all the interfaces
 on the system (thereby making it inaccessible from the network unless
 accessed through the proxy). I don't know enough about happstack to answer
 his question, but I can see from the documentation you provided that there
 doesn't seem to be any way to specify address to bind to as Dmitry stated in
 his original e-mail.

But I'm doing exactly that.

Here is some of the code:

main = do

  ...

  s - socket AF_INET Stream defaultProtocol
  setSocketOption s ReuseAddr 1
  h - getHostByName localhost
  let p = toEnum $ port $ httpConf appConf
  bindSocket s (SockAddrInet p (hostAddress h))
  listen s 10

  -- start the state system
  control - startSystemState' (store appConf) stateProxy

  -- start the http server
  httpTid - forkIO $ simpleHTTPWithSocket s (httpConf appConf)

  ...

And then my happstack server is just listening on 127.0.0.1.

To access it, I'm using Apache Proxy.

- Martin

 
 -R. Kyle Murphy
 --
 Curiosity was framed, Ignorance killed the cat.
 
 
 On Thu, Mar 11, 2010 at 07:39, Martin Kiefel m...@nopw.de wrote:
 
  Hi Dmitry,
 
  On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
   Hello haskellers,
  
   I want to host a simple happstack application behind a reverse proxy. So
   ideally would be to bind it to localhost only.
  
   According to
  
  http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/Happstack-Server-HTTP-Types.html#t%3AConf
   Conf datatyle has only Port field. Does it mean, there is currently no
   way to prevent binding happstack to all available interfaces?
 
  I think you are looking for simpleHTTPWithSocket [1]. You can use
  whatever socket you like.
 
  
   Regards,
   Dmitry
 
  Cheers,
  Martin
 
  [1]
  http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.html#v%3AsimpleHTTPWithSocket
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] redirecting ghc (as a library) output

2010-02-27 Thread Martin Hilbig

hi, i'm writing a Haskell View Server for CouchDB.

it communicates with couchdb over stdin and stdout. it gets JSON encoded 
haskell code, compiles it (like on 
http://www.haskell.org/haskellwiki/GHC/As_a_library), gets values, runs 
the given code over the given values and writes the results back (also 
json encoded).


when there is an error in the given haskell code it should reply with 
the error json encoded and exit. but f.e. when the given code imports a 
module, which cannot be found (here Reaction) ghc just spits out a panic 
directly to stdin and exits like this:


 ViewServer: panic! (the 'impossible' happened)
   (GHC version 6.12.1 for x86_64-unknown-linux):
 Could not find module `Reaction':
   Use -v to see a list of the files searched for.


 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

it puts other errors directly to stdout too, like:

 Assembler messages:
 Fatal error: can't create
 /home/*/AlkylRadicalDecomposition.o:
 Permission denied

this confuses couchdb, because it expects some JSON and i cant see whats 
going on between them.


now, how can i prevent ghc from using stdout and wrap the output in some 
JSON? is this even possible?


with ghc 6.10 this usage of 'handle' worked for me:

 main = handle (\e - do
let e' = show (e::SomeException)
case fromException e of
  Just UserInterrupt - exitSuccess
  _ - do
  let err = error2json the impossible happened... e'
  putStrLn err
  logToFile err
  return []) main_loop

did i got the Exception handling wrong?

thanks in advance.

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


Re: [Haskell-cafe] Re: Non-termination of type-checking

2010-01-29 Thread Martin Sulzmann
On Fri, Jan 29, 2010 at 8:56 AM, o...@okmij.org wrote:


 Here is a bit more simplified version of the example. The example has
 no value level recursion and no overt recursive types, and no impredicative
 polymorphism. The key is the observation, made earlier, that two types
c (c ()) and R (c ())
 unify when c = R. Although the GADTs R c below is not recursive, when
 we instantiate c = R, it becomes recursive, with the negative
 occurrence. The trouble is imminent.

 We reach the conclusion that an instance of a non-recursive GADT
 can be a recursive type. GADT may harbor recursion, so to speak.

 The code below, when loaded into GHCi 6.10.4, diverges on
 type-checking. It type-checks when we comment-out absurd.


 {-# LANGUAGE GADTs, EmptyDataDecls #-}

 data False  -- No constructors

 data R c where  -- Not recursive
R :: (c (c ()) - False) - R (c ())

 -- instantiate c to R, so (c (c ())) and R (c ()) coincide
 -- and we obtain a recursive type
 --mu R. (R (R ()) - False) - R (R ())

 cond_false :: R (R ()) - False
 cond_false x@(R f) = f x

 absurd :: False
 absurd = cond_false (R cond_false)


GHC (the compiler terminates)

The following variants terminate, either with GHCi or GHC,

absurd1 :: False
absurd1 = let x = (R cond_false)
  in cond_false x

absurd2 =  R cond_false

absurd3 x = cond_false x

absurd4 :: False
absurd4 = absurd3 absurd2

This suggests there's a bug in the type checker.
If i scribble down the type equation, I can't see
why the type checker should loop here.

-Martin




 ___
 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] General Advice Needed ..

2010-01-14 Thread Martin Coxall
 
 But after that im lost :(
 
 Is there any general advice? Just keep reading the book till it drills into
 my big head?

Is it that you're having difficulty knowing how you'd solve certain classes of 
problems using Haskell? You're stuck in an imperative rut?

The O'Reilly book Real World Haskell is very good for this, because as the 
name implies, it uses Haskell to solve actual engineering problems, rather than 
approach it from the theoretical angle.

Martin
___
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 Martin Coxall

On 14 Jan 2010, at 14:42, Matthias Görgens wrote:

 All Lisps have special forms which are evaluated uniquely and differently 
 from function application and are therefore reserved words by another name. 
 For example, Clojure has def, if, do, let, var, quote, fn, loop, recur, 
 throw, try, monitor-enter, monitor-exit, dot, new and set!.
 
 Yes, but the special forms are not distinguishable from user defined
 macros --- and some Lisp-implemantations special forms are another
 implementations macros.  E.g. you can choose to make `if' a macro that
 expands to `cond' or vice versa.  I do not know whether you are
 allowed to shadow the name of special-forms.
 

Clojure's a lot more 'syntaxy' than most Lisps. It has literals for large 
classes of entities that get represented as lists in most other Lisps. Which I 
guess is clearly a pragmatic design decision: be as syntax-heavy as is 
reasonably practicable without sacrificing homoiconicity and ending up like 
Dylan.

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


Re: [Haskell-cafe] Language simplicity

2010-01-13 Thread Martin Coxall

On 12 Jan 2010, at 21:25, Andrew Coppin wrote:

 OK people, it's random statistics time!
 
 Haskell '98 apparently features 25 reserved words. (Not counting forall and 
 mdo and so on, which AFAIK are not in Haskell '98.) So how does that 
 compare to other languages?
 
 C: 32
 C++: 62
 Borland Turbo Pascal: ~50 [without the OOP extensions added later]
 Eiffel: 59
 VB: The source I checked listed in excess of 120 reserved words, but I'm 
 dubious as to how reserved they really are. (Is CInt really reserved? I 
 doubt it!) It also depends wildly on which of the bazillion VB dialects you 
 mean.
 Java: 50
 JavaScript: 36
 Smalltalk: 0

There are six singleton pseudo-variables that act as reserved words: 
true,false, nil, self, super and thisContext.

 Lisp: AFAIK, there are no truly reserved words in Lisp, only predefined 
 functions. (??)

All Lisps have special forms which are evaluated uniquely and differently 
from function application and are therefore reserved words by another name. For 
example, Clojure has def, if, do, let, var, quote, fn, loop, recur, throw, try, 
monitor-enter, monitor-exit, dot, new and set!.

 Python: 31
 Ruby: 38
 Tcl: Same analysis as for Lisp I believe.

COBOL: Over 400 (!)

 
 As you can see, this conclusively proves... something.

Generally speaking, the most widely used languages seem to be near the upper 
end of the range.

I don't think it really tells you that much. Possibly that a little superficial 
complexity through syntactic sugar can make your language a lot more 
human-friendly, but that it's possible to go too far and end up like C++.

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


Re: [Haskell-cafe] Language simplicity

2010-01-13 Thread Martin Coxall

On 12 Jan 2010, at 22:22, Andrew Coppin wrote:

 Niklas Broberg wrote:
 Haskell '98 apparently features 25 reserved words. (Not counting forall
 and mdo and so on, which AFAIK are not in Haskell '98.)

 
 21 actually. case, class, data, default, deriving, do, else, if,
 import, in, infix, infixl, infixr, instance, let, module, newtype, of,
 then, type, where. There's also three special words that can still be
 used as identifiers, so aren't reserved: as, qualified, hiding.
  
 
 OK. Well the list I saw was for Haskell plus extensions, and I visually 
 filtered out the inapplicable stuff. Apparently I missed something.
 
 Also, the number varies depending on whether you consider reversed words or 
 keywords, 

Aye, there's a subtle distinction between keywords and reserved words, but I 
think for the purposes of this discussion, they're the same thing.

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


Re: [Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2010-01-13 Thread Martin Coxall

On 13 Jan 2010, at 09:51, Peter Verswyvelen wrote:

 On Sun, Nov 1, 2009 at 2:57 AM, Gregory Collins g...@gregorycollins.net 
 wrote:
 Doing OO-style programming in Haskell is difficult and unnatural, it's
 true (although technically speaking it is possible). That said, nobody's
 yet to present a convincing argument to me why Java gets a free pass for
 lacking closures and typeclasses.
 
 I might be wrong, but doesn't Java's concepts of inner classes and interfaces 
 together with adapter classes can be used to replace closures and typeclasses 
 in a way?

Inner classes are not a semantic replacement for closures, even if you discount 
horrific syntax. Inner classes do not close over their lexical environment.

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


Re: [Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2010-01-13 Thread Martin Coxall
 
 
 Anonymous classes in Java close over their lexical environment (can
 refer to variables in that lexical environment, with values bound at
 the time of instance construction) with the caveat that only local
 variables/parameters marked as 'final' may be referred to.  Aside from
 the horrible syntax, this is the key distinction between them, and,
 say, Ruby closures.  Referring to mutable variables from inside a
 closure has its drawbacks, making the horrible syntax the biggest
 stumbling block to using them IMHO (other than runtime overhead, which
 I believe is also an issue).


Yes, this. Which makes them basically unusable where you might want proper 
closures.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Restrictions on associated types for classes

2009-12-17 Thread Martin Sulzmann
The statements

class Cl [a] = Cl a

and

instance Cl a = Cl [a]

(I omit the type family constructor in the head for simplicyt)

state the same (logical) property:

For each Cl t there must exist Cl [t].

Their operational meaning is different under the dictionary-passing
translation [1].
The instance declaration says we build dictionary Cl [a] given the
dictionary Cl [a]. The super class declaration says that the dictionary for
Cl [a]
must be derivable (extractable) from Cl a's dictionary. So, here
we run into a cycle (on the level of terms as well as type inference).

However, if we'd adopt a type-passing translation [2] (similar to
dynamic method lookup in oo languages) then there isn't
necessarily a cycle (for terms and type inference). Of course,
we still have to verify the 'cyclic' property which smells like
we run into non-termination if we assume some inductive reason
(but we might be fine applying co-induction).

-Martin

[1] Cordelia V. Hall, Kevin
Hammondhttp://www.informatik.uni-trier.de/%7Eley/db/indices/a-tree/h/Hammond:Kevin.html,
Simon L. Peyton
Joneshttp://www.informatik.uni-trier.de/%7Eley/db/indices/a-tree/j/Jones:Simon_L=_Peyton.html,
Philip 
Wadlerhttp://www.informatik.uni-trier.de/%7Eley/db/indices/a-tree/w/Wadler:Philip.html:
Type Classes in Haskell. ACM Trans. Program. Lang. Syst.
18http://www.informatik.uni-trier.de/%7Eley/db/journals/toplas/toplas18.html#HallHJW96(2):
109-138 (1996)

[2] Satish R. Thatte: Semantics of Type Classes Revisited. LISP and
Functional Programming
1994http://www.informatik.uni-trier.de/%7Eley/db/conf/lfp/lfp1994.html#Thatte94:
208-219

On Thu, Dec 17, 2009 at 6:40 PM, Simon Peyton-Jones
simo...@microsoft.comwrote:

 |  Hmm.  If you have
 |class (Diff (D f)) = Diff f where
 | 
 |  then if I have
 |  f :: Diff f = ...
 |  f = e
 |  then the constraints available for discharging constraints arising
 |  from e are
 |  Diff f
 |  Diff (D f)
 |  Diff (D (D f))
 |  Diff (D (D (D f)))
 |  ...
 | 
 |  That's a lot of constraints.
 |
 | But isn't it a bit like having an instance
 |
 |Diff f = Diff (D f)

 A little bit.  And indeed, could you not provide such instances?  That is,
 every time you write an equation for D, such as
 type D (K a) = K Void
 make sure that Diff (K Void) also holds.

 The way you it, when you call f :: Diff f = blah, you are obliged to
 pass runtime evidence that (Diff f) holds.  And that runtime evidence
 includes as a sub-component runtime evidence that (Diff (D f)) holds.   If
 you like the, the evidence for Diff f looks like this:
data Diff f = MkDiff (Diff (D f)) (D f x - x - f x)
 So you are going to have to build an infinite data structure.  You can do
 that fine in Haskell, but type inference looks jolly hard.

 For example, suppose we are seeking evidence for
Diff (K ())
 We might get such evidence from either
  a) using the instance decl
 instance Diff (K a) where ...
 or
  b) using the fact that (D I) ~ K (), we need Diff I, so
we could use the instance
  instance Diff I

 Having two ways to get the evidence seems quite dodgy to me, even apart
 from the fact that I have no clue how to do type inference for it.

 Simon
 ___
 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] Hint causes GHCi linker error under Windows

2009-12-14 Thread Martin Hofmann
Hi Daniel,

 Do you have a complete example one can use to reproduce this behavior?  
 (preferably a short one! :P)

With this code I could reproduce it in ghci.

  runInterpreter $ loadModules [(SomeModule.hs, Nothing)]

Currently I am not on a Windows machine, so I can't tell you if this
only occured when trying to load a specific module. I'll try it later
and if so, I'll tell you.

If you need more information, just let me know.

Martin

  The error message is:
 
  GHCi runtime linker: fatal error: I found a duplicate definition for
  symbol _hs_gtWord64 whilst processing object file
C:\Programme\Haskell Platform\2009.2.0.2\ghc-prim-0.1.0.0
  HSghc-prim-0.1.0.o
  This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
  loaded twice.
  GHCi cannot safely continue in this situation.  Exiting now.  Sorry.
 
  The problem does not occur under Unix or with a compiled program. IMHO
  hint tries to start a second instance of GHCi which is not
  allowed/possible under Windows. If this is the case a more telling  
  error
  message would be helpful.
 
  I used the Haskell Platform, version 2009.2.0.2 under Windows XP. My
  package.conf is:
 
  C:/Programme/Haskell Platform/2009.2.0.2\package.conf:
 Cabal-1.6.0.3, GHood-0.0.3, GLUT-2.1.1.2, HTTP-4000.0.6,
 HUnit-1.2.0.3, MonadCatchIO-mtl-0.2.0.0, OpenGL-2.2.1.1,
 QuickCheck-1.2.0.0, Win32-2.2.0.0, ansi-terminal-0.5.0,
 ansi-wl-pprint-0.5.1, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0,
 bimap-0.2.4, bytestring-0.9.1.4, cgi-3001.1.7.1,
 containers-0.2.0.1, cpphs-1.9, directory-1.0.0.3, (dph-base-0.3),
 (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3),
 (dph-prim-seq-0.3), (dph-seq-0.3), extensible-exceptions-0.1.1.0,
 fgl-5.4.2.2, filepath-1.1.0.2, (ghc-6.10.4), ghc-mtl-1.0.1.0,
 ghc-paths-0.1.0.6, ghc-prim-0.1.0.0, haddock-2.4.2,
 haskeline-0.6.2.2, haskell-src-1.0.1.3, haskell-src-exts-1.3.4,
 haskell98-1.0.1.0, hint-0.3.2.1, hpc-0.5.0.3, html-1.0.1.2,
 integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1.4, old-locale-1.0.0.1,
 old-time-1.0.0.2, packedstring-0.1.0.1, parallel-1.1.0.1,
 parsec-2.1.0.1, pointless-haskell-0.0.1, pretty-1.0.1.0,
 process-1.0.1.1, random-1.0.0.1, regex-base-0.72.0.2,
 regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, stm-2.1.1.2,
 syb-0.1.0.1, template-haskell-2.3.0.1, time-1.1.2.4,
 utf8-string-0.3.6, xhtml-3000.2.0.1, zlib-0.5.0.0
 
  Thanks,
 
  Martin
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
-- 
---
Dipl.-Wirtsch.Inf. (E.M.B.Sc.) Martin Hofmann
Cognitive Systems Group
Faculty Information Systems and Applied Computer Science
University of Bamberg
http://www.cogsys.wiai.uni-bamberg.de/members/hofmann 
http://www.inductive-programming.org
   

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


Re: [Haskell-cafe] Hint causes GHCi linker error under Windows

2009-12-14 Thread Martin Hofmann
The following module reproduces the error when loaded into ghci and main
is executed under Windows. It works fine when compiled.

\begin{code}

module Main where
 
import Language.Haskell.Interpreter

main = putStrLn File to load:   getLine = erroneousLoad

erroneousLoad :: FilePath - IO ()
erroneousLoad f = do
ok - runInterpreter $ loadModules [f]
case ok of
Right _  - return ()
Left e   - fail (show e)

\end{code}
 
However in my current program I also encounter strange behaviour when
executing compiled code. I use 'haskeline' for a REP-loop. The user
input is parsed and passed to a function similar to 'erroneousLoad'.

When I type the path character by character, or when start with an empty
line by pressing return, again everything works fine. When I use the
completion function of 'haskeline' the program crashes with a
segmentation fault.

Changing the runInterpreter line to

trace (XXX  ++ (show f)) $ runInterpreter $ trace YYY $ loadModules 
$ trace ZZZ [f]

I get the following output:

XXX explExamples.hs
Igor2.exe: internal error: evacuate(static): strange closure type 1094
(GHC version 6.10.4 for i386_unknown_mingw32)
Please report this as a GHC bug:  
http://www.haskell.org/ghc/reportabug

This application has requested the Runtime to terminate it in an 
unusual way,
Please contact the application's support team for more information.

Sometimes I get different types of the 'strange closure', e.g. 17408 or others.

I was not able to reproduce those errors on a smaller example than my
whole program. Under Linux none of those errors occurs.

Cheers,

Martin

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


[Haskell-cafe] Hint causes GHCi linker error under Windows

2009-12-11 Thread Martin Hofmann
The following hint code causes GHCi to crash under Windows:

  runInterpreter $ loadModules [SomeModule.hs]

The error message is: 

GHCi runtime linker: fatal error: I found a duplicate definition for
symbol _hs_gtWord64 whilst processing object file
   C:\Programme\Haskell Platform\2009.2.0.2\ghc-prim-0.1.0.0
HSghc-prim-0.1.0.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
 loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.

The problem does not occur under Unix or with a compiled program. IMHO
hint tries to start a second instance of GHCi which is not
allowed/possible under Windows. If this is the case a more telling error
message would be helpful.

I used the Haskell Platform, version 2009.2.0.2 under Windows XP. My
package.conf is:

C:/Programme/Haskell Platform/2009.2.0.2\package.conf:
Cabal-1.6.0.3, GHood-0.0.3, GLUT-2.1.1.2, HTTP-4000.0.6,
HUnit-1.2.0.3, MonadCatchIO-mtl-0.2.0.0, OpenGL-2.2.1.1,
QuickCheck-1.2.0.0, Win32-2.2.0.0, ansi-terminal-0.5.0,
ansi-wl-pprint-0.5.1, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0,
bimap-0.2.4, bytestring-0.9.1.4, cgi-3001.1.7.1,
containers-0.2.0.1, cpphs-1.9, directory-1.0.0.3, (dph-base-0.3),
(dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3),
(dph-prim-seq-0.3), (dph-seq-0.3), extensible-exceptions-0.1.1.0,
fgl-5.4.2.2, filepath-1.1.0.2, (ghc-6.10.4), ghc-mtl-1.0.1.0,
ghc-paths-0.1.0.6, ghc-prim-0.1.0.0, haddock-2.4.2,
haskeline-0.6.2.2, haskell-src-1.0.1.3, haskell-src-exts-1.3.4,
haskell98-1.0.1.0, hint-0.3.2.1, hpc-0.5.0.3, html-1.0.1.2,
integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1.4, old-locale-1.0.0.1,
old-time-1.0.0.2, packedstring-0.1.0.1, parallel-1.1.0.1,
parsec-2.1.0.1, pointless-haskell-0.0.1, pretty-1.0.1.0,
process-1.0.1.1, random-1.0.0.1, regex-base-0.72.0.2,
regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, stm-2.1.1.2,
syb-0.1.0.1, template-haskell-2.3.0.1, time-1.1.2.4,
utf8-string-0.3.6, xhtml-3000.2.0.1, zlib-0.5.0.0

Thanks,

Martin

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


Re: [Haskell-cafe] Idea for a very simple GUI llibrary

2009-11-23 Thread Martin DeMello
Has there been real world adoption of any of these, in the shape of
a moderately complex end-user application that is not just a library
demo?

martin

On Mon, Nov 23, 2009 at 8:48 AM, Keith Holman hol...@gmail.com wrote:
 You should also check out Fudgets and Tangible Functional
 Programming. Fudgets is a really old Haskell UI library concept;
 Tangible FP is a recent Google talk about a UI library inspired by
 Haskell types.

 2009/11/22 Luke Palmer lrpal...@gmail.com:
 Nice idea.  I will try it if you write runGUI :-)

 This is an imperative style library.  For more Haskellian GUI library
 ideas, see Fruit (http://www.haskell.org/fruit/) and TVs
 (http://www.haskell.org/haskellwiki/TV).  They may not pass the
 builds constraint :-P

 Luke

 2009/11/22 Maurí­cio CA mauricio.antu...@gmail.com:
 Hi,

 Here is a sketch for a library with these properties:

 - Easy to test. All Haskell code can be tested in a text
 terminal. Also, testing code that uses the library can also be
 done without using a GUI.

 - Extremely easy to document and use.

 - Not even close to Gtk2hs power, but enough for small
 applications.

 - Could be the first GUI to build on hackage :)

 What we need is:

 - MyState. A user suplied type for application state.

 - WidId. A user suplied type for widget identifiers.

 - Gui wi. A type capable of describing an interface with all of
 its state. It's an instance of Eq.

 - Event wi. A type for events.

 - Prop. A type for properties than can related to a WidId.

 Running an application would be like this:

 main = runGUI
        initState  -- An initial MyState.
        event      -- :: MyState - DiffTime - Event WidId - MyState
        props      -- :: WidId - [Prop]
        action     -- :: MyState - DiffTime - IO (Maybe (MyState,Gui
 WidId))
        timeout    -- :: DiffTime

 DiffTime parameters for callbacks are always the time elapsed
 since application started.

 From initState and event, the implementation of runGUI can save a
 state that optionally changes with time.

 From props, it can get details on what to present in widgets
 associated with a WidId (selected state, picture to draw etc.).

 action presents a chance for using IO, and optionally change state
 and GUI description.

 timeout is the maximum time runGUI implementation is allowed to
 wait between calls to action.

 Examples for those types:

 newtype MyState = {
    lastUpdate :: DiffTime,
    builtGui :: Bool,
    earthCoordinates :: (Double,Double),
    map :: SVG,
    ...
  }

 data WidId = XCoord | YCoord | MapWindow | ReloadButton ...

 data Gui widid = TitleWindow (Gui widid)
      | Tabs [(String,Gui widid)]
      | PressButton String widid
      | Selection [String] widid
      | ...
  deriving Eq
   {-
      Eq is needed by runGUI to detect if GUI has
      changed after the last call to action.
   -}

 data Event widid = ButtonPressed widid
      | FileSelected String widid
      | OptionSelected String widid
      | ...

 data Prop widid = Active Bool
      | Text String
      | Draw SVG
      | ...

 I believe this can represent most kinds of simple applications,
 and be efficient enough for practical use.

 It's interesting that all of this can be designed, implemented and
 tested independent of runGUI implementation. Actually, if you want
 a pet project and want to write and design the Haskell part, I may
 probably be able to write runGUI for you :)

 Best,
 Maurício

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

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

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

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


RE: [Haskell-cafe] Re: Idea for a very simple GUI llibrary

2009-11-23 Thread Sam Martin

Thinking of a parallel with Java for a second, is there a GUI library out there 
that's structured like Java Swing? Meaning, there is a GUI library that has a 
small platform-specific GUI foundation (e.g. a per platform implementation of 
the core AWT functionality) and the rest of the functionality is pure haskell?

Supporting cross platform guis is often a bit ... complicated. Java attempted 
to resolve their debug-everywhere nightmare with AWT by making the per-platform 
bit as small as possible, and building everything else in Java.

I guess in theory gtk and wxWidgets take on this support burden, but you do get 
some fairly hefty imperative apis as a result. Perhaps it would make sense to 
focus efforts on stabilising a small 'core gui' library that can act as the 
foundation stone for all manner of pure haskell gui libraries?*

Or perhaps this already exists?

Just a thought.

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


Re: [Haskell-cafe] Graph drawing library for Haskell

2009-11-22 Thread Martin DeMello
On Fri, Nov 20, 2009 at 9:36 PM, Victor Mateus Oliveira
rhapso...@gmail.com wrote:
 I'm looking for something more integrated with a gui library. The
 jgraph integrates with swing, so you can move, create, delete, have
 popup menus, select nodes, and so on.

 I haven't found yet.. If there isn't, I thinking in create one lib
 with wxHaskell using wxDC... But by now, I really prefer to use one
 existing library.

Blobs [http://www.cs.york.ac.uk/fp/darcs/Blobs/] might be a better
starting point than implementing from scratch on wxdc

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


RE: [Haskell-cafe] Cabal upload issue

2009-11-12 Thread Sam Martin
Although it might be a pain in the arse to some degree, is there any
reason why 'base' is considered special? 

As an example, I've come across a fair number of libraries/apps that
(presumably) compile against a previous version of OpenGL, but not the
current latest. Given it's impossible to test any package against
libraries that don't yet exist, shouldn't the upper bound be required
for all package dependencies?

Just curious. :)

ta,
Sam

-Original Message-
From: haskell-cafe-boun...@haskell.org
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Neil Brown
Sent: 12 November 2009 14:36
To: Jeremy O'Donoghue
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Cabal upload issue

Jeremy O'Donoghue wrote:
 Hi all,

 I'm in the process of trying update the revisions of wx (part of
 wxHaskell) on hackage.

 I'm getting an error I find slightly surprising:
 ...
 Library
 if flag(splitBase)
 build-depends: base = 3, wxcore = 0.12.1.1, stm
   
Change this last line to base = 3   5 to get rid of the warning.  I 
think the idea is that if base becomes version 5, it will likely break 
your code, so you should specify ahead of time that this library isn't 
currently designed to work with a version of base beyond 4.  That way 
when someone installs your package in the future and you haven't tested 
with base 5, cabal will know to use base 4 for your library.

Thanks,

Neil.
___
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] Problems with Language.Haskell.Interpreter and errors

2009-11-11 Thread Martin Hofmann
I still have problems and your code won't typecheck on my machine
printing the following error:

Test.hs:9:34:
No instance for (Control.Monad.CatchIO.MonadCatchIO
   (InterpreterT IO))
  arising from a use of `catch' at Test.hs:9:34-53
Possible fix:
  add an instance declaration for
  (Control.Monad.CatchIO.MonadCatchIO (InterpreterT IO))
In the first argument of `runInterpreter', namely
`(code `catch` handler)'
In the second argument of `(=)', namely
`(runInterpreter (code `catch` handler))'
In the expression:
  print = (runInterpreter (code `catch` handler))


I assume we are using different versions of some packages. Could you
please send me the output of your 'ghc-pkg list'.

Thanks,

Martin

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


Re: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors

2009-11-11 Thread Martin Hofmann
Thanks,

using MonadCatchIO-mtl-0.2.0.0 and hint-0.3.2.0 did it.



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


Re: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors

2009-11-10 Thread Martin Hofmann

Although late, still very much appreciated. Thanks a lot!

Cheers,

Martin

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


Re: [Haskell-cafe] What's the deal with Clean?

2009-11-04 Thread Martin DeMello
On Wed, Nov 4, 2009 at 10:34 AM, Richard O'Keefe o...@cs.otago.ac.nz wrote:
 (4) It comes with its own IDE.  I don't think it can do anything much that
    Haskell tools can't do, but if you don't like looking for things, it's
    a help.

And a well-integrated GUI toolkit. If it weren't for the Windows bias
I'd have definitely taken the time to learn the language.

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


[Haskell-cafe] Re:

2009-10-14 Thread Martin Sulzmann
On Wed, Oct 14, 2009 at 7:33 AM, o...@okmij.org wrote:


 Martin Sulzmann wrote:
  Undecidable instances means that there exists a program for which
 there's
  an infinite reduction sequence.

 I believe this may be too strong of a statement. There exists patently
 terminating type families that still require undecidable
 instances in GHC.


Sorry, I wasn't precise enough.

I didn't mean to say that *every* program which requires undecidable
instance won't terminate.

Rather, take any of the properties which imply decidability. Then,
there *exists* a program which satisfies the negated property and this
program won't terminate.

As you show, for specific cases we can argue that undecidable instances
are decidable. You can even argue that the Add/Mult example is decidable,
assuming we never generate loopy type constraints.

-Martin


 Here is an example:

  {-# LANGUAGE TypeFamilies #-}
 
  type family I x :: *
  type instance I x = x
 
  type family B x :: *
  type instance B x = I x


 GHC 6.8.3 complaints:
Application is no smaller than the instance head
  in the type family application: I x
(Use -fallow-undecidable-instances to permit this)
In the type synonym instance declaration for `B'

 But there cannot possibly be any diverging reduction sequence here, can it?
 The type family I is the identity, and the type family B is its
 alias. There is no recursion. The fact that type families are open is
 not relevant here: our type families I and B are effectively closed,
 because one cannot define any more instance for I and B (or risk
 overlap, which is rightfully not supported for type families).

 The reason GHC complains is because it checks termination
 instance-by-instance. To see the termination in the above program, one
 should consider instances I and B together. Then we will see that I
 does not refer to B, so there are no loops. But this global
 termination check -- for a set of instances -- is beyond the
 abilities of GHC. This is arguably the right decision: after all, GHCi
 is not a full-blown theorem prover.

 Thus there are perfectly decidable type programs that require
 undecidable instances. Indeed, there is no reason to be afraid of that
 extension.

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


Re: [Haskell-cafe] Type-level naturals multiplication

2009-10-13 Thread Martin Sulzmann
On Tue, Oct 13, 2009 at 9:37 AM, Simon Peyton-Jones
simo...@microsoft.comwrote:

 |  Is there any way to define type-level multiplication without requiring
 |  undecidable instances?
 |
 | No, not at the moment.  The reasons are explained in the paper Type
 | Checking with Open Type Functions (ICFP'08):
 |
 |
 http://www.cse.unsw.edu.au/~chak/papers/tc-tfs.pdfhttp://www.cse.unsw.edu.au/%7Echak/papers/tc-tfs.pdf
 |
 | We want to eventually add closed *type families* to the system (ie,
 | families where you can't add new instances in other modules).  For
 | such closed families, we should be able to admit more complex
 | instances without requiring undecidable instances.

 It's also worth noting that while undecidable instances sound scary, but
 all it means is that the type checker can't prove that type inference will
 terminate.  We accept this lack-of-guarantee for the programs we *run*, and
 type inference can (worst case) take exponential time which is not so
 different from failing to terminate; so risking non-termination in type
 inference is arguably not so bad.



Some further details to shed some light on this topic.

Undecidable instances means that there exists a program for which there's
an infinite reduction sequence.
By undecidable I refer to instances violating the conditions in the
icfp'08
and in the earlier jfp paper Understanding Functional Dependencies via
Constraint Handling Rules.

Consider the classic example

  Add (Succ x) x ~ x
-- Succ (Add x x) ~ x

 substitute for x and you'll get another redex of the form

 Add (Succ ..) ... and therefore the reduction won't terminate

To fix this problem, i.e. preventing the type checker to non-terminate,
we could either

 (a) spot the loop in Add (Succ x) x ~ x  and reject this
   unsatisfiable constraint and thus the program
 (b) simply stop after n steps

The ad-hoc approach (b) restores termination but risks incompleteness.

Approach (a) is non-trivial to get right, there are more complicated loopy
programs
where spotting the loops gets really tricky.

The bottom line is this:

Running the type checker on undecidable instances means that
there are programs for which

   - the type checker won't terminate, or
- wrongly rejects the program (incompleteness)

So, the situation is slightly more scary, BUT
programs exhibiting the above behavior are (in my experience)
rare/contrived.

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


  1   2   3   4   >