Re: [Haskell-cafe] Category Theory and Haskell

2012-11-30 Thread AUGER Cédric
Le Sun, 25 Nov 2012 21:41:47 +,
Gytis Žilinskas gytis.zilins...@gmail.com a écrit :

 Greetings,
 
 I'm only taking my very first steps learning Haskell, but I believe
 that this mailing list might be appropriate for my question.
 
 How difficult would it be to study category theory and simultaneously
 come up with Haskell examples of various results that it presents?
 
 I believe some background is in order. I am a second year maths
 student (well actually I'm in-between 2nd and 3rd, but let's not delve
 into details). I have also done some 2nd year CS courses so I have
 some background in that too. My general interests seem to lie
 somewhere between maths and compsci (I guess theoretical cs is the
 word for it), but it doesn't look like there is a good way to study
 the subject at an undergrad level. Most CompSci undergrad courses seem
 to concentrate too much on the trade of being a programmer and only
 present the basics of the theoretical results. While maths departments
 seem to be reluctant to make room in the undergrad curriculum for a
 huge subject that, after all, is maths.
 
 Recently, whenever I try reading up on something that looks like an
 exciting topic to me, I hit my head against category theory. That
 seems to suggest, that I should check it out, as it might be a fun
 subject to study, or at least provide valuable insights elsewhere.
 
 I've tried looking for some resources online. Most of them are
 outright scary and clearly have prerequisites that I lack. Some a
 little bit more accessible. Overall, various similar questions on
 different stackexchanges and even some old discussions on this mailing
 list, imply that to study category theory one has to know many
 examples from other advanced fields, in order to see the patterns that
 category theory describes. Now I obviously lack that. Some basic group
 theory, linear algebra, real/complex analysis and metric spaces is
 pretty much all I've got. Moreover, most sources say that without the
 knowledge of examples - category theory is an extremely dry subject to
 study. Therefore, my preliminary plan is the following:
 
 Read:
 * Barry Mazur - When is one thing equal to some other thing?
 * Conceptual mathematics : a first introduction to categories / F.
 William Lawvere, Stephen H. Schanuel. (People say that it is rather
 lightweight, but at this point my goal is to see the general idea of
 category theory and get some taste of it)
 
 Then, in the 2nd semester, I have an option of taking a self-study
 module, and if I don't get bored by cats by that time - it would be
 great to invest some more time in it (or rather, I'll do anything to
 avoid applied maths *shudder*). However, I'll need to present my case
 before the department staff and this, basically, is why I'm here.
 Right now, it looks like the main argument against me, would be that I
 can't appreciate the subject since I lack the fundamentals in other
 areas of maths. So I was hoping, I could convince them that everything
 I lack example wise - I'll find in Haskell. Okay, everything might
 be too strong of a statement, but I don't really know what I'm talking
 about so it's a bit difficult to calibrate. Could you comment whether
 Haskell would serve me well for this purpose?
 
 I've also seen these lecture notes:
 http://www.haskell.org/haskellwiki/User:Michiexile/MATH198. But I'm
 not sure if they won't be deemed too comp sci targeted. Therefore, I'm
 putting more hope into The Joy of Cats which, at least according to
 the first few pages, doesn't assume any prior knowledge that I don't
 have.
 
 So that's that, I would appreciate any advice you could give.
 
 Gytis
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

 I would suggest reading Saunders MacLane book (Categories for the
working mathematician). I am happy to have bought this one. But do not
be impressed by the given exercises, they have no correction, and some
are not understandable for a new comer. (The first exercise of the book
talks about Lie groups and algebra, that is hard to start with). So for
the examples, only read the ones involving the Set, Ab, Rng
categories if you are not used to the other ones.
 The terminology is also annoying, as the formalization was done rather
lately, and some concepts merged, so for instance the concept of limit.
In the terminology, you have limit=inverse limit and
colimit=direct limit which is quite confusing (but MacLane is not
at fault for that).

Some other resource is the categories channel on IRC (Freenode), the
nLab wiki (and Wikipedia of course).

You may also be interested in Agda, which would help in using the laws
of each category (not ensured by raw Haskell). I learned Coq rather
than Agda, so you can also try it too.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org

Re: [Haskell-cafe] lambda case

2012-11-30 Thread Jon Fairbairn
Andreas Abel andreas.a...@ifi.lmu.de writes:

 I had been missing a pattern matching lambda in Haskell for
 a long time (SML had fn since ages) and my typical use
 will be

   monadic_expr = \case
 branches

We’ve been through that.  I want something similar, but would
have preferred something more algebraic.

 I think \case is not the worst choice, certainly better than
 of ...

What’s your argument? You’ll have to do better than blatant
assertion to convince me. Making “case exp” optional builds on
an existing expression syntax, giving an explicit meaning to a
part of it, so a reader only has to know that “of {alts}” is a
function and case does something specific with it. This “\case”
takes the keyword from that expression syntax and makes it a
special case of lambda, so a reader seeing a lambda now has to
check for a keyword instead of knowing straight off that the
next thing is going to be a variable.

Back when we originally designed Haskell there were lots of
things that people wanted to put in, and eventually we reached a
point where we said that we would only put something new in if
it allowed us to remove (or simplify) something else. “\case”
complicates lambda, using “of” simply breaks “case … of …” into
two easily understood parts.
-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk



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


[Haskell-cafe] ANN: base-compat

2012-11-30 Thread Simon Hengel
Hi,
I just released the first version of a package that provide new
additions to base for older versions of base [2].  So far the following
is covered:

readMaybe
readEither
lookupEnv
getExecutablePath 

