Re: [Haskell-cafe] Handling absent maintainers

2010-07-24 Thread Roman Beslik
 I patch broken packages in my local repository. I increment a version 
so the local repository get a precedence over the Hackage.


On 16.07.10 03:54, Mark Wotton wrote:

2. run my own hackage server and tell my users to use that instead.


--
Best regards,
  Roman Beslik.

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


[Haskell-cafe] a patch for base.Foreign.C.String, the current locale

2010-07-24 Thread Roman Beslik
 Hi. I have composed a patch that implements Foreign.C.String according 
to Foreign Function Interface Addendum, i.e. C strings are treated as 
they are encoded with the current locale. Search Locale.hs in the 
patch for further directions. Ask if you do not know how to build a 
patched version of the base library.

http://www.beroal.in.ua/prg/haskell/locale.patch

--
Best regards,
  Roman Beslik.

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


Re: [Haskell-cafe] Handling absent maintainers

2010-07-24 Thread Mark Wotton
That works fine for my own stuff, but I'd like it to work for people
using my software that relies on those packages.

mark

On Sat, Jul 24, 2010 at 4:10 PM, Roman Beslik ber...@ukr.net wrote:
  I patch broken packages in my local repository. I increment a version so
 the local repository get a precedence over the Hackage.

 On 16.07.10 03:54, Mark Wotton wrote:

 2. run my own hackage server and tell my users to use that instead.

 --
 Best regards,
  Roman Beslik.





-- 
A UNIX signature isn't a return address, it's the ASCII equivalent of a
black velvet clown painting. It's a rectangle of carets surrounding a
quote from a literary giant of weeniedom like Heinlein or Dr. Who.
        -- Chris Maeda
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Handling absent maintainers

2010-07-24 Thread Alexander Dunlap
One issue that comes up is that when you fork a package, data can no
longer be freely exchanged between libraries using the original
package's datatypes and libraries using the forked package's
datatypes. Something that might help here is the concept of
extension or friend packages or modules: packages or modules that
could break through to access concrete representations of abstract
datatypes or classes. The advantage would be that in many cases,
instead of forking a package, you could make the necessary changes
through a tightly-coupled but separately-maintained friend package
while still maintaining compatibility with the original package.

This wouldn't help for the problem of maintaining a package that
wouldn't compile. That might be helped by something like a provides
or equivalent field, where Cabal could be informed that a new
package should be treated as satisfying a dependency on a different
package.

Alex

On Fri, Jul 23, 2010 at 11:36 PM, Mark Wotton mwot...@gmail.com wrote:
 That works fine for my own stuff, but I'd like it to work for people
 using my software that relies on those packages.

 mark

 On Sat, Jul 24, 2010 at 4:10 PM, Roman Beslik ber...@ukr.net wrote:
  I patch broken packages in my local repository. I increment a version so
 the local repository get a precedence over the Hackage.

 On 16.07.10 03:54, Mark Wotton wrote:

 2. run my own hackage server and tell my users to use that instead.

 --
 Best regards,
  Roman Beslik.





 --
 A UNIX signature isn't a return address, it's the ASCII equivalent of a
 black velvet clown painting. It's a rectangle of carets surrounding a
 quote from a literary giant of weeniedom like Heinlein or Dr. Who.
         -- Chris Maeda
 ___
 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] Anyone here from New Zealand?

2010-07-24 Thread Hamish Mackenzie
On 24 Jul 2010, at 02:15, Tim Matthews wrote:

 Any of the haskellers here from NZ?

I am in Wellington, Stephen is near Palmerston North. There are a few others 
elsewhere I think.

 Are you using haskell in production, internally within your company or just 
 outside of work in your own time?

I work on Leksah in my spare time.

 In Aus they've got hackathons and user groups. Anything even remotely similar 
 here in New Zealand?

The last couple of times I have visited my parents in (who live in Palmerston 
North), Stephen and I have got together for what we jokingly refer to as NZHac 
or the NZHUG. Our next trip to Palmy will be late August I think.

There is an Erlang users group here in Wellington (organised by Lenz) and I 
attend when I can, there has not been a meeting in some time.  It's really more 
of a FP group in a way as others that attending are not all Erlang users (but 
most use or would like to use a functional language of some sort).  I think if 
we changed the name to the Wellington FP Users Group or something we might get 
more interest (especially if we catered to people interested in learning Scala 
and F#).

Hamish


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


[Haskell-cafe] Re: ANNOUNCE: Haskell Platform 2010.2.0.0

2010-07-24 Thread Benjamin L. Russell
Don Stewart d...@galois.com writes:

 We're pleased to announce the fifth release of the Haskell Platform: a
 single, standard Haskell distribution for everyone.

 Download the Haskell Platform 2010.2.0.0:

 http://hackage.haskell.org.nyud.net/platform/

 (Caching server).

 The specification, along with installers (including Windows, Apple and
 Unix installers for a full Haskell environment) are available.
 
 [snip]

Just out of curiosity, is the MacPorts version of the Haskell Platform
compatible with Mac OS X 10.5.8 Leopard on the PowerPC architecture (as
opposed to the Intel one)?

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. -- Matsuo Basho^ 

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


[Haskell-cafe] build and use ghc's rts without a full unregistered ghc port?

2010-07-24 Thread Korcan Hussein

Hi, I was just wondering if this is possible, I would like to use a gcc port
which cross compiles to the PPC architecture (Wii DevkitPPC to be specifically:
http://wiibrew.org/wiki/DevkitPPC) for a platform that is not POSIX compatible I
believe (at least not fully or maybe I'm wrong entirely).

Ideally I would make an unregistered port of GHC but the problem is because GHC
doesn't support true cross compiling yet I need to bootstrap on to the target
machine, which isn't running a POSIX environment.

Still I did try to attempt to build with both the host and target set to
'powerpc-unknown-linux' and build it with devkitPPC, I did use a custom build.mk
which should pull in all the required dependencies, defines, etc for devkitPPC.

In the end I didn't get very far with it, it looked like missing posix 
functions.

I didn't want to spend to much time trying to make it work this way (maybe i'm
doing it wrong completely). It's quite possible that I could make this work more
easily if I used a linux port for the wii but I would like to avoid the need of
using linux on the wii because I guess most home-brew users don't have such a 
setup.

So I thought maybe it's possible with less effort to build GHC's RTS and then
compile Haskell in C with the RTS as a library dependency. Is this possible?
maybe I'm missing something or doing something stupid?

Thanks in advance.
  
_
http://clk.atdmt.com/UKM/go/19780/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
now___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] build and use ghc's rts without a full unregistered ghc port?

2010-07-24 Thread Mark Wotton
can't speak as to how difficult it is to get GHC built unregisterised,
but you might want to consider JHC if you don't need to use a lot of
Hackage. It compiles to C without a special RTS needed, which might
make it a lot easier.

mark

On Sat, Jul 24, 2010 at 8:45 PM, Korcan Hussein korca...@hotmail.com wrote:

 Hi, I was just wondering if this is possible, I would like to use a gcc port
 which cross compiles to the PPC architecture (Wii DevkitPPC to be 
 specifically:
 http://wiibrew.org/wiki/DevkitPPC) for a platform that is not POSIX 
 compatible I
 believe (at least not fully or maybe I'm wrong entirely).

 Ideally I would make an unregistered port of GHC but the problem is because 
 GHC
 doesn't support true cross compiling yet I need to bootstrap on to the target
 machine, which isn't running a POSIX environment.

 Still I did try to attempt to build with both the host and target set to
 'powerpc-unknown-linux' and build it with devkitPPC, I did use a custom 
 build.mk
 which should pull in all the required dependencies, defines, etc for 
 devkitPPC.

 In the end I didn't get very far with it, it looked like missing posix 
 functions.

 I didn't want to spend to much time trying to make it work this way (maybe i'm
 doing it wrong completely). It's quite possible that I could make this work 
 more
 easily if I used a linux port for the wii but I would like to avoid the need 
 of
 using linux on the wii because I guess most home-brew users don't have such a 
 setup.

 So I thought maybe it's possible with less effort to build GHC's RTS and then
 compile Haskell in C with the RTS as a library dependency. Is this possible?
 maybe I'm missing something or doing something stupid?

 Thanks in advance.

 _
 http://clk.atdmt.com/UKM/go/19780/direct/01/
 We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
 now___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
A UNIX signature isn't a return address, it's the ASCII equivalent of a
black velvet clown painting. It's a rectangle of carets surrounding a
quote from a literary giant of weeniedom like Heinlein or Dr. Who.
        -- Chris Maeda
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Weird behavior with arrow commands

2010-07-24 Thread Jürgen Doser
El vie, 23-07-2010 a las 23:27 -0400, Ronald Guida escribió:
 I am trying to figure out how to use GHC's arrow commands, and I found
 some extremely weird behavior.

CC'ed to ghc-users, because this may be a ghc bug.

 In GHC's manual, there is a description of arrow commands, which I
 don't really understand.
 http://www.haskell.org/ghc/docs/latest/html/users_guide/arrow-notation.html#id667303
 (Primitive Constructs)
 
 I have two questions:
 1. What are arrow commands supposed to do?
 2. What is this code supposed to do?
 
 -- start of code --
 
 {-# LANGUAGE Arrows #-}
 module Main where
 
 import Control.Arrow
 
 foo :: (b - String) - b, Int), Float), Double) - String) - (b - 
 String)
 foo f g b = f b ++   ++ g (((b, 8), 1.0), 6.0)
 
 bar :: (t - String) - ((Double, Int) - String) - t - String
 bar f g  = proc x - do
   (f - x) `foo` \n m - g - (n)
 
 main = do
   putStrLn $ foo show show 17
   putStrLn $ bar show show 17
   putStrLn $ foo show show 42
   putStrLn $ bar show show 42
 
 -- end of code --
 
 Output from GHCi:
 
 17 (((17,8),1.0),6.0)
 17 (6.730326920298707e-306,0)
 42 (((42,8),1.0),6.0)
 42 (6.730326920298707e-306,0)
 
 Output after compiling with GHC:
 
 17 (((17,8),1.0),6.0)
 17 (5.858736684536801e-270,0)
 42 (((42,8),1.0),6.0)
 42 (5.858736684536801e-270,0)
 
 GHC Version:
 The Glorious Glasgow Haskell Compilation System, version 6.12.3


