Re: [Haskell-cafe] DFAs and self-referential data

2010-12-28 Thread oleg

Maxime Henrion wrote:
 I've been playing with some code to work with DFAs, but I'm now faced
 with an implementation problem.  In order to have states that can
 transition to themselves, it seems I would need self-referential data;
 otherwise I would need to separate those transitions from the rest and
 handle them specially in the code.

Perhaps an old article
http://okmij.org/ftp/misc.html#ccard-transform

might be of some help. The article describes not only running a finite
automaton (represented as a cyclic graph) on given input but also
printing the automaton out and determinizing it: converting NFA to an
equivalent DFA. The latter operation converts one cyclic graph to
another.

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


Re: [Haskell-cafe] DFAs and self-referential data

2010-12-28 Thread Jason Dagit
On Tue, Dec 28, 2010 at 3:09 AM, o...@okmij.org wrote:


 Maxime Henrion wrote:
  I've been playing with some code to work with DFAs, but I'm now faced
  with an implementation problem.  In order to have states that can
  transition to themselves, it seems I would need self-referential data;
  otherwise I would need to separate those transitions from the rest and
  handle them specially in the code.

 Perhaps an old article
http://okmij.org/ftp/misc.html#ccard-transform

 might be of some help. The article describes not only running a finite
 automaton (represented as a cyclic graph) on given input but also
 printing the automaton out and determinizing it: converting NFA to an
 equivalent DFA. The latter operation converts one cyclic graph to
 another.


That link was a 404 for me.  I think you meant this link:
http://okmij.org/ftp/Haskell/misc.html#ccard-transform

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


[Haskell-cafe] Incrementially updating an array

2010-12-28 Thread Robert Clausecker
Hi folks!

I have the following problem. As code is most time easier to understand,
let give an example what I try to do in C:

unsigned int i,j;
unsigned int r[100];
for (i = 0; i  100; i++) {
  j = makeResult(); //j is known to be smaller than 100.
  r[j] = r[j] + 1;
}