Source is on GitHub [2]; patches welcome ;)

Cheers,
Simon

[1] http://hackage.haskell.org/package/base-compat
[2] https://github.com/sol/base-compat

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


Re: [Haskell-cafe] lambda case

2012-11-30 Thread Herbert Valerio Riedel
Jon Fairbairn jon.fairba...@cl.cam.ac.uk writes:

[...]

 “\case” complicates lambda, using “of” simply breaks “case … of …”
 into two easily understood parts.

Just some observation (I'm rather late to the lambda-case discussion, so
this might have been already pointed out previously):

if the reserved keyword 'of' was to take the place of '\case', shouldn't
then

  'case' exp

w/o the 'of' { alts }-part become a separately valid expression (with
'case' essentially meaning 'flip ($)') to really break it up into two
independent parts? Then 'case exp of { alts }' wouldn't be a special
form anymore, but would just result from combining 'case' and 'of';

'case' wouldn't even need to be a reserved keyword (and thus the grammar
could be simplified), if it wasn't for the current grammar which
requires to isolate a \case-expression by using () or $, consider e.g.:

  {-# LANGUAGE LambdaCase #-}
  
  import System.Environment
  
  case' :: b - (b - c) - c
  case' = flip ($)
  
  main = do
s - getArgs
  
case' s $ \case  -- image '\case' was actually '\of' or 'of'
  [x] - putStrLn (Hello  ++ x)
  _   - putStrLn wrong number of arguments given


just my 2¢

cheers,
  hvr

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


Re: [Haskell-cafe] ANN: base-compat

2012-11-30 Thread dag.odenh...@gmail.com
Adding  could be useful.


On Fri, Nov 30, 2012 at 12:23 PM, Simon Hengel s...@typeful.net wrote:

 Hi,
 I just released the first version of a package that provide new
 additions to base for older versions of base [2].  So far the following
 is covered:

 readMaybe
 readEither
 lookupEnv
 getExecutablePath

 Source is on GitHub [2]; patches welcome ;)

 Cheers,
 Simon

 [1] http://hackage.haskell.org/package/base-compat
 [2] https://github.com/sol/base-compat

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

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


Re: [Haskell-cafe] ANN: base-compat

2012-11-30 Thread Simon Hengel
On Fri, Nov 30, 2012 at 02:32:12PM +0100, dag.odenh...@gmail.com wrote:
 Adding  could be useful.

Yes, patch is welcome ;)

Cheers,
Simon

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


Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Brent Yorgey
On Fri, Nov 30, 2012 at 02:33:54AM +0100, Ben Franksen wrote:
 Brent Yorgey wrote:
  On Thu, Nov 29, 2012 at 03:52:58AM +0100, Ben Franksen wrote:
  Tony Morris wrote:
   As a side note, I think a direct superclass of Functor for Monad is not
   a good idea, just sayin'
   
   class Functor f where
 fmap :: (a - b) - f a - f b
   
   class Functor f = Apply f where
 (*) :: f (a - b) - f a - f b
   
   class Apply f = Bind f where
 (=) :: (a - f b) - f a - f b
   
   class Apply f = Applicative f where
 unit :: a - f a
   
   class (Applicative f, Bind f) = Monad f where
   
   Same goes for Comonad (e.g. [] has (=) but not counit)
   ... and again for Monoid, Category, I could go on...
  
  Hi Tony
  
  even though I dismissed your mentioning this on the Haskell' list, I do 
 have 
  to admit that the proposal has a certain elegance. However, before I buy 
  into this scheme, I'd like to see some striking examples for types with 
  natural (or at least useful) Apply and Bind instances that cannot be made 
  Applicative resp. Monad. 
  
  Try writing an Applicative instances for (Data.Map.Map k).  It can't
  be done, but the Apply instance is (I would argue) both natural and 
 useful.
 
 I see. So there is one example. Are there more? I'd like to get a feeling 
 for the abstraction and this is hard if there is only a single example.

Any data type which admits structures of arbitrary but *only finite*
size has a natural zippy Apply instance but no Applicative (since
pure would have to be an infinite structure).  The Map instance I
mentioned above falls in this category.  Though I guess I'm having
trouble coming up with other examples, but I'm sure some exist.  Maybe
Edward knows of other examples.

-Brent

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


Re: [Haskell-cafe] lambda case

2012-11-30 Thread Brent Yorgey
Oh, PLEASE people.  Let's not have another round of bikeshedding about
this AFTER the feature is already implemented!

-Brent