This seems to be a bug in ghc. First, let's fix bar to give the full
three arguments (Int, Float, Double)  to g:

bar f g  = proc x - do
  (f - x) `foo` (\n m k - g - (n,m,k))

ghc infers the type:

bar :: (t - String) - ((Double, Float, Int) - String) - t - String

and we see that the argument order in the second argument to bar is
reversed. But the arguments are still given to bar in the order (Int,
Float, Double). For example, the 6.0 in foo is interpreted as an Int and
outputs a 0 (the first 32 bits in such a small double are zeros).
When one varies the numbers in foo, one can see the effects in bar. Can
someone from GHC HQ confirm my understanding, or is this just not
supposed to work with multiple arguments?

Jürgen


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


Re: [Haskell-cafe] Weird behavior with arrow commands

2010-07-24 Thread Ross Paterson
On Sat, Jul 24, 2010 at 01:10:56PM +0200, Jürgen Doser wrote:
 This seems to be a bug in ghc. First, let's fix bar to give the full
 three arguments (Int, Float, Double)  to g:
 
 bar f g  = proc x - do
   (f - x) `foo` (\n m k - g - (n,m,k))
 
 ghc infers the type:
 
 bar :: (t - String) - ((Double, Float, Int) - String) - t - String
 
 and we see that the argument order in the second argument to bar is
 reversed. But the arguments are still given to bar in the order (Int,
 Float, Double). For example, the 6.0 in foo is interpreted as an Int and
 outputs a 0 (the first 32 bits in such a small double are zeros).
 When one varies the numbers in foo, one can see the effects in bar. Can
 someone from GHC HQ confirm my understanding, or is this just not
 supposed to work with multiple arguments?

You're right: it's getting the argument order wrong, so -dcore-lint
fails on this example and all bets are off.  Definitely a bug.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Immanuel Normann
Hi,

I have a problem with the data constructor NodeMap
Data.Graph.Inductive.NodeMap
of the graph library fgl-5.4.2.3 (also fgl-5.4.2.2):

I cannot access the data constructor NodeMap, as the ghci session shows:

Prelude :m Data.Graph.Inductive.NodeMap
Prelude Data.Graph.Inductive.NodeMap :t NodeMap

interactive:1:0: Not in scope: data constructor `NodeMap'


However, when I load the source directly it works:

Prelude :l Data/Graph/Inductive/NodeMap.hs
[1 of 3] Compiling Data.Graph.Inductive.Graph (
Data/Graph/Inductive/Graph.hs, interpreted )
[2 of 3] Compiling Data.Graph.Inductive.Internal.FiniteMap (
Data/Graph/Inductive/Internal/FiniteMap.hs, interpreted )
[3 of 3] Compiling Data.Graph.Inductive.NodeMap (
Data/Graph/Inductive/NodeMap.hs, interpreted )
Ok, modules loaded: Data.Graph.Inductive.Internal.FiniteMap,
Data.Graph.Inductive.Graph, Data.Graph.Inductive.NodeMap.
*Data.Graph.Inductive.NodeMap :t NodeMap
NodeMap :: (Ord a) = FiniteMap a Node - Int - NodeMap a

Why is that so?

Afterall, my purpose is to get access to the map in a NodeMap and finally to
apply lookup to it. But I don't know how to access the map from a NodeMap
(the map selector isn't accessible either).

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


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Ivan Lazar Miljenovic
Immanuel Normann immanuel.norm...@googlemail.com writes:

 Hi,

 I have a problem with the data constructor NodeMap
 Data.Graph.Inductive.NodeMap
 of the graph library fgl-5.4.2.3 (also fgl-5.4.2.2):

 I cannot access the data constructor NodeMap, as the ghci session shows:

 Prelude :m Data.Graph.Inductive.NodeMap
 Prelude Data.Graph.Inductive.NodeMap :t NodeMap

 interactive:1:0: Not in scope: data constructor `NodeMap'

Well, yes, because you're not meant to.

 However, when I load the source directly it works:

 Prelude :l Data/Graph/Inductive/NodeMap.hs
 [1 of 3] Compiling Data.Graph.Inductive.Graph (
 Data/Graph/Inductive/Graph.hs, interpreted )
 [2 of 3] Compiling Data.Graph.Inductive.Internal.FiniteMap (
 Data/Graph/Inductive/Internal/FiniteMap.hs, interpreted )
 [3 of 3] Compiling Data.Graph.Inductive.NodeMap (
 Data/Graph/Inductive/NodeMap.hs, interpreted )
 Ok, modules loaded: Data.Graph.Inductive.Internal.FiniteMap,
 Data.Graph.Inductive.Graph, Data.Graph.Inductive.NodeMap.
 *Data.Graph.Inductive.NodeMap :t NodeMap
 NodeMap :: (Ord a) = FiniteMap a Node - Int - NodeMap a

 Why is that so?