(My C is poor, so please don't laugh)

Currently I'm using a Data.Map for this, but as the result is bounded in
this area, an array seems to be more appropreate. I don't want to mess
with mutable arrays, but I can't find anything which does the same like
Data.Map.insertWith for arrays in a reasonable way.

In my example, the input comes from a lazy list and is than folded into
the Map by insertWith (+) j 1 r. Is there any nice, quick way to do this
with Arrays without using mutable ones?

Yours, Robert Clausecker


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


Re: [Haskell-cafe] Incrementially updating an array

2010-12-28 Thread Henning Thielemann


On Tue, 28 Dec 2010, Robert Clausecker wrote:


Hi folks!

I have the following problem. As code is most time easier to understand,
let give an example what I try to do in C:

unsigned int i,j;
unsigned int r[100];
for (i = 0; i  100; i++) {
 j = makeResult(); //j is known to be smaller than 100.
 r[j] = r[j] + 1;
}

(My C is poor, so please don't laugh)

Currently I'm using a Data.Map for this, but as the result is bounded in
this area, an array seems to be more appropreate. I don't want to mess
with mutable arrays, but I can't find anything which does the same like
Data.Map.insertWith for arrays in a reasonable way.


Mutable arrays in ST monad sound like a reasonable choice.


In my example, the input comes from a lazy list and is than folded into
the Map by insertWith (+) j 1 r. Is there any nice, quick way to do this
with Arrays without using mutable ones?


You may attach a one to the list elements and then call Array.accum with 
(+). The corresponding function in Data.Map is Data.Map.fromListWith with 
(+).


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


Re: [Haskell-cafe] Incrementially updating an array

2010-12-28 Thread Ross Paterson
On Tue, Dec 28, 2010 at 08:46:24PM +0800, Robert Clausecker wrote:
 I have the following problem. As code is most time easier to understand,
 let give an example what I try to do in C:
 
 unsigned int i,j;
 unsigned int r[100];
 for (i = 0; i  100; i++) {
   j = makeResult(); //j is known to be smaller than 100.
   r[j] = r[j] + 1;
 }
 
 (My C is poor, so please don't laugh)
 
 Currently I'm using a Data.Map for this, but as the result is bounded in
 this area, an array seems to be more appropreate. I don't want to mess
 with mutable arrays, but I can't find anything which does the same like
 Data.Map.insertWith for arrays in a reasonable way.
 
 In my example, the input comes from a lazy list and is than folded into
 the Map by insertWith (+) j 1 r. Is there any nice, quick way to do this
 with Arrays without using mutable ones?

accumArray is designed for situations like this.

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


Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-28 Thread Tillmann Rendel

Hi,

Jonathan Geddes wrote:

For TH use #1, compile-time parsing of arbitrary strings, I think it
would be nice for quasiquote semantics to be modified so that code
like


json :: String -  JsonObject
json = ...

data = [ json |
{ name : Jonathan
, favorite language: Haskell
}
|]


causes the function json to be called at compile time with a string
argument of{\name\ : \Jonathan\\n   , \favorite language\:
\Haskell\\n   }. The whole expression being then replaced with the
result of the function application. What I like about this is that
defining quasiquoters is trivial. They're just functions of the form
String -  a. Many such quasiquoters already exist and would be ready
for use! I imagine certain rules would apply, ie a quasiquoter must be
defined prior to use and in a separate module, etc.


First note that this is just quotation, not yet quasiquotation. For 
quasiquotation, you would also need to support antiquotation (i.e., the 
use of Haskell identifiers or even expressions in the middle of quoted 
syntax). And to reach something similar to the current support for 
quasiquotation, you would need to support patterns etc., too.



Secondly, I was going to propose to use generic programming to convert 
from a parser like (String - JsonObject) to a quasiquoter for Json. But 
after half a day of experiments, I figured out that this idea is already 
developed in


  Geoffrey B. Mainland.
  Why It's Nice to be Quoted: Quasiquoting for Haskell.
  Haskell Workshop 2007

  Available at:

http://www.eecs.harvard.edu/~mainland/publications/mainland07quasiquoting.pdf

In that paper, Geoffrey Mainland explains how a parser can be 
generically upgraded to a quoter, reaching an intermediate conclusion on 
page 6:

By using generic programming, we can take a parser and create
expression and pattern quasiquoters for the language it parses with
only four lines of code, including type signatures! This holds not
just for our simple object language, but for any object language.


He goes on to explain how to add support for antiquotation [...] with 
only slightly more than four lines of code.



The functions dataToExpQ and dataToPatQ from that paper are available in 
the TH library in Language.Haskell.TH.Quote. A simple helper function


  quasiQuoter :: Data a = (String - Either String a) - QuasiQuoter
  quasiQuoter parser = QuasiQuoter
{ quoteExp = either fail (dataToExpQ (const Nothing)) . parse
, quotePat = either fail (dataToPatQ (const Nothing)) . parse
}

should allow you to write your JSON example as follows:

  parse :: String - Either String JsonObject
  parse = ...

  json = quasiQuoter parse

This seems simple enough to me, so it looks as if your use case is 
already supported as a library on top of the more general API.


  Tillmann

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


Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-28 Thread Jonathan Geddes
On Tue, Dec 28, 2010 at 8:17 AM, Tillmann Rendel
ren...@mathematik.uni-marburg.de wrote:
 This seems simple enough to me, so it looks as if your use case is already
 supported as a library on top of the more general API.

This is exactly what I was looking for, and much simpler than my
previous experiences with quasiQuoters.

In the original post I said, It may very well be that I am simply not
experienced enough with TH to fully appreciate and embrace it. More
and more I am thinking this is the case. I'll have to give TH a more
thorough look.

BTW, in addition to the resources already given, can anyone suggest
materials for my aforementioned more thorough look?

Thanks again for the responses.

--Jonathan

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


[Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Edward Amsden
Hello all:

I'd like to right a function that could take a structure with type
(random example):

(Int, (String, (Int, Int)))

and another where each individual value is a Maybe of the
corresponding type, for example:
(Maybe Int, (Maybe String, (Maybe Int, Maybe Int)))

and perform a fromMaybe using the values to produce a new value with
the original types. The catch is, I'd like to be able to do that for
an n-deep structure with any type, without having to write a separate
function for them. I'm not even sure that this is possible, but
perhaps someone could explain how it is or isn't?


-- 
Edward Amsden
Undergraduate
Computer Science
Rochester Institute of Technology
www.edwardamsden.com

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


[Haskell-cafe] Haskell for Gingerbread

2010-12-28 Thread Chris Kuklewicz
Hi folks,

  I have been looking at developing for my Android phone which is
running Gingerbread (Android version 2.3).  The important thing about
the official development kit is this:

The new native development kit (C/C++ cross compiler for ARM) is that
the you can create android applications from pure C without using the
Dalvik/Java virtual machine at all.  The thinking behind this was
probably for game developers to be able to avoid their VM.

So all that might be needed is a Haskell compiler with a C-backend that
emits ARM-compatible code and an initially minimal android runtime.
Implementing to the new native_activity.h allow for the usual
application life-cycle: onStart, onPause, onResume, onStop...

Some options I have not had a chance to look into:

1) GHC arm port and -via-C
2) jhc (and lhc) generated C
3) port nhc98
4) port yhc bytecode runtime