On Fri, Nov 30, 2012 at 01:25:27PM +0100, Herbert Valerio Riedel wrote:
 Jon Fairbairn jon.fairba...@cl.cam.ac.uk writes:
 
 [...]
 
  “\case” complicates lambda, using “of” simply breaks “case … of …”
  into two easily understood parts.
 
 Just some observation (I'm rather late to the lambda-case discussion, so
 this might have been already pointed out previously):
 
 if the reserved keyword 'of' was to take the place of '\case', shouldn't
 then
 
   'case' exp
 
 w/o the 'of' { alts }-part become a separately valid expression (with
 'case' essentially meaning 'flip ($)') to really break it up into two
 independent parts? Then 'case exp of { alts }' wouldn't be a special
 form anymore, but would just result from combining 'case' and 'of';
 
 'case' wouldn't even need to be a reserved keyword (and thus the grammar
 could be simplified), if it wasn't for the current grammar which
 requires to isolate a \case-expression by using () or $, consider e.g.:
 
   {-# LANGUAGE LambdaCase #-}
   
   import System.Environment
   
   case' :: b - (b - c) - c
   case' = flip ($)
   
   main = do
 s - getArgs
   
 case' s $ \case  -- image '\case' was actually '\of' or 'of'
   [x] - putStrLn (Hello  ++ x)
   _   - putStrLn wrong number of arguments given
 
 
 just my 2¢
 
 cheers,
   hvr
 
 ___
 Glasgow-haskell-users mailing list
 glasgow-haskell-us...@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 

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


Re: [Haskell-cafe] lambda case

2012-11-30 Thread Andreas Abel

Right, case..of is superfluous,

  case e of
branches

can now be written as

  e | \case
branches

with backwards application | (or some prefer  --- sadly, the proposal 
to add backwards appliation to base did not make it to a consensus).


This is in accordance to the monadic

  me = \case
branches

If there was an opportunity to make drastic language changes, case..of 
could be disposed of altogether.  \case could become 'cases' or 'match' 
or 'fun' (rather not 'of', for my taste).


The current compromise it not too bad, I think.

Unfortunately, I have to wait for 7.6 to become the standard before 
using \case in Agda source...


Cheers,
Andreas

On 30.11.12 7:25 AM, Herbert Valerio Riedel wrote:

Jon Fairbairn jon.fairba...@cl.cam.ac.uk writes:

[...]


“\case” complicates lambda, using “of” simply breaks “case … of …”
into two easily understood parts.


Just some observation (I'm rather late to the lambda-case discussion, so
this might have been already pointed out previously):

if the reserved keyword 'of' was to take the place of '\case', shouldn't
then

   'case' exp

w/o the 'of' { alts }-part become a separately valid expression (with
'case' essentially meaning 'flip ($)') to really break it up into two
independent parts? Then 'case exp of { alts }' wouldn't be a special
form anymore, but would just result from combining 'case' and 'of';

'case' wouldn't even need to be a reserved keyword (and thus the grammar
could be simplified), if it wasn't for the current grammar which
requires to isolate a \case-expression by using () or $, consider e.g.:

   {-# LANGUAGE LambdaCase #-}

   import System.Environment

   case' :: b - (b - c) - c
   case' = flip ($)

   main = do
 s - getArgs

 case' s $ \case  -- image '\case' was actually '\of' or 'of'
   [x] - putStrLn (Hello  ++ x)
   _   - putStrLn wrong number of arguments given


just my 2¢

cheers,
   hvr

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



--
Andreas AbelDu bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.a...@ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/

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


Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Dan Doel
Lists! The finite kind.

This could mean Seq for instance.
On Nov 30, 2012 9:53 AM, Brent Yorgey byor...@seas.upenn.edu wrote:

 On Fri, Nov 30, 2012 at 02:33:54AM +0100, Ben Franksen wrote:
  Brent Yorgey wrote:
   On Thu, Nov 29, 2012 at 03:52:58AM +0100, Ben Franksen wrote:
   Tony Morris wrote:
As a side note, I think a direct superclass of Functor for Monad is
 not
a good idea, just sayin'
   
class Functor f where
  fmap :: (a - b) - f a - f b
   
class Functor f = Apply f where
  (*) :: f (a - b) - f a - f b
   
class Apply f = Bind f where
  (=) :: (a - f b) - f a - f b
   
class Apply f = Applicative f where
  unit :: a - f a
   
class (Applicative f, Bind f) = Monad f where
   
Same goes for Comonad (e.g. [] has (=) but not counit)
... and again for Monoid, Category, I could go on...
  
   Hi Tony
  
   even though I dismissed your mentioning this on the Haskell' list, I
 do
  have
   to admit that the proposal has a certain elegance. However, before I
 buy
   into this scheme, I'd like to see some striking examples for types
 with
   natural (or at least useful) Apply and Bind instances that cannot be
 made
   Applicative resp. Monad.
  
   Try writing an Applicative instances for (Data.Map.Map k).  It can't
   be done, but the Apply instance is (I would argue) both natural and
  useful.
 
  I see. So there is one example. Are there more? I'd like to get a feeling
  for the abstraction and this is hard if there is only a single example.

 Any data type which admits structures of arbitrary but *only finite*
 size has a natural zippy Apply instance but no Applicative (since
 pure would have to be an infinite structure).  The Map instance I
 mentioned above falls in this category.  Though I guess I'm having
 trouble coming up with other examples, but I'm sure some exist.  Maybe
 Edward knows of other examples.

 -Brent

 ___
 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] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Gershom Bazerman

On 11/30/12 10:44 AM, Dan Doel wrote:


Lists! The finite kind.

This could mean Seq for instance.

On Nov 30, 2012 9:53 AM, Brent Yorgey byor...@seas.upenn.edu 
mailto:byor...@seas.upenn.edu wrote:



Any data type which admits structures of arbitrary but *only finite*
size has a natural zippy Apply instance but no Applicative (since
pure would have to be an infinite structure).  The Map instance I
mentioned above falls in this category.  Though I guess I'm having
trouble coming up with other examples, but I'm sure some exist.  Maybe
Edward knows of other examples.