This works because you're using ghci from within the module, whereas
when you import it you're using only its exposed API.

 Afterall, my purpose is to get access to the map in a NodeMap and finally to
 apply lookup to it. But I don't know how to access the map from a NodeMap
 (the map selector isn't accessible either).

You're not meant to; the point of NodeMap is to serve as a wrapper
around the normal graph types, not for you to use directly (exactly the
same as why the constructor for Map isn't exported).

May I ask, however, why you want to use Data.Graph.Inductive.NodeMap?

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Ivan Lazar Miljenovic
CC-ing haskell-cafe again:

Immanuel Normann immanuel.norm...@googlemail.com writes:

 2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

 Immanuel Normann immanuel.norm...@googlemail.com writes:
  Afterall, my purpose is to get access to the map in a NodeMap and finally
 to
  apply lookup to it. But I don't know how to access the map from a NodeMap
  (the map selector isn't accessible either).

 You're not meant to; the point of NodeMap is to serve as a wrapper
 around the normal graph types, not for you to use directly (exactly the
 same as why the constructor for Map isn't exported).

 May I ask, however, why you want to use Data.Graph.Inductive.NodeMap?


 Some of my lnodes in the graph have by construction unique labels and I want
 to lookup the lnode from a graph given only the label of that lnode.

Well, from my understanding NodeMap doesn't do what you want, since it
assumes that _all_ of the node labels are unique.  Furthemore, the way
of using it seems to be analogous of how one would use a State monad
rather than for actual interactive use throughout.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Ivan Lazar Miljenovic
Once again cc-ing -cafe; Immanuel, can you please do reply to all
rather than just reply in GMail? :p

Immanuel Normann immanuel.norm...@googlemail.com writes:

 2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

 CC-ing haskell-cafe again:

 Immanuel Normann immanuel.norm...@googlemail.com writes:

  2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

  Some of my lnodes in the graph have by construction unique labels and I
 want
  to lookup the lnode from a graph given only the label of that lnode.

 Well, from my understanding NodeMap doesn't do what you want, since it
 assumes that _all_ of the node labels are unique


 I wouldn't bother when NodeMap maps also non-unique labels to single nodes,
 because I only lookup nodes with unique labels, e.g. assume my label are of
 the form
 data Label = Unique String | Multi Label

I'm of the suspicion that using NodeMaps in this fashion will have
problem when considering nodes with the same label (even if you don't
explicitly use it for those nodes), as NodeMap seems to assume that node
labels are unique.

For example, mkNode assumes node labels are unique.

 Furthemore, the way of using it seems to be analogous of how one would use a
 State monad
 rather than for actual interactive use throughout.


 Could you elaborate this further, please.

http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun
and
http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun_

If you just want a mapping from labels to nodes, you may be better off
using your own custom Map (and maybe even defining a new graph type that
has such a Map as part of it).

The successor to FGL-5.x (whatever we'll end up calling it) will allow
you to have custom node types rather than using Ints.  However, this
will not work for you in this situation.

The node type is just an _index_ type, analogous to the actual hash
value in a hash{map,array} (as opposed to the value which has the
hashing function applied upon it).  It's there to provide a unique
identifier for a particular node.  Arguably, an abstract type would be
even better as an Int as it will prevent you from doing silly things
like adding node indices together, but that's beside the point.

If you wish to find a node with a specific label, try using something
like gsel: 
http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-Basic.html#v%3Agsel

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Immanuel Normann
2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

 Once again cc-ing -cafe; Immanuel, can you please do reply to all
 rather than just reply in GMail? :p


Oh, yes I forgot - sorry!

Thanks for all the valuable infos :-)

Immanuel


 Immanuel Normann immanuel.norm...@googlemail.com writes:

  2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
 
  CC-ing haskell-cafe again:
 
  Immanuel Normann immanuel.norm...@googlemail.com writes:
 
   2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
 
   Some of my lnodes in the graph have by construction unique labels and
 I
  want
   to lookup the lnode from a graph given only the label of that lnode.
 
  Well, from my understanding NodeMap doesn't do what you want, since it
  assumes that _all_ of the node labels are unique
 
 
  I wouldn't bother when NodeMap maps also non-unique labels to single
 nodes,
  because I only lookup nodes with unique labels, e.g. assume my label are
 of
  the form
  data Label = Unique String | Multi Label

 I'm of the suspicion that using NodeMaps in this fashion will have
 problem when considering nodes with the same label (even if you don't
 explicitly use it for those nodes), as NodeMap seems to assume that node
 labels are unique.

 For example, mkNode assumes node labels are unique.

  Furthemore, the way of using it seems to be analogous of how one would
 use a
  State monad
  rather than for actual interactive use throughout.
 
 
  Could you elaborate this further, please.


 http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun
 and

 http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun_

 If you just want a mapping from labels to nodes, you may be better off
 using your own custom Map (and maybe even defining a new graph type that
 has such a Map as part of it).

 The successor to FGL-5.x (whatever we'll end up calling it) will allow
 you to have custom node types rather than using Ints.  However, this
 will not work for you in this situation.

 The node type is just an _index_ type, analogous to the actual hash
 value in a hash{map,array} (as opposed to the value which has the
 hashing function applied upon it).  It's there to provide a unique
 identifier for a particular node.  Arguably, an abstract type would be
 even better as an Int as it will prevent you from doing silly things
 like adding node indices together, but that's beside the point.

 If you wish to find a node with a specific label, try using something
 like gsel:
 http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-Basic.html#v%3Agsel

 --
 Ivan Lazar Miljenovic
 ivan.miljeno...@gmail.com
 IvanMiljenovic.wordpress.com

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


Re: [Haskell-cafe] Heavy lift-ing

2010-07-24 Thread aditya siram
I wouldn't-it was a bad example. My only point was that because of the
way (=) is implemented for lists the order of the arguments 'a' and
'b' in 'liftM2 f a b' matters.

-deech

On Sat, Jul 24, 2010 at 1:37 AM, Lennart Augustsson
lennart.augusts...@gmail.com wrote:
 Why would you expect swapped operands to (-) ?


 Sent from my iPad

 On Jul 23, 2010, at 20:12, aditya siram aditya.si...@gmail.com wrote:

 Lists are non-deterministic, but the function taken by liftM2 does not
 necessarily generate all possible outcomes. In the case of (+) it
 does, not in the case of (-):
 liftM2 (-) [0,1] [2,3] = [0-1,0-2,1-2,1-3] = [-2,-3,-1,-2]
 if all possible cases were generated between the two lists we have to
 include also:
 [2-0,2-1,3-0,3-1]

 -deech

 On Fri, Jul 23, 2010 at 3:44 PM, Alex Stangl a...@stangl.us wrote:
 On Fri, Jul 23, 2010 at 11:43:08AM -0700, michael rice wrote:
 What does it mean to promote a function to a monad?

 It would seem that the monad values must understand the function that's 
 being promoted, like Ints understand (+).

 Prelude Control.Monad liftM2 (+) (Just 1) (Just 1)
 Just 2

 But how does one add [0,1] and [0,2] to get [0,2,1,3]?

 It depends upon the semantics of the particular monad. List monads
 represent nondeterminism. So, for example, [0,1] represents a 0 or
 1, and [0,2] represents a 0 or 2.

 When you add 0 or 1 to 0 or 2, your possible answers are [0,2,1,3].

 Alex
 ___
 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] Heavy lift-ing

2010-07-24 Thread Max Rabkin
On Sat, Jul 24, 2010 at 4:08 PM, aditya siram aditya.si...@gmail.com wrote:
 I wouldn't-it was a bad example. My only point was that because of the
 way (=) is implemented for lists the order of the arguments 'a' and
 'b' in 'liftM2 f a b' matters.

 -deech

No, it's not. The type of liftM2 makes this clear:

liftM2 :: (Monad m) = (a - b - r) - m a - m b - m r

The arguments to the function *must* come in the right order, because
there is no way to match (a) with (m b) or (b) with (m a). Since
liftM2 is parametrically polymorphic in (a) and (b), it can't behave
differently in the case where (a = b).

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


Re: [Haskell-cafe] Heavy lift-ing

2010-07-24 Thread aditya siram
Perhaps I'm being unclear again. All I was trying to say was that:
liftM2 (-) [0,1] [2,3] /= liftM2 (-) [2,3] [0,1]

-deech

On Sat, Jul 24, 2010 at 9:30 AM, Max Rabkin max.rab...@gmail.com wrote:
 On Sat, Jul 24, 2010 at 4:08 PM, aditya siram aditya.si...@gmail.com wrote:
 I wouldn't-it was a bad example. My only point was that because of the
 way (=) is implemented for lists the order of the arguments 'a' and
 'b' in 'liftM2 f a b' matters.

 -deech

 No, it's not. The type of liftM2 makes this clear:

 liftM2 :: (Monad m) = (a - b - r) - m a - m b - m r

 The arguments to the function *must* come in the right order, because
 there is no way to match (a) with (m b) or (b) with (m a). Since
 liftM2 is parametrically polymorphic in (a) and (b), it can't behave
 differently in the case where (a = b).

 --Max

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


[Haskell-cafe] Re: New FGL naming survey

2010-07-24 Thread Ivan Lazar Miljenovic
For those interested, the overall results are in:
http://ivanmiljenovic.wordpress.com/2010/07/25/results-of-fgl-naming-survey/

Ivan Miljenovic ivan.miljeno...@gmail.com writes:

 Thank you for all the people who have voted; we so far have 42 results
 in about 12 hours.

 Some indication of the results so far:

 * 62% prefer inductive-graphs

 * 62% have indicated that they use fgl or do some graph-related stuff
 (no correlation, just an interesting coincidence; I have not as yet
 done the number crunching to tell what the most popular name is for
 people that actually use fgl or other graph stuff).

 * Someone stated that ponies smell sweaty... not sure how that's
 relevant, but OK.

 * At least two people prefer the new name as it isn't an acronym (one
 because acronyms aren't needed and the term functional is redundant,
 the other because the term graph isn't directly in the package
 name).

 * Martin Erwig himself said that he thinks we should keep using the name 
 fgl.

 So, keep the votes coming in (I actually didn't expect this many already)!

 On 14 July 2010 00:24, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com 
 wrote:
 Whether or not the new FGL that Thomas Bereknyei and I are working on
 should keep the name was a semi-hot issue when we first mentioned the
 fact that we were working on a new version about a month ago.  As such,
 I've created a survey here to try and find out what the Haskell
 community overall thinks we should call it:
 https://spreadsheets.google.com/viewform?formkey=dGpzMmFnUWY3Uktodk5wdHlLQk5kT1E6MA

 More info can be found on the actual survey page.

 --
 Ivan Lazar Miljenovic
 ivan.miljeno...@gmail.com
 IvanMiljenovic.wordpress.com


-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Heavy lift-ing

2010-07-24 Thread michael rice
Prelude Control.Monad liftM2 (\a b - a : b : []) abc 123
[a1,a2,a3,b1,b2,b3,c1,c2,c3]
Prelude Control.Monad 

Got it!

Thanks to all.

Michael

--- On Sat, 7/24/10, aditya siram aditya.si...@gmail.com wrote:

From: aditya siram aditya.si...@gmail.com
Subject: Re: [Haskell-cafe] Heavy lift-ing
To: Max Rabkin max.rab...@gmail.com
Cc: haskell-cafe@haskell.org haskell-cafe@haskell.org, Lennart Augustsson 
lennart.augusts...@gmail.com
Date: Saturday, July 24, 2010, 10:35 AM

Perhaps I'm being unclear again. All I was trying to say was that:
liftM2 (-) [0,1] [2,3] /= liftM2 (-) [2,3] [0,1]

-deech

On Sat, Jul 24, 2010 at 9:30 AM, Max Rabkin max.rab...@gmail.com wrote:
 On Sat, Jul 24, 2010 at 4:08 PM, aditya siram aditya.si...@gmail.com wrote:
 I wouldn't-it was a bad example. My only point was that because of the
 way (=) is implemented for lists the order of the arguments 'a' and
 'b' in 'liftM2 f a b' matters.

 -deech

 No, it's not. The type of liftM2 makes this clear:

 liftM2 :: (Monad m) = (a - b - r) - m a - m b - m r

 The arguments to the function *must* come in the right order, because
 there is no way to match (a) with (m b) or (b) with (m a). Since
 liftM2 is parametrically polymorphic in (a) and (b), it can't behave
 differently in the case where (a = b).

 --Max

___
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] default function definitions

2010-07-24 Thread Patrick Browne
Hi,
I am studying the Haskell type class system as part of a language
comparison thesis. At this point I am looking at how default function
definitions are handled in classes. Functions are usually defined in
instances, not classes. I appreciate that the code below may not be an
appropriate way to write Haskell programs, but it does help me
understand how defaults work. I am not trying to construct a running
program. Any feedback on the questions below and defaults work in
general would be appreciated.

Pat

module A where
data Person = Person String Integer deriving Show
data Employee  = Employee String Integer deriving Show

class C1 c1 where
  age :: c1 - Integer
-- add default impl, can this be defined only once at class level?
-- Can this function be redefined in a *class* lower down the heirarchy?
 age(c1) = 1


-- Is it true that instances must exists before we can run function or
make subclasses?
instance C1  Person where
instance C1  Employee where


-- Is it true that C2 can inherit age, provided an instance of C1 exists
class C1 c2 =  C2 c2 where
  name :: c2 - String
  name(c2) = C2


instance C2  Person where
instance C2  Employee where

-- Is it true that C3 cannot override C1 or C2 existing defaults?
-- Is it true that this must be done at instance level?
-- class Cx c3 =  C3 c3 where
--age(c3) = 3
--

This message has been scanned for content and viruses by the DIT Information 
Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] build and use ghc's rts without a full unregistered ghc port?

2010-07-24 Thread Korcan Hussein

I did initially thought about it and had reservations but you convinced me so 
I've been trying out jhc. Seems a lot more promising but unfortunately I had 
problems, here's my targets.ini:

[wii]
cc=powerpc-eabi-gcc
byteorder=be
gc=static
cflags+=-DGEKKO -mrvl -mcpu=750 -meabi -mhard-float
executable_extension=.elf
bits=32

bits_max=64

Trying to compile a simple hello world haskell program resulted in the 
following error message:

hs.out.elf_code.c:118:2: error: #error Could not determine bitsize
hs.out.elf_code.c:150:24: error: sys/select.h: No such file or directory
hs.out.elf_code.c:154:25: error: sys/utsname.h: No such file or directory
...
...

For the first error I looked at the line and there is some pre-processor 
conditional code to determine the word size, this seems a bit odd since i've 
already specified these in the target.ini I would assume that they would get 
passed in to the compiler as extra defines.

More depressing is the last two lines, which looks like a POSIX compatible 
environment is required with jhc it seems. Having a look at devkitPPC include 
directory it seems it does implement some POSIX headers but those particular 
headers certainly do not exist in there.

Anyway I'll send a message to the jhc mailing list about it.


 Date: Sat, 24 Jul 2010 20:51:39 +1000
 Subject: Re: [Haskell-cafe] build and use ghc's rts without a full 
 unregistered ghc port?
 From: mwot...@gmail.com
 To: korca...@hotmail.com
 CC: haskell-cafe@haskell.org

 can't speak as to how difficult it is to get GHC built unregisterised,
 but you might want to consider JHC if you don't need to use a lot of
 Hackage. It compiles to C without a special RTS needed, which might
 make it a lot easier.

 mark

 On Sat, Jul 24, 2010 at 8:45 PM, Korcan Hussein  wrote:

 Hi, I was just wondering if this is possible, I would like to use a gcc port
 which cross compiles to the PPC architecture (Wii DevkitPPC to be 
 specifically:
 http://wiibrew.org/wiki/DevkitPPC) for a platform that is not POSIX 
 compatible I
 believe (at least not fully or maybe I'm wrong entirely).

 Ideally I would make an unregistered port of GHC but the problem is because 
 GHC
 doesn't support true cross compiling yet I need to bootstrap on to the target
 machine, which isn't running a POSIX environment.

 Still I did try to attempt to build with both the host and target set to
 'powerpc-unknown-linux' and build it with devkitPPC, I did use a custom 
 build.mk
 which should pull in all the required dependencies, defines, etc for 
 devkitPPC.

 In the end I didn't get very far with it, it looked like missing posix 
 functions.

 I didn't want to spend to much time trying to make it work this way (maybe 
 i'm
 doing it wrong completely). It's quite possible that I could make this work 
 more
 easily if I used a linux port for the wii but I would like to avoid the need 
 of
 using linux on the wii because I guess most home-brew users don't have such 
 a setup.

 So I thought maybe it's possible with less effort to build GHC's RTS and then
 compile Haskell in C with the RTS as a library dependency. Is this possible?
 maybe I'm missing something or doing something stupid?

 Thanks in advance.

 _
 http://clk.atdmt.com/UKM/go/19780/direct/01/
 We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
 now___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




 --
 A UNIX signature isn't a return address, it's the ASCII equivalent of a
 black velvet clown painting. It's a rectangle of carets surrounding a
 quote from a literary giant of weeniedom like Heinlein or Dr. Who.
 -- Chris Maeda
  
_
http://clk.atdmt.com/UKM/go/19780/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
now___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] default function definitions

2010-07-24 Thread Daniel Fischer
On Saturday 24 July 2010 19:59:26, Patrick Browne wrote:

 module A where
 data Person = Person String Integer deriving Show
 data Employee  = Employee String Integer deriving Show

 class C1 c1 where
   age :: c1 - Integer
 -- add default impl, can this be defined only once at class level?
 -- Can this function be redefined in a *class* lower down the heirarchy?
  age(c1) = 1

That would normally be written
   age _ = 1

Yes, a default implementation of a class method can only be given in the 
class definition, it can't be redefined, but it can be overridden in an 
instance declaration. For example

instance C1 Person where
age _ = 3

instance C1 Employee where
   age (Employee _ n) = n



 -- Is it true that instances must exists before we can run function or
 make subclasses?
 instance C1  Person where
 instance C1  Employee where

You can *call* class methods only for types which are instances of that 
class.
You can define subclasses [not to confuse with OO-subclasses] of C1 even 
if there are no instances of C1 in scope.



 -- Is it true that C2 can inherit age, provided an instance of C1 exists
 class C1 c2 =  C2 c2 where
   name :: c2 - String
   name(c2) = C2

A compiler/interpreter can accept an instance declaration of C2 for a type 
only if an instance of C1 for that type in scope [defined in the same 
module or in a module directly or indirectly imported; class instances are 
always re-exported from a module].

Since an instance of C2 must also be an instance of C1, all methods of C1 
can be applied to that type.



 instance C2  Person where
 instance C2  Employee where

 -- Is it true that C3 cannot override C1 or C2 existing defaults?
 -- Is it true that this must be done at instance level?
 -- class Cx c3 =  C3 c3 where
 --age(c3) = 3
 --


True. Default methods can only be overridden in instance declarations for 
the class.

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


Re: [Haskell-cafe] default function definitions

2010-07-24 Thread Alexander Solla


On Jul 24, 2010, at 10:59 AM, Patrick Browne wrote:


class C1 c1 where
 age :: c1 - Integer
-- add default impl, can this be defined only once at class level?
-- Can this function be redefined in a *class* lower down the  
heirarchy?

age(c1) = 1



Yes, but keep in mind that the hierarchy is only two levels tall.   
This mechanism isn't meant for OO-style inheritance.





-- Is it true that instances must exists before we can run function or
make subclasses?
instance C1  Person where
instance C1  Employee where



Yes, absolutely.



-- Is it true that C2 can inherit age, provided an instance of C1  
exists

class C1 c2 =  C2 c2 where
 name :: c2 - String
 name(c2) = C2



instance C2  Person where
instance C2  Employee where


There's no notion of inheritance here.   If Person belongs to C2,  
then it must belong to C1, because you have specifically said that a  
C2 needs to be a C1 (presumably because you need a person's age to  
compute their name).  So Person will be using C1's age function, in  
virtue of having a C1 instance.


Compare this to:

class C4 c4 where name' :: c4 - String

instance C1 Person 			-- gives Person an age function, either default  
or overridden
instance C1 thing = C4 thing  -- gives every C1 thing a name, needs  
Haskell extensions.




-- Is it true that C3 cannot override C1 or C2 existing defaults?
-- Is it true that this must be done at instance level?
-- class Cx c3 =  C3 c3 where
--age(c3) = 3


Yes, as I said, the hierarchy is two levels tall.

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


Re: [Haskell-cafe] Porting ELF statifier to Haskell!

2010-07-24 Thread Henning Thielemann
C K Kashyap schrieb:
 Hi,
 At my work we ran into a situation where we started wishing there was a
 way to take a dynamically linked executable and create a statically
 linked bundle out of it. Little bit of googling got me to statifier -
 http://statifier.sourceforge.net/statifier/main.html.

I also tried to use statifier in order to run a Haskell program on a
remote machine that I compiled locally. I had also no success. :-(

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


[Haskell-cafe] Type problems

2010-07-24 Thread michael rice
This works:

Prelude System.Random do { randomRIO (1,6) = (\x - putStrLn $ Value =  ++ 
show x) }
Value = 5

So does this:

Prelude System.Random do { x - randomRIO (1,6); putStrLn $ Value =  ++ show 
x }
Value = 2

But not this:

1 import Control.Monad
2 import System.Random
3
4 foo :: IO ()
5 foo = do
6   x - randomRIO (1,6)
7   putStrLn $ Value =  ++ show x


foo.hs:6:18:
    Ambiguous type variable `t' in the constraints:
  `Num t' arising from the literal `1' at foo.hs:6:18
  `Random t' arising from a use of `randomRIO' at foo.hs:6:7-21
    Probable fix: add a type signature that fixes these type variable(s)
Failed, modules loaded: none.
Prelude System.Random 

Or this:

1 import Control.Monad
2 import System.Random
3
4 foo :: IO ()
5 foo = randomRIO (1,6) = (\x - putStrLn $ Value =  ++ show x)


foo.hs:5:17:
    Ambiguous type variable `t' in the constraints:
  `Num t' arising from the literal `1' at foo.hs:5:17
  `Random t' arising from a use of `randomRIO' at foo.hs:5:6-20
    Probable fix: add a type signature that fixes these type variable(s)
Failed, modules loaded: none.


How to fix?

Michael








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


Re: [Haskell-cafe] Type problems

2010-07-24 Thread Tobias Brandt
You have to fix the type of 1 and 6, e.g. by writing

x - randomRIO (1, 6) :: IO Int

or

x - randomRIO (1, 6 :: Int)

 GHCi defaults integral numbers to Int, that's why it works there.

On 24 July 2010 21:36, michael rice nowg...@yahoo.com wrote:

 This works:

 Prelude System.Random do { randomRIO (1,6) = (\x - putStrLn $ Value =
  ++ show x) }
 Value = 5

 So does this:

 Prelude System.Random do { x - randomRIO (1,6); putStrLn $ Value =  ++
 show x }
 Value = 2

 But not this:

 1 import Control.Monad
 2 import System.Random
 3
 4 foo :: IO ()
 5 foo = do
 6   x - randomRIO (1,6)
 7   putStrLn $ Value =  ++ show x


 foo.hs:6:18:
 Ambiguous type variable `t' in the constraints:
   `Num t' arising from the literal `1' at foo.hs:6:18
   `Random t' arising from a use of `randomRIO' at foo.hs:6:7-21
 Probable fix: add a type signature that fixes these type variable(s)
 Failed, modules loaded: none.
 Prelude System.Random

 Or this:

 1 import Control.Monad
 2 import System.Random
 3
 4 foo :: IO ()
 5 foo = randomRIO (1,6) = (\x - putStrLn $ Value =  ++ show x)


 foo.hs:5:17:
 Ambiguous type variable `t' in the constraints:
   `Num t' arising from the literal `1' at foo.hs:5:17
   `Random t' arising from a use of `randomRIO' at foo.hs:5:6-20
 Probable fix: add a type signature that fixes these type variable(s)
 Failed, modules loaded: none.


 How to fix?

 Michael







 ___
 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] Type problems

2010-07-24 Thread michael rice
Thanks, Tobias. I figured it was something like that but lack the syntax 
expertise on where to put it.

MIchael

--- On Sat, 7/24/10, Tobias Brandt tob.bra...@googlemail.com wrote:

From: Tobias Brandt tob.bra...@googlemail.com
Subject: Re: [Haskell-cafe] Type problems
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Saturday, July 24, 2010, 3:50 PM

You have to fix the type of 1 and 6, e.g. by writing
x - randomRIO (1, 6) :: IO Int
or
x - randomRIO (1, 6 :: Int)
 GHCi defaults integral numbers to Int, that's why it works there.


On 24 July 2010 21:36, michael rice nowg...@yahoo.com wrote:

This works:

Prelude System.Random do { randomRIO (1,6) = (\x - putStrLn $ Value =  ++ 
show x) }

Value = 5

So does this:

Prelude System.Random do { x - randomRIO (1,6); putStrLn $ Value =  ++ show 
x }
Value = 2

But not this:

1 import Control.Monad
2 import System.Random

3
4 foo :: IO ()
5 foo = do
6   x - randomRIO (1,6)
7   putStrLn $ Value =  ++ show x


foo.hs:6:18:
    Ambiguous type variable `t' in the constraints:
  `Num t' arising from the literal `1' at foo.hs:6:18

  `Random t' arising from a use of `randomRIO' at foo.hs:6:7-21
    Probable fix: add a type signature that fixes these type variable(s)
Failed, modules loaded:
 none.
Prelude System.Random 

Or this:

1 import Control.Monad
2 import System.Random
3
4 foo :: IO ()
5 foo = randomRIO (1,6) = (\x - putStrLn $ Value =  ++ show x)



foo.hs:5:17:
    Ambiguous type variable `t' in the constraints:
  `Num t' arising from the literal `1' at foo.hs:5:17
  `Random t' arising from a use of `randomRIO' at foo.hs:5:6-20

    Probable fix: add a type signature that fixes these type variable(s)
Failed, modules loaded: none.


How to fix?

Michael








  
___

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] Type problems

2010-07-24 Thread Daniel Fischer
On Saturday 24 July 2010 21:36:14, michael rice wrote:
 This works:

 Prelude System.Random do { randomRIO (1,6) = (\x - putStrLn $ Value
 =  ++ show x) } Value = 5

 So does this:

 Prelude System.Random do { x - randomRIO (1,6); putStrLn $ Value = 
 ++ show x } Value = 2

 But not this:

 1 import Control.Monad
 2 import System.Random
 3
 4 foo :: IO ()
 5 foo = do
 6   x - randomRIO (1,6)
 7   putStrLn $ Value =  ++ show x


 foo.hs:6:18:
     Ambiguous type variable `t' in the constraints:
   `Num t' arising from the literal `1' at foo.hs:6:18
   `Random t' arising from a use of `randomRIO' at foo.hs:6:7-21
     Probable fix: add a type signature that fixes these type variable(s)
 Failed, modules loaded: none.
 Prelude System.Random

The x has type

(Num a, Random a) = a

so GHC doesn't know which type to choose.
GHCi uses extended defaulting rules and picks Integer.

Fix, tell GHC which type to choose:

putStrLn $ Value =  ++ show (x :: Integer)

or

x - randomRIO (1,6) :: IO Integer


 Or this:

 1 import Control.Monad
 2 import System.Random
 3
 4 foo :: IO ()
 5 foo = randomRIO (1,6) = (\x - putStrLn $ Value =  ++ show x)


 foo.hs:5:17:
     Ambiguous type variable `t' in the constraints:
   `Num t' arising from the literal `1' at foo.hs:5:17
   `Random t' arising from a use of `randomRIO' at foo.hs:5:6-20
     Probable fix: add a type signature that fixes these type variable(s)
 Failed, modules loaded: none.


 How to fix?

 Michael

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


Re: [Haskell-cafe] Wildly off-topic: de Boor's algorithm

2010-07-24 Thread mokus
Andrew Coppin wrote:
 Given a suitable definition for Vector2 (i.e., a 2D vector with the
 appropriate classes), it is delightfully trivial to implement de
 Casteljau's algorithm:

 de_Casteljau :: Scalar - [Vector2] - [[Vector2]]
 de_Casteljau t [p] = [[p]]
 de_Casteljau t ps = ps : de_Casteljau t (zipWith (line t) ps (tail ps))

 line :: Scalar - Vector2 - Vector2 - Vector2
 line t a b = (1-t) *| a + t *| b

 Now if you want to compute a given point along a Bezier spline, you can do

 bezier :: Scalar - [Vector2] - Vector2
 bezier t ps = head $ last $ de_Casteljau t ps

 You can chop one in half with

 split :: Scalar - [Vector2] - ([Vector2], [Vector2])
 split t ps =
   let pss = de_Casteljau t ps
   in (map head pss, map last pss)

 And any other beautiful incantations.


 Now, de Boor's algorithm is a generalisation of de Casteljau's
 algorithm. It draws B-splines instead of Bezier-splines (since B-splines
 generalise Bezier-splines). But I think I may have ACTUALLY MELTED MY
 BRAIN attempting to comprehend it. Can anybody supply a straightforward
 Haskell implementation?

It took me a while to get around to it, and another while to work it out,
but here's what I've come up with.  First, here's a restatement of your
code with a concrete choice of types (using Data.VectorSpace from the
vector-space package) and a few minor stylistic changes just so things
will line up with the generalized version better:

  import Data.VectorSpace
 
  interp a x y = lerp x y a
 
  deCasteljau [] t = []
  deCasteljau ps t = ps : deCasteljau (zipWith (interp t) ps (tail ps)) t
 
  bezier ps = head . last . deCasteljau ps
 
  split ps t = (map head pss, reverse (map last pss))
  where pss = deCasteljau ps t

To generalize to De Boor's algorithm, the primary change is the
interpolation operation.  In De Casteljau's algorithm, every interpolation
is over the same fixed interval 0 = x = 1.  For De Boor's algorithm we
need a more general linear interpolation on the arbitrary interval
[x0,x1], because all the interpolations in De Boor's recurrence are
between pairs of knots, which have arbitrary values instead of just 0 or
1.

Because of Haskell's laziness, we can also take care of searching the
result table for the correct set of control points at the same time, just
by clamping the input to the desired interval and pre-emptively returning
the corresponding 'y' if the input is outside that interval.  This way, to
find the final interpolant we only need to go to the end of the table, as
in 'deCasteljau'.  Unlike 'deCasteljau', only a portion of the table is
actually computed (a triangular portion with the active control points as
base and a path from the vertex of the triangle to the final entry in the
table).

 interp x (x0,x1) (y0,y1)
 |  x   x0  = y0
 |  x = x1  = y1
 | otherwise = lerp y0 y1 a
 where
 a = (x - x0) / (x1 - x0)

Computing the table is now nearly as straightforward as in De Casteljau's
algorithm:

 deBoor p  _ [] x = []
 deBoor p (_:us) ds x = ds : deBoor (p-1) us ds' x
 where
 ds' = zipWith (interp x) (spans p us) (spans 1 ds)

Making use of a simple list function to select the spans:

 spans n xs = zip xs (drop n xs)

Note that the algorithm does not make use of @us!!0@ at all.  I believe
this is correct, based both on the Wikipedia description of the algorithm
and the implementations I've seen.  De Boor's recurrence seems to require
an irrelevant choice of extra control point that would be, notionally,
@ds!!(-1)@.  This control point has no actual influence inside the domain
of the spline, although it /can/ affect values outside the domain (The
domain being taken as the central portion of the knot vector where there
are @p+1@ non-zero basis functions, forming a complete basis for the
degree @p@ polynomials on that interval).

This implementation makes the arbitrary but justifiable choice that the
extra control point be identical to the first, so that the position of the
first knot is irrelevant. It could alternatively be written to take the
extra control point as an argument or as a part of @ds@, in which case the
caller would be required to supply an additional control point that does
not actually influence the spline.

I initially found this result difficult to convince myself of even though
it seems very plausible mathematically, because it seems to indicate that
in general the position of the first and last knots are utterly irrelevant
and I never saw any remarks to that effect in any of my reading on
B-splines. Empirically, though, it seems to hold.  Moving an internal knot
at one end of a basis function does not alter the shape of that function
in the segment furthest opposite, which is basically the same effect the
first knot should have on the first basis function (and the opposite
segment is the only one that falls inside the domain of the spline).  It
still may be that I'm wrong, and if anyone knows I'd love to hear about
it, but I'm presently inclined 

Re: [Haskell-cafe] default function definitions

2010-07-24 Thread Andrew Coppin

Patrick Browne wrote:

Hi,
I am studying the Haskell type class system as part of a language
comparison thesis. At this point I am looking at how default function
definitions are handled in classes. Functions are usually defined in
instances, not classes. I appreciate that the code below may not be an
appropriate way to write Haskell programs, but it does help me
understand how defaults work. I am not trying to construct a running
program. Any feedback on the questions below and defaults work in
general would be appreciated.
  


1. Stop thinking of Haskell classes being like normal classes in OOP. 
They are more like what Java calls interfaces. A type can belong to a 
class, much like in Java any class can implement Runnable (for example).


2. Making one class a subclass of another merely means that before a 
type can be made an instance of Y, it must first be an instance of X. 
There is no inheritance in Haskell. And no, if Y is a subclass of X, 
it cannot change anything in X, just add new stuff. It merely means that 
if you say I want something that's an instance of Y then it's also 
guaranteed to be an instance of X, without you having to manually say so.


3. A default implementation is just what it says on the tin: an 
implementation that will automatically be used if you don't manually 
supply one. The usual reason for this is if there's an implementation 
that will always work, but in some cases there may be a more efficient 
one. The default implementation is then the general version that will 
always work, and when you write instances for other types, you may 
specify a better implementation. The other reason is if X can be defined 
in terms of Y, and Y can be defined in terms of X. Add default 
implementations for both, and when you write an instance you can 
implement whichever one is easiest and use the default for the other.


HTH.

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


[Haskell-cafe] data type declaration

2010-07-24 Thread Patrick Browne
Hi,
I am trying to understand the data type declaration below.
What is the relation between class C3 and the data type Address below?
Where is such a technique used?

Thanks,
Pat


module A where
data Person = Person String Integer deriving Show
data Employee  = Employee String Integer deriving Show

class C1 c1 where
  age :: c1 - Integer

instance C1  Person where
   age(Person P1 1) = 1


instance C1  Employee where
age(Employee E1 1) = 1


class C1 c2 =  C2 c2 where
  name :: c2 - String


instance C2  Person where
  name(Person P2 1) = P2

instance C2  Employee where
name(Employee E2 1) = E2


class C2 c3 =  C3 c3 a where
  address :: c3  - a

instance C3 Person String where

-- ** What are the semantics or purpose of this construct.
-- ** Is the type declared in the context of a class.
data C3 c3 a  = Address c3 a = Address c3 a

instance C3 Person (Address String String) where

This message has been scanned for content and viruses by the DIT Information 
Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] build and use ghc's rts without a full unregistered ghc port?