Does anyone know who else is thinking along any of these lines?  Are
there 5th or 6th routes to take?

Cheers,
  Chris Kuklewicz



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


Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Jake McArthur
Maybe something like this would work for you (requires the TypeFamilies 
extension).


class FromMaybe a where
  type Maybe' a
  fromMaybe :: a - Maybe' a - a

instance FromMaybe Int where
  type Maybe' Int = Maybe Int
  fromMaybe = Data.Maybe.fromMaybe

instance FromMaybe String where
  type Maybe' String = Maybe String
  fromMaybe = Data.Maybe.fromMaybe

instance (FromMaybe a, FromMaybe b) = FromMaybe (a, b) where
  type Maybe' (a, b) = (Maybe' a, Maybe' b)
  fromMaybe (x, y) (a, b) = (fromMaybe x a, fromMaybe y b)

- Jake McArthur

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


[Haskell-cafe] ghc +RTS -M and -A behaving strange

2010-12-28 Thread Johannes Waldmann
Hello.

When I run a program compiled with ghc-6.12.3 like this:

...  +RTS -A2G -M8G -s 

I get as an answer:

Heap exhausted;
Current maximum heap size is 0 bytes (0 MB);
use `+RTS -Msize' to increase it.

and when I put the options

... +RTS -A2000M -M8000M -s

I get 

Heap exhausted;
Current maximum heap size is 4093640704 bytes (3904 MB);
use `+RTS -Msize' to increase it.

and both numbers look strange.

The behaviour of the program is also strange (instead of heap exhausted
I'd expect it to do some smore garbage collections, which it does indeed without
the -A option)





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


Re: [Haskell-cafe] what is the status of haskell's mail libraries?

2010-12-28 Thread Robert Wills
I've finally gotten around to doing an update to HaskellNet which
provides along with some cleanups
integration with mime-mail.  There is an example of its usage at:

example/smtpMimeMail.hs

in

http://hackage.haskell.org/package/HaskellNet

-Rob

On Wed, Oct 27, 2010 at 11:05 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Wed, Oct 27, 2010 at 10:39 AM, Henk-Jan van Tuyl hjgt...@chello.nl wrote:
 On Wed, 27 Oct 2010 04:46:07 +0200, Michael Snoyman mich...@snoyman.com
 wrote:

 I just release mime-mail[1], which can construct multipart messages.

 Note, that this will not run on Windows, as it gives command
  /usr/sbin/sendmail

 The sendmail feature will not work on Windows (and you're right, I
 should document that more clearly). However, rendering of email
 messages is completely cross-platform, and there was some talk of
 getting either HaskellNet or SMTPClient to work with mime-mail, which
 would allow direct sending of email via SMTP.

 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] Haskell for Gingerbread