Another common case would be an embedded DSL representing code in a 
different language, targeting a different platform (or even an FPGA or 
the like), etc. You can apply `OtherLang (a - b)` to an `OtherLang a` 
and get an `OtherLang b`, but you clearly can't promote (or lower, I 
guess) an arbitrary Haskell function into a function in your target 
language. This is the same reason that GArrows remove the `arr` function 
(http://www.cs.berkeley.edu/~megacz/garrows/).


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


Re: [Haskell-cafe] Is anyone working on a sparse matrix library in Haskell?

2012-11-30 Thread Ernesto Rodriguez
Hi Mark,

For my bachelor thesis I am doing something somewhat in that direction. I
am developing a Echo State Neural Networks (ESNs) (
http://minds.jacobs-university.de/esn_research) library in Haskell. I
haven't worked on it for a while, since I was reading related literature in
the last months. It will be used to classify motion capture data. Feel free
to check it out: https://github.com/netogallo/LambdaNN. Sparse matrixes are
used to build the ESNs, I have basic functions to produce sparse matrixes
but nothing fancy at the moment.

Cheers,

Ernesto Rodriguez


On Thu, Nov 29, 2012 at 11:03 PM, Mark Flamer m...@flamerassoc.com wrote:

 I am looking to continue to learn Haskell while working on something that
 might eventually be useful to others and get posted on Hackage. I have
 written quite a bit of Haskell code now, some useful and a lot just throw
 away for learning. In the past others have expressed interest in having a
 native Haskell sparse matrix and linear algebra library available(not just
 bindings to a C lib). This in combination with FEM is one of my interests.
 So my questions, is anyone currently working on a project like this? Does
 it
 seem like a good project/addition to the community? I'm also interested if
 anyone has any other project idea's, maybe even to collaborate on. Thanks



 --
 View this message in context:
 http://haskell.1045720.n5.nabble.com/Is-anyone-working-on-a-sparse-matrix-library-in-Haskell-tp5721452.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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




-- 
Ernesto Rodriguez

Bachelor of Computer Science - Class of 2013
Jacobs University Bremen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to incrementally update list

2012-11-30 Thread Mark Thom
 Haskell's laziness is tricky to understand coming from imperative
 languages, but once you figure out its evaluation rules, you'll begin to
 see the elegance.


Is there a paper or other single resource that will help me thoroughly
understand non-strictness in Haskell? Once my programs hit a certain level
of complexity, their behaviour becomes much harder for me to predict. I've
been using the wiki pages up to this point, but apparently they haven't
pushed my understanding of laziness nearly far enough.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-30 Thread Bryan O'Sullivan
On Tue, Nov 27, 2012 at 11:02 AM, Jeff Shaw shawj...@gmail.com wrote:

 Once each minute, a thread of my program updates a global state, stored in
 an IORef, and updated with atomicModifyIORef', based on query results via
 HDBC-obdc.


Incidentally, what kind of database are you talking to? Issues of FFI
correctness aside, HDBC is in general terribly slow compared to some of the
more DB-specific bindings.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] tplot (out of memory)

2012-11-30 Thread Malcolm Wallace
For the record, it turned out that the key difference between the linux 
machines was the fonts packages installed via RPM.  The strace utility told me 
that the crash happened shortly after cairo/pango attempted (and failed) to 
open some font configuration files.  After installing some of the X11 font 
packages (and some others too), the crash went away.

On 18 Oct 2012, at 09:55, malcolm.wallace wrote:

 Did you ever solve this?  I have a similar message ( user error (out of 
 memory) ) arising from a different app (not tplot) that uses the Haskell 
 Chart library (and cairo underneath).  On some linux machines, it crashes, on 
 others it works fine.  I can find no environment differences between the 
 machines.  The app does not use a lot of memory, and the machine is not 
 running out of physical or swap. 
 Regards,
 Malcolm
 
 
 On 04 Sep, 2012,at 04:01 PM, Eugene Kirpichov ekirpic...@gmail.com wrote:
 
 Hi Manish,
 
 Please provide the input file, I'll debug this.
 
 On Mon, Sep 3, 2012 at 1:06 PM, Manish Trivedi trivman...@gmail.com wrote:
  Hi,
 
  I am running into a weird out of memory issue. While running timeplot over
  an input file having ~800 rows. From below provided info, seems like 
  machine
  has enough ram (1849MB).
  Please let me know if anyone has pointers.
 
  # free -m
  total used free shared buffers cached
  Mem: 3825 1975 1849 0 13 71
  -/+ buffers/cache: 1891 1934
  Swap: 4031 111 3920
 
  #time tplot -o out.png -or 1024x768 -k 'CurrentPerHour' 'lines' -k
  'RequiredPerHour' 'lines' -if adgroup_delivery_chart.input -tf 'date
  %Y-%m-%d %H:%M:%OS'
 
  tplot: user error (out of memory)
 
  real 0m0.026s
  user 0m0.018s
  sys 0m0.008s
 
  -Manish
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
 
 -- 
 Eugene Kirpichov
 http://www.linkedin.com/in/eugenekirpichov
 
 ___
 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] tplot (out of memory)

2012-11-30 Thread Eugene Kirpichov
Hi,

Wow, that's weird. I wonder what kinds of fonts were missing? I was just
using the default cairo font everywhere.