2010-07-24 Thread Korcan Hussein

I managed to get a hello world app working on the Wii! but I had to do some 
hacking of the generated C code because the devkitPPC is missing 2 posix 
headers referenced in the generated C code from Jhc. The functions the code 
used from those headers didn't seem completely essential. Basically I set the 
define JHC_isPosix to 0, commented out problem code. Of-course this isn't 
ideal, the solution would be to implement the missing headers for devkitPPC.


 From: korca...@hotmail.com
 To: mwot...@gmail.com
 CC: haskell-cafe@haskell.org
 Subject: RE: [Haskell-cafe] build and use ghc's rts without a full 
 unregistered ghc port?
 Date: Sat, 24 Jul 2010 18:25:56 +


 I did initially thought about it and had reservations but you convinced me so 
 I've been trying out jhc. Seems a lot more promising but unfortunately I had 
 problems, here's my targets.ini:

 [wii]
 cc=powerpc-eabi-gcc
 byteorder=be
 gc=static
 cflags+=-DGEKKO -mrvl -mcpu=750 -meabi -mhard-float
 executable_extension=.elf
 bits=32

 bits_max=64

 Trying to compile a simple hello world haskell program resulted in the 
 following error message:

 hs.out.elf_code.c:118:2: error: #error Could not determine bitsize
 hs.out.elf_code.c:150:24: error: sys/select.h: No such file or directory
 hs.out.elf_code.c:154:25: error: sys/utsname.h: No such file or directory
 ...
 ...

 For the first error I looked at the line and there is some pre-processor 
 conditional code to determine the word size, this seems a bit odd since i've 
 already specified these in the target.ini I would assume that they would get 
 passed in to the compiler as extra defines.

 More depressing is the last two lines, which looks like a POSIX compatible 
 environment is required with jhc it seems. Having a look at devkitPPC include 
 directory it seems it does implement some POSIX headers but those particular 
 headers certainly do not exist in there.

 Anyway I'll send a message to the jhc mailing list about it.

 
 Date: Sat, 24 Jul 2010 20:51:39 +1000
 Subject: Re: [Haskell-cafe] build and use ghc's rts without a full 
 unregistered ghc port?
 From: mwot...@gmail.com
 To: korca...@hotmail.com
 CC: haskell-cafe@haskell.org

 can't speak as to how difficult it is to get GHC built unregisterised,
 but you might want to consider JHC if you don't need to use a lot of
 Hackage. It compiles to C without a special RTS needed, which might
 make it a lot easier.

 mark

 On Sat, Jul 24, 2010 at 8:45 PM, Korcan Hussein wrote:

 Hi, I was just wondering if this is possible, I would like to use a gcc port
 which cross compiles to the PPC architecture (Wii DevkitPPC to be 
 specifically:
 http://wiibrew.org/wiki/DevkitPPC) for a platform that is not POSIX 
 compatible I
 believe (at least not fully or maybe I'm wrong entirely).

 Ideally I would make an unregistered port of GHC but the problem is because 
 GHC
 doesn't support true cross compiling yet I need to bootstrap on to the 
 target
 machine, which isn't running a POSIX environment.

 Still I did try to attempt to build with both the host and target set to
 'powerpc-unknown-linux' and build it with devkitPPC, I did use a custom 
 build.mk
 which should pull in all the required dependencies, defines, etc for 
 devkitPPC.

 In the end I didn't get very far with it, it looked like missing posix 
 functions.

 I didn't want to spend to much time trying to make it work this way (maybe 
 i'm
 doing it wrong completely). It's quite possible that I could make this work 
 more
 easily if I used a linux port for the wii but I would like to avoid the 
 need of
 using linux on the wii because I guess most home-brew users don't have such 
 a setup.

 So I thought maybe it's possible with less effort to build GHC's RTS and 
 then
 compile Haskell in C with the RTS as a library dependency. Is this possible?
 maybe I'm missing something or doing something stupid?

 Thanks in advance.

 _
 http://clk.atdmt.com/UKM/go/19780/direct/01/
 We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
 now___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




 --
 A UNIX signature isn't a return address, it's the ASCII equivalent of a
 black velvet clown painting. It's a rectangle of carets surrounding a
 quote from a literary giant of weeniedom like Heinlein or Dr. Who.
 -- Chris Maeda

 _
 http://clk.atdmt.com/UKM/go/19780/direct/01/
 We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
 now
  
_
http://clk.atdmt.com/UKM/go/19780/direct/01/
We want to hear all your funny, exciting and crazy 

Re: [Haskell-cafe] Type problems

2010-07-24 Thread Ivan Miljenovic
On 25 July 2010 05:50, Tobias Brandt tob.bra...@googlemail.com wrote:

 You have to fix the type of 1 and 6, e.g. by writing
 x - randomRIO (1, 6) :: IO Int
 or
 x - randomRIO (1, 6 :: Int)
  GHCi defaults integral numbers to Int, that's why it works there.

The default numeric type is Integer, not Int.

--
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: recommendation for (best) sqlite3 bindings

2010-07-24 Thread Dan Knapp
I am the author of direct-sqlite, and I thank you for the bug report.
I'll be fixing this as soon as I'm able.  It's always nice to hear
about people using my code!


On Wed, Jul 21, 2010 at 2:10 AM, Michael Snoyman mich...@snoyman.com wrote:


 On Wed, Jul 21, 2010 at 8:59 AM, Gour g...@gour-nitai.com wrote:

 On Wed, 21 Jul 2010 08:06:49 +0300
  Michael == Michael Snoyman mich...@snoyman.com wrote:

 Michael For the sqlite backend for persistent, I took direct-sqlite
 Michael and modified it slightly. I have a long history of using the
 Michael sqlite3 C API, so the API felt very familiar to me.

 So, it seems you're satisfiew with direct-sqlite?

 What is missing in 1st package (Galois bindings)?

 I didn't investigate it, I would imagine it's pretty complete if Galois
 wrote it. I stuck with direct-sqlite just because it was so incredibly
 simple (single file, ~15 functions).


 btw, after some research, I've concluded that NOSQL (Redis, MongoDB)
 are not good solutions in our use-case since we want to have extensive
 querying support and using sqlite3 with SQL seems better option.

 That's why I'm sticking with SQL for my current project.

 Michael If I'm not mistaken, direct-sqlite does not build as-is on
 Michael hackage because it's missing a reference to the C library.

 Hmm...you're right.

 Apparently Archlinux package built OK; but loading it into ghci gives:

 ghc: /usr/lib/direct-sqlite-1.0/ghc-6.12.1/HSdirect-sqlite-1.0.o:
 unknown symbol `sqlite3_column_blob'

 Thank you.

 Michael However, if you take my approach and just include the code in
 Michael your library, you can fix that easily enough.

 It looks it's the problem with package's cabal file...


 True, it's a very simple fix. In fact, you can just include the sqlite
 amalgamation file with the code and not worry about library dependencies.
 Michael
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





-- 
Dan Knapp
An infallible method of conciliating a tiger is to allow oneself to
be devoured. (Konrad Adenauer)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: recommendation for (best) sqlite3 bindings

2010-07-24 Thread Michael Snoyman
Sorry I didn't send it earlier, it must have slipped my mind.

On Sun, Jul 25, 2010 at 3:07 AM, Dan Knapp dan...@gmail.com wrote:

 I am the author of direct-sqlite, and I thank you for the bug report.
 I'll be fixing this as soon as I'm able.  It's always nice to hear
 about people using my code!


 On Wed, Jul 21, 2010 at 2:10 AM, Michael Snoyman mich...@snoyman.com
 wrote:
 
 
  On Wed, Jul 21, 2010 at 8:59 AM, Gour g...@gour-nitai.com wrote:
 
  On Wed, 21 Jul 2010 08:06:49 +0300
   Michael == Michael Snoyman mich...@snoyman.com wrote:
 
  Michael For the sqlite backend for persistent, I took direct-sqlite
  Michael and modified it slightly. I have a long history of using the
  Michael sqlite3 C API, so the API felt very familiar to me.
 
  So, it seems you're satisfiew with direct-sqlite?
 
  What is missing in 1st package (Galois bindings)?
 
  I didn't investigate it, I would imagine it's pretty complete if Galois
  wrote it. I stuck with direct-sqlite just because it was so incredibly
  simple (single file, ~15 functions).
 
 
  btw, after some research, I've concluded that NOSQL (Redis, MongoDB)
  are not good solutions in our use-case since we want to have extensive
  querying support and using sqlite3 with SQL seems better option.
 
  That's why I'm sticking with SQL for my current project.
 
  Michael If I'm not mistaken, direct-sqlite does not build as-is on
  Michael hackage because it's missing a reference to the C library.
 
  Hmm...you're right.
 
  Apparently Archlinux package built OK; but loading it into ghci gives:
 
  ghc: /usr/lib/direct-sqlite-1.0/ghc-6.12.1/HSdirect-sqlite-1.0.o:
  unknown symbol `sqlite3_column_blob'
 
  Thank you.
 
  Michael However, if you take my approach and just include the code in
  Michael your library, you can fix that easily enough.
 
  It looks it's the problem with package's cabal file...
 
 
  True, it's a very simple fix. In fact, you can just include the sqlite
  amalgamation file with the code and not worry about library dependencies.
  Michael
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 



 --
 Dan Knapp
 An infallible method of conciliating a tiger is to allow oneself to
 be devoured. (Konrad Adenauer)
 ___
 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] Porting ELF statifier to Haskell!

2010-07-24 Thread C K Kashyap
Looks like the crash is due to ASLR (Address Space Layout Randomization).
You need to disable it for it to work. You can disable ASLR very easily -
check out
http://stackoverflow.com/questions/1455904/how-to-disable-address-space-randomization-for-a-binary-on-linux
for
instance
Statifier worked for me once I disabled ASLR ...

On Sun, Jul 25, 2010 at 12:32 AM, Henning Thielemann 
schlepp...@henning-thielemann.de wrote:

 C K Kashyap schrieb:
  Hi,
  At my work we ran into a situation where we started wishing there was a
  way to take a dynamically linked executable and create a statically
  linked bundle out of it. Little bit of googling got me to statifier -
  http://statifier.sourceforge.net/statifier/main.html.

 I also tried to use statifier in order to run a Haskell program on a
 remote machine that I compiled locally. I had also no success. :-(




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