2010-12-28 Thread austin seipp
There was work ongoing for an ARM port of GHC. See here:

http://tommd.wordpress.com/2010/01/19/ghc-on-arm/

Also see:

http://alpheccar.org/en/posts/show/94

Alpheccar's build uses the work of Stephen Blackheath to cross
compile, which originated in the GHC-iPhone project, based on ghc
6.10.2 I believe. They are both based on the unregistered C backend,
i.e. using the -fvia-C backend.

None of this work has been accepted upstream as of me typing this, as
far as I know. Certainly the large majority of Stephen's work is not
in GHC (in particular things like the POOLSIZE wrapper, which is a
workaround for not being able to generate code at runtime via libffi,
because the iPhone doesn't allow it. I don't think Android has the
same restrictions, here.)

There are some plans underway for adding cross compilation support to
the GHC build system, see here:

http://hackage.haskell.org/trac/ghc/wiki/CrossCompilation

In particular this avoids the need for non-standard and painful build
setups like alpheccar went through, or the peculiar dance that e.g.
HalVM has to go through to cross compile GHC for Xen.

Overwhelmingly, I would say focusing efforts on GHC is the way to go.
JHC is fiddly (and still fails badly on some simple programs,) ditto
for LHC which is highly experimental and not quite as portable. nhc98
would probably be a good baseline, but the lack of language extensions
and support from the community probably means you're not going to get
a lot to work with it. yhc seems unmaintained. GHC also generates
better code than pretty much anything else, too (except when JHC
manages to actually work.) GHC is what everybody uses and knows, so it
seems best to focus efforts here.

Getting GHC to actually support cross compilation in the build system
is IMO probably the biggest thing that needs to be done, before any
sort of registered ARM port, or adding support for android to the
runtime (if that would even be necessary, I have not looked at the
Android Gingerbread NDK notes - it may be possible to just have a
library that takes care of interfacing with the NDK.) I say this
because I think GHC being cross compilable is ultimately a much
greater goal than just a port to work on Android/ARM (even debian has
had unregistered arm/armel GHC builds for a while, IIRC) and would
make using GHC with more exotic toolchains much, much easier (android
included.) Until then, your only hope is porting the unregistered
compiler, which can be quite frustrating and delicate (and doesn't
always work - see the GHC wiki page on Porting.)

Perhaps we should be paging Mr. Simon Marlow in here, since he can
probably give a better and more concrete answer.

On Tue, Dec 28, 2010 at 1:27 PM, Chris Kuklewicz
hask...@list.mightyreason.com wrote:
 Hi folks,

  I have been looking at developing for my Android phone which is
 running Gingerbread (Android version 2.3).  The important thing about
 the official development kit is this:

 The new native development kit (C/C++ cross compiler for ARM) is that
 the you can create android applications from pure C without using the
 Dalvik/Java virtual machine at all.  The thinking behind this was
 probably for game developers to be able to avoid their VM.

 So all that might be needed is a Haskell compiler with a C-backend that
 emits ARM-compatible code and an initially minimal android runtime.
 Implementing to the new native_activity.h allow for the usual
 application life-cycle: onStart, onPause, onResume, onStop...

 Some options I have not had a chance to look into:

 1) GHC arm port and -via-C
 2) jhc (and lhc) generated C
 3) port nhc98
 4) port yhc bytecode runtime

 Does anyone know who else is thinking along any of these lines?  Are
 there 5th or 6th routes to take?

 Cheers,
  Chris Kuklewicz



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




-- 
Regards,
Austin

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


Re: [Haskell-cafe] Haskell for Gingerbread

2010-12-28 Thread John Meacham
jhc generated C works on the android/ARM just fine. Android specific
libraries arn't available, so you would have to bind to what you want
with the FFI.