On Fri, Nov 30, 2012 at 11:27 PM, Malcolm Wallace malcolm.wall...@me.comwrote:

 For the record, it turned out that the key difference between the linux
 machines was the fonts packages installed via RPM.  The strace utility told
 me that the crash happened shortly after cairo/pango attempted (and failed)
 to open some font configuration files.  After installing some of the X11
 font packages (and some others too), the crash went away.

 On 18 Oct 2012, at 09:55, malcolm.wallace wrote:

  Did you ever solve this?  I have a similar message ( user error (out of
 memory) ) arising from a different app (not tplot) that uses the Haskell
 Chart library (and cairo underneath).  On some linux machines, it crashes,
 on others it works fine.  I can find no environment differences between the
 machines.  The app does not use a lot of memory, and the machine is not
 running out of physical or swap.
  Regards,
  Malcolm
 
 
  On 04 Sep, 2012,at 04:01 PM, Eugene Kirpichov ekirpic...@gmail.com
 wrote:
 
  Hi Manish,
 
  Please provide the input file, I'll debug this.
 
  On Mon, Sep 3, 2012 at 1:06 PM, Manish Trivedi trivman...@gmail.com
 wrote:
   Hi,
  
   I am running into a weird out of memory issue. While running timeplot
 over
   an input file having ~800 rows. From below provided info, seems like
 machine
   has enough ram (1849MB).
   Please let me know if anyone has pointers.
  
   # free -m
   total used free shared buffers cached
   Mem: 3825 1975 1849 0 13 71
   -/+ buffers/cache: 1891 1934
   Swap: 4031 111 3920
  
   #time tplot -o out.png -or 1024x768 -k 'CurrentPerHour' 'lines' -k
   'RequiredPerHour' 'lines' -if adgroup_delivery_chart.input -tf 'date
   %Y-%m-%d %H:%M:%OS'
  
   tplot: user error (out of memory)
  
   real 0m0.026s
   user 0m0.018s
   sys 0m0.008s
  
   -Manish
  
   ___
   Haskell-Cafe mailing list
   Haskell-Cafe@haskell.org
   http://www.haskell.org/mailman/listinfo/haskell-cafe
  
 
 
 
  --
  Eugene Kirpichov
  http://www.linkedin.com/in/eugenekirpichov
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
Eugene Kirpichov
http://www.linkedin.com/in/eugenekirpichov
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is anyone working on a sparse matrix library in Haskell?

2012-11-30 Thread mukesh tiwari
Hi Mark
I can work on couple of algorithms if you have anything specific in mind.
May be first start with how to represent the matrix and then continue with
algorithms.

Mukesh Tiwari


On Fri, Nov 30, 2012 at 3:33 AM, Mark Flamer m...@flamerassoc.com wrote:

 I am looking to continue to learn Haskell while working on something that
 might eventually be useful to others and get posted on Hackage. I have
 written quite a bit of Haskell code now, some useful and a lot just throw
 away for learning. In the past others have expressed interest in having a
 native Haskell sparse matrix and linear algebra library available(not just
 bindings to a C lib). This in combination with FEM is one of my interests.
 So my questions, is anyone currently working on a project like this? Does
 it
 seem like a good project/addition to the community? I'm also interested if
 anyone has any other project idea's, maybe even to collaborate on. Thanks



 --
 View this message in context:
 http://haskell.1045720.n5.nabble.com/Is-anyone-working-on-a-sparse-matrix-library-in-Haskell-tp5721452.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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

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


Re: [Haskell-cafe] How to incrementally update list

2012-11-30 Thread Kim-Ee Yeoh
On Sat, Dec 1, 2012 at 1:16 AM, Mark Thom markjordant...@gmail.com wrote:

  Is there a paper or other single resource that will help me thoroughly
understand non-strictness in Haskell?

If performance is utterly vital the best resource is Core, as in, the
ability to read it. The order of evaluation is all laid out there. Don [1]
and Johan [2] have written variously about it.

[1] http://stackoverflow.com/questions/6121146/reading-ghc-core
[2]
http://blog.johantibell.com/2012/02/forcing-values-returned-from-monadic.html


-- Kim-Ee


On Sat, Dec 1, 2012 at 1:16 AM, Mark Thom markjordant...@gmail.com wrote:


 Haskell's laziness is tricky to understand coming from imperative
 languages, but once you figure out its evaluation rules, you'll begin to
 see the elegance.


 Is there a paper or other single resource that will help me thoroughly
 understand non-strictness in Haskell? Once my programs hit a certain level
 of complexity, their behaviour becomes much harder for me to predict. I've
 been using the wiki pages up to this point, but apparently they haven't
 pushed my understanding of laziness nearly far enough.

 ___
 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] Simple GUI Form

2012-11-30 Thread Rune Harder Bak
 Of course.  There is no reason to think that FRP is limited to real-time
 applications with complicated interactions.
(...)
 there is a somewhat comprehensive tutorial [1] as well
 as lots of examples [2] linked from the wiki.

Thank you for the links. I read it and looked at the examples.
It seems you still need to build up the wx gui the same way
as using wx directly and be sure it is in sync with the datatype.
You just handle the logic with reactive-banana.
As there really is almost no logic involved it gives too much overhead,
needing to convert all the widgets to behaviors etc.

I got the form working in wx, so I'll stick with that for now!
Thanks!

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


Re: [Haskell-cafe] Simple GUI Form

2012-11-30 Thread Rune Harder Bak
 I know it's not wx, but if you were willing to use GTK, you could simply
 install:

 http://hackage.haskell.org/package/gtk-jsinput

 and generate the form automatically as described in:

 https://github.com/timthelion/gtk-jsinput/blob/master/Graphics/UI/Gtk/Custom/JSInput.hs

Cool!

Would rather see it generated from the haskell data structure than from json,
but you could of cause generate json from the data type.

My understand is that GTK applications don't look and feel native on
windows/mac, that's why I went for wx,
but I could easily be wrong.

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


Re: [Haskell-cafe] How to incrementally update list

2012-11-30 Thread KC
Why do you want to incrementally update this list a lot of times?

The question would affect the answer you get; i.e. some context
(non-monadically speaking). :D