John

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


Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Stephen Tetley
On 28 December 2010 19:23, Edward Amsden eca7...@cs.rit.edu wrote:
 Hello all:

 I'd like to right a function that could take a structure with type
 (random example):

 (Int, (String, (Int, Int)))

 and another where each individual value is a Maybe of the
 corresponding type, for example:
 (Maybe Int, (Maybe String, (Maybe Int, Maybe Int)))

 and perform a fromMaybe using the values to produce a new value with
 the original types. The catch is, I'd like to be able to do that for
 an n-deep structure with any type, without having to write a separate
 function for them. I'm not even sure that this is possible, but
 perhaps someone could explain how it is or isn't?



Maybe this is possible with Strafunski or one of the generics
libraries that lean in that direction (SYB, KURE, or Oleg Kiselyov's
typecase), though I've never looked at descending into two terms at
the same time even if they have the same type shape.

http://okmij.org/ftp/Haskell/typecast.html

At a meta-level do you have a need for this, or is it just a
curiosity? If it is for some real world situation, I suspect there are
simpler ways of achieving the functionality you seem to want.

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


Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread aditya siram
Although I don't understand it myself Oleg's deepest functor [1] seems
to be what you're looking for.
-deech

[1] http://okmij.org/ftp/Haskell/deepest-functor.lhs

On Tue, Dec 28, 2010 at 1:23 PM, Edward Amsden eca7...@cs.rit.edu wrote:
 Hello all:

 I'd like to right a function that could take a structure with type
 (random example):

 (Int, (String, (Int, Int)))

 and another where each individual value is a Maybe of the
 corresponding type, for example:
 (Maybe Int, (Maybe String, (Maybe Int, Maybe Int)))

 and perform a fromMaybe using the values to produce a new value with
 the original types. The catch is, I'd like to be able to do that for
 an n-deep structure with any type, without having to write a separate
 function for them. I'm not even sure that this is possible, but
 perhaps someone could explain how it is or isn't?


 --
 Edward Amsden
 Undergraduate
 Computer Science
 Rochester Institute of Technology
 www.edwardamsden.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] Polymorphic function over pairs of maybes.

2010-12-28 Thread Max Rabkin
On Tue, Dec 28, 2010 at 21:23, Edward Amsden eca7...@cs.rit.edu wrote:
 (Int, (String, (Int, Int)))

 and another where each individual value is a Maybe of the
 corresponding type, for example:
 (Maybe Int, (Maybe String, (Maybe Int, Maybe Int)))

This example demonstrates exactly why you might want to avoid doing
this... if you apply Maybe as deeply inside type constructors as
possible, you actually get

(Maybe Int, ([Maybe Char], (Maybe Int, Maybe Int)))

and in general you may not know or care whether a type is atomic or not.

There may be a way which works if you specify the target type as well.

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


Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Edward Amsden
Aditya: Not quite, because I'm actually looking to extract values from
a functor (Maybe) with a default.

Stephen: Thanks, I'll take a look at those. I do have a need for it.
I'm writing a very similar library to Yampa. (I would be patching
Yampa, but the code is a mess, so I decided to try starting from
scratch.)
Basically, I have a signal processing loop, where values are passed
updated with a Maybe, representing whether there is or is not a change
to the value. I could use a single Maybe around the whole thing, but
that would require then re-updating a potentially large structure
entirely. I want to be able to build a combinator that can combine two
signal-fetching actions into a larger one:

IO (Maybe a) - IO (...) - IO (Maybe a, (...))

and then an action that could, given the previous value:
(a, (...))

update any places in this chain of pairs where the Maybe is not Nothing.