On Wed, Nov 28, 2012 at 3:43 AM, Branimir Maksimovic bm...@hotmail.com wrote:
 Problem is following short program:
 list = [1,2,3,4,5]

 advance l = map (\x - x+1) l

 run 0 s = s
 run n s = run (n-1) $ advance s

 main = do
 let s =  run 5000 list
 putStrLn $ show s

 I want to incrementally update list lot of times, but don't know
 how to do this.
 Since Haskell does not have loops I have to use recursion,
 but problem is that recursive calls keep previous/state parameter
 leading to excessive stack.and memory usage.
 I don't know how to tell Haskell not to keep previous
 state rather to release so memory consumption becomes
 managable.

 Is there some solution to this problem as I think it is rather
 common?


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




-- 
--
Regards,
KC

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


[Haskell-cafe] ANN: zeromq3-conduit, Conduit bindings for zeromq3-haskell

2012-11-30 Thread Nicolas Trangez
Hi,

I published zeromq3-conduit, a small library which facilitates using
zeromq3-haskell, a binding for ZeroMQ 3.x, in a Conduit-based
application.

The 'examples' folder in the source repository contains ports of the
zeromq3-haskell examples.

The library also contains a module which might ease using plain
zeromq3-haskell: it lifts some of the IO actions into MonadIO and
provides a ReaderT which carries a Context around, so sockets can be
created without passing this around explicitly.

Package is on Hackage [1] and Github [2]. Comments/feedback/pull
requests/... welcome!

Nicolas

[1] http://hackage.haskell.org/package/zeromq3-conduit
[2] https://github.com/NicolasT/zeromq3-conduit/


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


Re: [Haskell-cafe] Is anyone working on a sparse matrix library in Haskell?

2012-11-30 Thread Mark Flamer
Thanks for all the replies,
 It sounds like there is enough interest and even some potential
collaborators out there. I have created a few data structures to represent
sparse vectors and matrices. The vector was a simple binary tree and the
matrix a quad tree. As I suspected a standard IntMap was around 3X as fast
as my binary tree, so I have switched to the IntMap for now. I was hoping to
hold on to my quad tree for the matrix rep. because I like the elegance of
the recursive algorithms like Strassen’s for multiplication. In the end it
will most likely be best to have a few different matrix representations
anyway. For instance, I know that compressed row form is most efficient for
certain algorithms. I have a Gauss iterative solver working currently and am
thinking of moving on to a parallel Conjugate gradient or direct solver
using LU decomposition. I’m no expert in Haskell or numeric methods but I do
my best. I’ll clean up what I have and open up the project on Github or
Bitbucket. Any other thoughts or ideas are welcome. 
I’m currently using the Matrix Market files for testing. It would be nice to
benchmark this against an industry standard solver in C or Fortran, without
having to do a lot of work to set it up. Does anyone know of an easy way to
do this? I’m just trying to get results to compare in orders of magnitude
for now. It would be motivating to see these comparisons.




--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Is-anyone-working-on-a-sparse-matrix-library-in-Haskell-tp5721452p5721556.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Ben Franksen
Gershom Bazerman wrote:
 On 11/30/12 10:44 AM, Dan Doel wrote:

 Lists! The finite kind.

 This could mean Seq for instance.

 On Nov 30, 2012 9:53 AM, Brent Yorgey byor...@seas.upenn.edu 
 mailto:byor...@seas.upenn.edu wrote:


 Any data type which admits structures of arbitrary but *only finite*
 size has a natural zippy Apply instance but no Applicative (since
 pure would have to be an infinite structure).  The Map instance I
 mentioned above falls in this category.  Though I guess I'm having
 trouble coming up with other examples, but I'm sure some exist.  