Jake: I'd prefer to not have to define class instances for the types.
It would get tedious and awkward quickly. (See above for a description
of what I'm looking for.)

-- 
Edward Amsden
Undergraduate
Computer Science
Rochester Institute of Technology
www.edwardamsden.com

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


[Haskell-cafe] multi type addition

2010-12-28 Thread william murphy
We were trying to make an addition function that, unlike the library one,
could add numbers of different types from the typeclass 'Num.' We originally
ran into a problem when trying to add (5 :: Integer) + 4.8, and were trying
to define a new function that would be able to get that:

(+') :: (Num a, Num b) = a - b - Float
x +' b = d + e
 where d :: Float
   d = x
   e :: Float
   e = b


This gave us the error:

Couldn't match expected type `Float' against inferred type `b'
  `b' is a rigid type variable bound by
  the type signature for `pl' at test.hs:9:18
In the expression: b
In the definition of `e': e = b
In the definition of `pl':
pl x b
 = d + e
 where
 d :: Float
 d = x
 e :: Float
 e = b
Failed, modules loaded: none.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Sterling Clover
 Basically, I have a signal processing loop, where values are passed
 updated with a Maybe, representing whether there is or is not a change
 to the value. I could use a single Maybe around the whole thing, but
 that would require then re-updating a potentially large structure
 entirely. I want to be able to build a combinator that can combine two
 signal-fetching actions into a larger one:
 
 IO (Maybe a) - IO (...) - IO (Maybe a, (...))
 
 and then an action that could, given the previous value:
 (a, (...))
 
 update any places in this chain of pairs where the Maybe is not Nothing.


Sounds like you want a generic diff: 
http://hackage.haskell.org/package/gdiff-1.0

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


Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Stephen Tetley
On 28 December 2010 21:44, Edward Amsden eca7...@cs.rit.edu wrote:
[SNIP]

 I'm writing a very similar library to Yampa. (I would be patching
 Yampa, but the code is a mess, so I decided to try starting from
 scratch.)
 Basically, I have a signal processing loop, where values are passed
 updated with a Maybe, representing whether there is or is not a change
 to the value. I could use a single Maybe around the whole thing, but
 that would require then re-updating a potentially large structure
 entirely. I want to be able to build a combinator that can combine two
 signal-fetching actions into a larger one:


Hi Edward

That's a tough proposition - phrased in a different way, you want
syntax (i.e algebraic data types) with holes. Functors (List,
Data.Sequence, ...) and Bifunctors (pairs and Either, ...) have
obvious holes, and working with holey things is possible[*] but its
probably way too far out for signal processing where you have
efficiency concerns.

Is it common for Reactive libraries like Yampa to operate on a large
World datatype - rather than streams of signals of some atomic unit
like Double? If it were me, I'd want to answer this question first
before attempting to represent it.


[*] See Conor McBride's Clowns and Jokers for instance:
http://personal.cis.strath.ac.uk/~conor/Dissect.pdf

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


Re: [Haskell-cafe] multi type addition

2010-12-28 Thread aditya siram
The problem here is that unfortunately the Haskell type system cannot
do coercion.

There is however a toRational method Real typeclass that converts
instances of Num and Ord to Rational data type and a fromRational
method that converts back. So your code could be:

myplus :: (Real a, Real b) = a - b - Float
a `myplus` b = fromRational(toRational a + toRational b)

 (1 :: Integer) `myplus` (2::Integer)
3.0
 (1.5 :: Float) `myplus` (2::Integer)
3.5

-deech

[1] 
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#t:Real
[2] 
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#t:Rational

On Tue, Dec 28, 2010 at 3:45 PM, william murphy will.t.mur...@gmail.com wrote:
 We were trying to make an addition function that, unlike the library one,
 could add numbers of different types from the typeclass 'Num.' We originally
 ran into a problem when trying to add (5 :: Integer) + 4.8, and were trying
 to define a new function that would be able to get that:

 (+') :: (Num a, Num b) = a - b - Float
 x +' b = d + e
  where d :: Float
    d = x
    e :: Float
    e = b


 This gave us the error:

     Couldn't match expected type `Float' against inferred type `b'
   `b' is a rigid type variable bound by
   the type signature for `pl' at test.hs:9:18
     In the expression: b
     In the definition of `e': e = b
     In the definition of `pl':
     pl x b
  = d + e
  where
  d :: Float
  d = x
  e :: Float
  e = b
 Failed, modules loaded: none.


 ___
 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] What's the motivation for η rul es?

2010-12-28 Thread David Sankel
TIA,

David

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


Re: [Haskell-cafe] What's the motivation for η rul es?

2010-12-28 Thread Luke Palmer
Eta conversion corresponds to extensionality; i.e. there is nothing
more to a function than what it does to its argument.

Suppose f x = g x for all x.  Then using eta conversion:

f = (\x. f x) = (\x. g x) = g

Without eta this is not possible to prove.  It would be possible for
two functions to be distinct (well, not provably so) even if they do
the same thing to every argument -- say if they had different
performance characteristics.  Eta is a controversial rule of lambda
calculus -- sometimes it is omitted, for example, Coq does not use it.
 It tends to make things more difficult for the compiler -- I think
Conor McBride is the local expert on that subject.


On Tue, Dec 28, 2010 at 4:12 PM, David Sankel cam...@gmail.com wrote:
 TIA,
 David

 --
 David Sankel
 Sankel Software
 www.sankelsoftware.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] What's the motivation for η rules?

2010-12-28 Thread Stefan Monnier
One way to look at it is that β rules are the application of an
eliminator (e.g. function application) to its corresponding constructor
(the lambda expression), whereas η rules correspond to the application
of a constructor to its corresponding eliminator.

E.g.

   λ y . (x y)=  x
   if x then True else False  =  x
   (π₁ x, π₂ x)   =  x

IOW there's no need for a motivation: those rules just appear naturally.


Stefan


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


Re: [Haskell-cafe] what is the status of haskell's mail libraries?

2010-12-28 Thread Michael Snoyman
This looks very good, thank you! One comment: do you think it would be
possible to add a function for sending a mime-mail Mail datatype
directly? I see that you provide a wrapper around simpleMail in your
sendMimeMail function, but that won't always be sufficient.

Michael

On Tue, Dec 28, 2010 at 9:46 PM, Robert Wills wrwi...@gmail.com wrote:
 I've finally gotten around to doing an update to HaskellNet which
 provides along with some cleanups
 integration with mime-mail.  There is an example of its usage at:

 example/smtpMimeMail.hs

 in

 http://hackage.haskell.org/package/HaskellNet

 -Rob

 On Wed, Oct 27, 2010 at 11:05 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Wed, Oct 27, 2010 at 10:39 AM, Henk-Jan van Tuyl hjgt...@chello.nl 
 wrote:
 On Wed, 27 Oct 2010 04:46:07 +0200, Michael Snoyman mich...@snoyman.com
 wrote:

 I just release mime-mail[1], which can construct multipart messages.

 Note, that this will not run on Windows, as it gives command
  /usr/sbin/sendmail

 The sendmail feature will not work on Windows (and you're right, I
 should document that more clearly). However, rendering of email
 messages is completely cross-platform, and there was some talk of
 getting either HaskellNet or SMTPClient to work with mime-mail, which
 would allow direct sending of email via SMTP.

 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


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


[Haskell-cafe] Having trouble with ftphs module

2010-12-28 Thread aXqd
Hi all:

I'm new to Haskell, and I ran into this problem recently while I am
using ftphs module downloaded from hackage.

Prelude :m Network.FTP.Client
Prelude Network.FTP.Client h - easyConnectFTP xxx.xxx.xxx.xxx
*** Exception: FTP: (unknown) (line 2, column 1):
unexpected \r
expecting \r\n or Code 220

I am not the administrator of this FTP server. Hence all I've been
told is that it is a Microsoft FTP Server.

I want to know 1. if this should be regarded as a bug of ftphs or not?
2. is there any other workaround other than the one below?

Possible workaround: Implement another BAT script to do the FTP work
and use system() to invoke it.

Thanks in advance.

-- 
Best regards,
-Tian

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