Maybe
 Edward knows of other examples.

 
 Another common case would be an embedded DSL representing code in a 
 different language, targeting a different platform (or even an FPGA or 
 the like), etc. You can apply `OtherLang (a - b)` to an `OtherLang a` 
 and get an `OtherLang b`, but you clearly can't promote (or lower, I 
 guess) an arbitrary Haskell function into a function in your target 
 language. This is the same reason that GArrows remove the `arr` function 
 (http://www.cs.berkeley.edu/~megacz/garrows/).

A fine example! And I am getting the drift... yes, this could be a useful 
abstraction.

Now, on to Bind: the standard finite structure example for Bind is most 
probably the substitution thingy, i.e. if m :: m a, f :: a - m b, then m 
= f means replace all elements x :: a in m with f x and then flatten the 
result so it's an m b again. Like concatMap for lists, right? So, there is 
no return for that in the Map case for exactly the same reason as with 
Apply: the unit would have have value id for every possible key, so cannot 
be finite.

So what about an example for Bind\\Monad that is not yet another variation 
of the finite structure theme?

Cheers
-- 
Ben Franksen
()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments


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


Re: [Haskell-cafe] Is anyone working on a sparse matrix library in Haskell?

2012-11-30 Thread Carter Schonwald
I look forward to see what comes of this!



On Fri, Nov 30, 2012 at 4:58 PM, Mark Flamer m...@flamerassoc.com wrote:

 Thanks for all the replies,
  It sounds like there is enough interest and even some potential
 collaborators out there. I have created a few data structures to represent
 sparse vectors and matrices. The vector was a simple binary tree and the
 matrix a quad tree. As I suspected a standard IntMap was around 3X as fast
 as my binary tree, so I have switched to the IntMap for now. I was hoping
 to
 hold on to my quad tree for the matrix rep. because I like the elegance of
 the recursive algorithms like Strassen’s for multiplication. In the end it
 will most likely be best to have a few different matrix representations
 anyway. For instance, I know that compressed row form is most efficient for
 certain algorithms. I have a Gauss iterative solver working currently and
 am
 thinking of moving on to a parallel Conjugate gradient or direct solver
 using LU decomposition. I’m no expert in Haskell or numeric methods but I
 do
 my best. I’ll clean up what I have and open up the project on Github or
 Bitbucket. Any other thoughts or ideas are welcome.
 I’m currently using the Matrix Market files for testing. It would be nice
 to
 benchmark this against an industry standard solver in C or Fortran, without
 having to do a lot of work to set it up. Does anyone know of an easy way to
 do this? I’m just trying to get results to compare in orders of magnitude
 for now. It would be motivating to see these comparisons.




 --
 View this message in context:
 http://haskell.1045720.n5.nabble.com/Is-anyone-working-on-a-sparse-matrix-library-in-Haskell-tp5721452p5721556.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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

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


Re: [Haskell-cafe] computation over containers, greatly simplified notation.

2012-11-30 Thread Takayuki Muranushi
Dear everyone,

After a number of attempts [1] I'm starting to think that my initial
approach was ill-directed.

After all, Functor, Applicative, Zip are three different classes.
Functors are type constructors where you can map unary functions over them.
Applicatives are those with map-over of zero-ary functions (pure,) unary
functions, binary functions, ternary functions, ... etc.
Zip are those with unary, binary, ternary ... mapover, but not zero-ary
map-over.

Repa Arrays and Vectors belong to Zip because there's no trivial unique way
to implement pure.

What the customer really needed [2] seems to be the following series of
functions:

forLiftZ1 :: Zip f = f a - (a - b) - f b
forLiftZ2 :: Zip f = f a - f b - (a - b - c) - f c

forLiftZ3 :: Zip f = f a - f b - f c - (a - b - c - d) - f d

Now I'm trying if it's possible to implement the series in a single shot
[3] .

I'm reporting my progress for anyone who might be still thinking for me.
Thank you!!

[1] https://github.com/nushio3/practice/tree/master/free-objects
[2] http://www.projectcartoon.com/cartoon/3
[3] https://github.com/nushio3/practice/blob/master/free-objects/printf6.hs



2012/11/29 Takayuki Muranushi muranu...@gmail.com

 Dear all,

 I came up with an idea to greatly simplify some kinds of array
 computations. It should work well with many kinds of arrays. Is this new?

 https://gist.github.com/4162375



 These few days, I've been trying to rewrite a hydrodynamic simulation code
 that used Data.Vector (~250 lines), to Repa [1] . It seemed promising, but
 soon I realized that I needed to use Repa.map and Repa.zipWith almost
 everywhere. I need careful thinking to transform every lines (that used
 vector's indexing) to Repa's point-free stile. Is there any better ways?

 Then I realized that I was the author of Paraiso [2], a DSL for stencil
 computation. One of its feature is to write down array computation just as
 if it were scalar computation.

 Basically what I need is ZipList-like Applicative instances for vectors
 and Repa arrays. Why not they support ZipVector? Because 'pure' of zipList
 was an infinite list and you can't do infinite vectors. Then I came up with
 this idea.

 https://gist.github.com/4162375

 the wrapper W does several things: it represents the 'pure,' homogeneous
 array in a space-efficient manner, and also serves as a newtype-wrapper of
 Num (and possibly Fractional, Floating...) instances.

 Questions are: is this technology new? or promising? doomed?
 It seems to me like a free-Applicative, like the free-Monad theory. Are
 they related?
 The function 'backend' helps to mix in the non-zip-like computations. How
 can we remove the 'undefined' in the 'backend?'
 Some of Repa computations are Monads. W needs to be a monad transformer to
 incooperate this.

 Also I'm grateful to past cafe discussion on existing Zippable
 implementations [3][4] .

 [1] hackage.haskell.org/package/repa
 [2] http://hackage.haskell.org/package/Paraiso
 [3] http://www.haskell.org/pipermail/haskell-cafe/2009-July/064403.html
 [4]
 http://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Functor-Zip.html


 --
 Takayuki MURANUSHI
 The Hakubi Center for Advanced Research, Kyoto University
 http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html




-- 
Takayuki MURANUSHI
The Hakubi Center for Advanced Research, Kyoto University
http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] computation over containers, greatly simplified notation.

2012-11-30 Thread Jason Dagit
You might find this paper an interesting read: http://www.brics.dk/RS/01/10/

On Fri, Nov 30, 2012 at 4:43 PM, Takayuki Muranushi muranu...@gmail.comwrote:

 Dear everyone,

 After a number of attempts [1] I'm starting to think that my initial
 approach was ill-directed.

 After all, Functor, Applicative, Zip are three different classes.
 Functors are type constructors where you can map unary functions over them.
 Applicatives are those with map-over of zero-ary functions (pure,) unary
 functions, binary functions, ternary functions, ... etc.
 Zip are those with unary, binary, ternary ... mapover, but not zero-ary
 map-over.

 Repa Arrays and Vectors belong to Zip because there's no trivial unique
 way to implement pure.

 What the customer really needed [2] seems to be the following series of
 functions:


 forLiftZ1 :: Zip f = f a - (a - b) - f b

 forLiftZ2 :: Zip f = f a - f b - (a - b - c) - f c


 forLiftZ3 :: Zip f = f a - f b - f c - (a - b - c - d) - f d

 Now I'm trying if it's possible to implement the series in a single shot
 [3] .

 I'm reporting my progress for anyone who might be still thinking for me.
 Thank you!!

 [1] https://github.com/nushio3/practice/tree/master/free-objects
 [2] http://www.projectcartoon.com/cartoon/3
 [3]
 https://github.com/nushio3/practice/blob/master/free-objects/printf6.hs




 2012/11/29 Takayuki Muranushi muranu...@gmail.com

 Dear all,

 I came up with an idea to greatly simplify some kinds of array
 computations. It should work well with many kinds of arrays. Is this new?

 https://gist.github.com/4162375



 These few days, I've been trying to rewrite a hydrodynamic simulation
 code that used Data.Vector (~250 lines), to Repa [1] . It seemed promising,
 but soon I realized that I needed to use Repa.map and Repa.zipWith almost
 everywhere. I need careful thinking to transform every lines (that used
 vector's indexing) to Repa's point-free stile. Is there any better ways?

 Then I realized that I was the author of Paraiso [2], a DSL for stencil
 computation. One of its feature is to write down array computation just as
 if it were scalar computation.

 Basically what I need is ZipList-like Applicative instances for vectors
 and Repa arrays. Why not they support ZipVector? Because 'pure' of zipList
 was an infinite list and you can't do infinite vectors. Then I came up with
 this idea.

 https://gist.github.com/4162375

 the wrapper W does several things: it represents the 'pure,' homogeneous
 array in a space-efficient manner, and also serves as a newtype-wrapper of
 Num (and possibly Fractional, Floating...) instances.

 Questions are: is this technology new? or promising? doomed?
 It seems to me like a free-Applicative, like the free-Monad theory. Are
 they related?
 The function 'backend' helps to mix in the non-zip-like computations. How
 can we remove the 'undefined' in the 'backend?'
 Some of Repa computations are Monads. W needs to be a monad transformer
 to incooperate this.

 Also I'm grateful to past cafe discussion on existing Zippable
 implementations [3][4] .

 [1] hackage.haskell.org/package/repa
 [2] http://hackage.haskell.org/package/Paraiso
 [3] http://www.haskell.org/pipermail/haskell-cafe/2009-July/064403.html
 [4]
 http://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Functor-Zip.html


 --
 Takayuki MURANUSHI
 The Hakubi Center for Advanced Research, Kyoto University
 http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html




 --
 Takayuki MURANUSHI
 The Hakubi Center for Advanced Research, Kyoto University
 http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html

 ___
 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] Can a GC delay TCP connection formation?

2012-11-30 Thread Jeff Shaw

On 11/30/2012 1:29 PM, Bryan O'Sullivan wrote:
On Tue, Nov 27, 2012 at 11:02 AM, Jeff Shaw shawj...@gmail.com 
mailto:shawj...@gmail.com wrote:


Once each minute, a thread of my program updates a global state,
stored in an IORef, and updated with atomicModifyIORef', based on
query results via HDBC-obdc.


Incidentally, what kind of database are you talking to? Issues of FFI 
correctness aside, HDBC is in general terribly slow compared to some 
of the more DB-specific bindings.

I'm connecting to a MS SQL Server 2008 R2 DBMS via Free TDS.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-30 Thread Kim-Ee Yeoh
Ben,

 Now, on to Bind: the standard finite structure example for Bind is
most probably the substitution thingy ...

Danger of conflating a bunch of things here:

(1) the substitution monadic effect is always also applicative and always
also unital/pointed because monads are always applicative and pointed.

(2) the zippy applicative effect is NOT monadic (see main applicative paper)

(3) for finite structures, there's even a
pre-applicative-but-still-zippy-ish Apply effect that's apparently NOT
unital/pointed. I don't know of any results that crystallize this intuition
about finite/infinite cleanly distributing itself into Applicative and
Apply bins.

(4) all the above has thus far been functors! Gershom has explained a use
case where Apply isn't even one.

HTH,
-- Kim-Ee


On Sat, Dec 1, 2012 at 5:00 AM, Ben Franksen ben.frank...@online.de wrote:

 Gershom Bazerman wrote:
  On 11/30/12 10:44 AM, Dan Doel wrote:
 
  Lists! The finite kind.
 
  This could mean Seq for instance.
 
  On Nov 30, 2012 9:53 AM, Brent Yorgey byor...@seas.upenn.edu
  mailto:byor...@seas.upenn.edu wrote:
 
 
  Any data type which admits structures of arbitrary but *only finite*
  size has a natural zippy Apply instance but no Applicative (since
  pure would have to be an infinite structure).  The Map instance I
  mentioned above falls in this category.  Though I guess I'm having
  trouble coming up with other examples, but I'm sure some exist.
 Maybe
  Edward knows of other examples.
 
 
  Another common case would be an embedded DSL representing code in a
  different language, targeting a different platform (or even an FPGA or
  the like), etc. You can apply `OtherLang (a - b)` to an `OtherLang a`
  and get an `OtherLang b`, but you clearly can't promote (or lower, I
  guess) an arbitrary Haskell function into a function in your target
  language. This is the same reason that GArrows remove the `arr` function
  (http://www.cs.berkeley.edu/~megacz/garrows/).

 A fine example! And I am getting the drift... yes, this could be a useful
 abstraction.

 Now, on to Bind: the standard finite structure example for Bind is most
 probably the substitution thingy, i.e. if m :: m a, f :: a - m b, then m
 = f means replace all elements x :: a in m with f x and then flatten the
 result so it's an m b again. Like concatMap for lists, right? So, there is
 no return for that in the Map case for exactly the same reason as with
 Apply: the unit would have have value id for every possible key, so cannot
 be finite.

 So what about an example for Bind\\Monad that is not yet another variation
 of the finite structure theme?

 Cheers
 --
 Ben Franksen
 ()  ascii ribbon campaign - against html e-mail
 /\  www.asciiribbon.org   - against proprietary attachments


 ___
 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