Re: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one!

2010-02-13 Thread Patai Gergely
> Seems like today FRP is the last word in game programming with Haskell.
> Do you know something that could be a good tutorial, or at least
> introduction to FRP ? Something that could somewhat help me learn the ropes,
> 'cause I'm afraid if I dive directly into your code I'm gonna be lost.
I don't think there's any material on FRP that could be considered a
general tutorial, because there are many flavours with smaller and
bigger differences, and no-one really seems to know how to program in
this manner beyond toy examples. So, for the time being, I'd probably
start with the original Fran paper [1], which is quite accessible in my
opinion, and even though some of the details are obsolete, it explains
the basics reasonably well. The Yampa Arcade [2] is probably the best
introduction to the arrow-based approach (AFRP). The new Reactive paper
[3] is not beginner friendly, but if you already grokked Fran, it
shouldn't be too hard to follow, and it describes a way to design an
applicative style reactive library with a much cleaner interface than
that of Fran.

Gergely

[1] http://conal.net/papers/icfp97/
[2] http://www.haskell.org/yale/papers/haskell-workshop03/index.html
[3] http://conal.net/papers/push-pull-frp/

-- 
http://www.fastmail.fm - A fast, anti-spam email service.

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


Re: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one!

2010-02-13 Thread Patai Gergely
> I tried it, but after briefly displaying a window, the program terminates  
> with the message:
>dow: user error (unknown OpenGL extension entry glTexParameteri, check  
> for OpenGL 3.1)
I just tried it under XP, using an unaltered Haskell Platform 2009.2.0.1
(GHC 6.10.3), and it compiled and worked out of the box. I got some
other error reports too (about segfaults under Linux), but I can't
reproduce any of them.

Gergely

-- 
http://www.fastmail.fm - Access your email from home and the web

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


[Haskell-cafe] Atom Examples

2010-02-13 Thread Tom Hawkins
On Sun, Feb 14, 2010 at 1:30 AM, Yves Parès  wrote:
>
> I've been interested in using Atom since I saw this:
> http://blog.sw17ch.com/wordpress/?p=84
> However those samples are very outdated, do you have newer ones?

Unfortunately, no.  I wish I had the time to write Atom examples and
tutorials, but I don't.

So in lieu of a tutorial, here's a few modules we use on our real
projects -- with limited documentation.

Arbiter.hs: A general purpose non-preemptive arbiter than implements
Lamport's bakery algorithm.  We use this to arbitrate multiple
software components that need to use the CAN protocol stacks for
sending multi-packet messages.  This is a good example that
illustrates some of the benefits of atomic state transitions rules.
What I find interesting is it works without any centralized arbiter
logic; notice there are no rule declarations in mkArbiter.

ECU.hs:  This is the hardware abstraction layer to our ECU.  Nothing
too interesting, but a good example of how to wire Atom up to external
C code.  Note the ECU record includes a bunch of expressions (E types)
and variables (V types).  The expressions form the inputs, like ADCs
and discrete inputs, and the mutable variables form the outputs, such
as PWMs and discrete outputs.  It also provides hooks to send and
receive CAN messages.

EVU.hs: The eVU is a little display mounted on the dash.  It presents
the driver with information such as charge pressure, mode settings,
and fault conditions.  The ECU talks to the eVU via the CAN bus.  This
is a good example because it illustrates a common object-oriented
pattern we tend to use all over the place:  the object contructor
(mkEVU) creates some state variables, defines rules for stuff to do,
and packages the state variables into an abstract type, or object
(EVU); then methods operate on this object.  In the case of EVU, the
object constructor defines variables for the things the eVU displays,
and it defines a rule to periodically send this information to the eVU
device via CAN.  And the methods set the various display elements such
as the active fault code (setCode), the accumulator pressure
(setCharge), and the active mode (setMode).

Sensors.hs:  Sensor processing, which takes data from the hardware
abstraction layer (ECU.hs).  One interesting feature is the oil
temperature sensor computation.  Based on a 1-D lookup table the
'lookup1D' function searches the table for the corresponding points
and performs interpolation.  In C, this probably would have been
written as a for-loop that would compute the lookup on every sample.
But because change in oil temperature is much slower than the sample
rate of the system, we only need to search one row of the table every
50 samples or so (i.e. with rules 'below', 'above', 'next', and
'found').  This effectively spreads out the computation over many
samples, thus lowering the processing latency of every sample.  Doing
this type of time-sharing in C would be tricky.  But in Atom, it's
trivial.  One of the many ways Atom benefits hard realtime
programming.

I hope this helps.

-Tom


AtomExamples.tar.gz
Description: GNU Zip compressed data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: atom-1.0.0

2010-02-13 Thread John Van Enk
Hmm... that's my outdated blog post. I've been meaning to add an updated
version. I'll try and get to that soon.

On Sat, Feb 13, 2010 at 7:30 PM, Yves Parès  wrote:

>
> I've been interested in using Atom since I saw this:
> http://blog.sw17ch.com/wordpress/?p=84
> However those samples are very outdated, do you have newer ones?
>
>
>
> Tom Hawkins-2 wrote:
> >
> > Atom is a Haskell DSL for designing hard realtime embedded software.
> > The 1.0 release is meant to indicate some level of stability; most of
> > the core has been unchanged for quite some time.
> >
> > That said, there are a few interesting changes in 1.0.  First the var'
> > family of variable declarations (bool', word8', double', etc.) are no
> > longer part of the Atom monad.  For example:
> >
> > bool' :: Name -> V Bool
> >
> > This cleaned up quite a bit of code in our production design.  This
> > also made the randomization in Atom's unit testing framework monadless
> > as well.
> >
> > The other significant change with 1.0 is all state variables are now
> > packed into a hierarchical C structure that matches the hierarchy of
> > the Atom design.  Not only does this make the generated C a bit more
> > legible, it is now possible to interface external C code directly to
> > Atom's state variables and arrays.  Prior to this change, all
> > interfacing had to be done through var' declarations and action calls
> > -- too often a messy process.  To further aid interfacing to external
> > code, Atom now generates a header file that exposes both the iterative
> > function and the hierarchical state structure.
> >
> > -Tom
> >
> > http://hackage.haskell.org/package/atom
> > ___
> > Haskell-Cafe mailing list
> > Haskell-Cafe@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> >
>
>
> -
> Yves Parès
>
> Live long and prosper
> --
> View this message in context:
> http://old.nabble.com/ANN%3A-atom-1.0.0-tp27574165p27579930.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] ANN: atom-1.0.0

2010-02-13 Thread Yves Parès

I've been interested in using Atom since I saw this:
http://blog.sw17ch.com/wordpress/?p=84
However those samples are very outdated, do you have newer ones?



Tom Hawkins-2 wrote:
> 
> Atom is a Haskell DSL for designing hard realtime embedded software.
> The 1.0 release is meant to indicate some level of stability; most of
> the core has been unchanged for quite some time.
> 
> That said, there are a few interesting changes in 1.0.  First the var'
> family of variable declarations (bool', word8', double', etc.) are no
> longer part of the Atom monad.  For example:
> 
> bool' :: Name -> V Bool
> 
> This cleaned up quite a bit of code in our production design.  This
> also made the randomization in Atom's unit testing framework monadless
> as well.
> 
> The other significant change with 1.0 is all state variables are now
> packed into a hierarchical C structure that matches the hierarchy of
> the Atom design.  Not only does this make the generated C a bit more
> legible, it is now possible to interface external C code directly to
> Atom's state variables and arrays.  Prior to this change, all
> interfacing had to be done through var' declarations and action calls
> -- too often a messy process.  To further aid interfacing to external
> code, Atom now generates a header file that exposes both the iterative
> function and the hierarchical state structure.
> 
> -Tom
> 
> http://hackage.haskell.org/package/atom
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 


-
Yves Parès

Live long and prosper
-- 
View this message in context: 
http://old.nabble.com/ANN%3A-atom-1.0.0-tp27574165p27579930.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] Re: How many "Haskell Engineer I/II/III"s are there?

2010-02-13 Thread Sean Leather
Hi Günther,


> about the Haskell Summer School,
>
> who can participate and what does it cost?
>
>>

> As second (but related) shameless plug, we also have a two-week-long
>> summer school which is an excellent way to jump-start the above master's
>> program or to get quickly up to speed on Haskell for business or
>> pleasure. The course is in August, and the deadline is May 1.
>>
>> http://www.utrechtsummerschool.nl/index.php?type=courses&code=H9
>>
>
The link above has all the details (more than I do) on the Utrecht Summer
School for Applied Functional Programming.

I don't believe there are any restrictions on who can participant, though
the course is geared towards advanced bachelor's and beginning master's
students. Since there are a limited number of spots, an applicant should try
to put together a convincing application (e.g. write a good letter of
motivation).

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


Re: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one!

2010-02-13 Thread Limestraël

Seems like today FRP is the last word in game programming with Haskell.
Do you know something that could be a good tutorial, or at least
introduction to FRP ? Something that could somewhat help me learn the ropes,
'cause I'm afraid if I dive directly into your code I'm gonna be lost.

Good job, by the way.


Yves Parès


Felipe Lessa wrote:
> 
> On Sat, Feb 13, 2010 at 09:49:53PM +0100, Henk-Jan van Tuyl wrote:
>> I tried it, but after briefly displaying a window, the program
>> terminates with the message:
>>   dow: user error (unknown OpenGL extension entry glTexParameteri,
>> check for OpenGL 3.1)
>>
>> I suppose the program needs a newer version than is supplied with
>> Windows (opengl.org states that Microsoft always includes an old
>> version of OpenGL [1])
>> Does anybody know how to deal with this?
> 
> Just a thought: maybe it is something else.  That function
> appears to exist since Windows 95 according msdn[1] and OpenGL
> 1.1[2].
> 
> [1] http://msdn.microsoft.com/en-us/library/dd368641(VS.85).aspx
> [2] http://www.talisman.org/opengl-1.1/Reference/glTexParameter.html
> 
> HTH,
> 
> --
> Felipe.
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 

-- 
View this message in context: 
http://old.nabble.com/ANN%3A-Dungeons-of-Wor---a-largish-FRP-example-and-a-fun-game%2C-all-in-one%21-tp27543827p27579234.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] Implementing "unionAll"

2010-02-13 Thread Leon Smith
With the urging and assistance of Omar Antolín Camarena,  I will be
adding two functions to data-ordlist:  mergeAll and unionAll,  which
merge (or union)  a potentially infinite list of potentially infinite
ordered lists,   under the assumption that the heads of the non-empty
lists appear in a non-decreasing sequence.

Union takes two sorted lists and produces a new sorted list;  an
element occurs in the result as many times as the maximum number of
occurrences in either list.   The unionAll function generalizes this
behavior to an infinite number of lists.

A reasonable implementation of mergeAll is:

> import Data.List.Ordered(merge, union)

> mergeAll :: Ord a => [[a]] -> [a]
> mergeAll = foldr (\(x:xs) ys -> x : merge xs ys) []

However,  for many inputs,  we can do better;   the library
implementation of mergeAll is based on H. Apfelmus's article "Implicit
Heaps",  which presents a simplification of Dave Bayer's "venturi"
algorithm.   The difference is that the foldr version uses a line of
comparisons, whereas "venturi" uses a tree of comparisons.

http://apfelmus.nfshost.com/articles/implicit-heaps.html
http://www.mail-archive.com/haskell-cafe@haskell.org/msg27612.html

However,  as Omar pointed out to me,  the following implementation of
unionAll has a flaw:

> unionAll :: Ord a => [[a]] -> [a]
> unionAll = foldr (\(x:xs) ys -> x : union xs ys) []

Namely unionAll [[1,2],[1,2]] should return [1,2],  whereas it
actually returns [1,1,2].   After some work,  I believe I have
generalized H. Apfelmus's algorithm to handle this;  however it seems
a bit complicated.   I would love feedback,  especially with regard to
simplifications,  bugs,  testing strategies,  and optimizations:

> unionAll' :: Ord a => [[a]] -> [a]
> unionAll' = unionAllBy compare

> data People a = VIP a (People a) | Crowd [a]

> unionAllBy :: (a -> a -> Ordering) -> [[a]] -> [a]
> unionAllBy cmp xss = loop [ (VIP x (Crowd xs)) | (x:xs) <- xss ]
>   where
> loop [] = []
> loop (  VIP x xs  :  VIP y ys  :  xss  )
>   = case cmp x y of
>   LT -> x : loop (  xs  :  VIP y ys  :  xss  )
>   EQ -> loop (  VIP x (union' xs ys)  :  unionPairs xss  )
>   GT -> error "Data.List.Ordered.unionAll:  assumption violated!"
> loop (  VIP x xs  :  xss  )
>   =  x : loop (xs:xss)
> loop [Crowd xs] = xs
> loop (xs:xss) = loop (unionPairs (xs:xss))
>
> unionPairs [] = []
> unionPairs [x] = [x]
> unionPairs (x:y:zs) = union' x y : unionPairs zs
>
> union' (VIP x xs) (VIP y ys)
>= case cmp x y of
>LT -> VIP x (union' xs (VIP y ys))
>EQ -> VIP x (union' xs ys)
>GT -> error "Data.List.Ordered.unionAll:  assumption violated!"
> union' (VIP x xs) (Crowd ys) = VIP x (union' xs (Crowd ys))
> union' (Crowd []) ys = ys
> union' (Crowd xs) (Crowd ys) = Crowd (unionBy cmp xs ys)
> union' xs@(Crowd (x:xt)) ys@(VIP y yt)
>= case cmp x y of
>LT -> VIP x (union' (Crowd xt) ys)
>EQ -> VIP x (union' (Crowd xt) yt)
>GT -> VIP y (union' xs yt)

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


[Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there?

2010-02-13 Thread Günther Schmidt

Hi Sean,

about the Haskell Summer School,

who can participate and what does it cost?

Günther


Am 10.02.10 17:26, schrieb Sean Leather:

  I wonder how many people actually write Haskell,
  principally or exclusively, at work?


I suppose you're implying non-academic jobs by that statement, but most
of the people in my research group develop programs in Haskell on a
daily basis. You'll find a number of libraries on Hackage from us.

http://www.cs.uu.nl/staff/cur/IDX/sds.html

As a shameless plug, I will also add that we have a great master's
program in which you can get your fill of Haskell and compilers, among
other things.

http://www.cs.uu.nl/wiki/Master/

As second (but related) shameless plug, we also have a two-week-long
summer school which is an excellent way to jump-start the above master's
program or to get quickly up to speed on Haskell for business or
pleasure. The course is in August, and the deadline is May 1.

http://www.utrechtsummerschool.nl/index.php?type=courses&code=H9


Regards,
Sean



___
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: Dungeons of Wor - a largish FRP example and a fun game, all in one!

2010-02-13 Thread Felipe Lessa
On Sat, Feb 13, 2010 at 09:49:53PM +0100, Henk-Jan van Tuyl wrote:
> I tried it, but after briefly displaying a window, the program
> terminates with the message:
>   dow: user error (unknown OpenGL extension entry glTexParameteri,
> check for OpenGL 3.1)
>
> I suppose the program needs a newer version than is supplied with
> Windows (opengl.org states that Microsoft always includes an old
> version of OpenGL [1])
> Does anybody know how to deal with this?

Just a thought: maybe it is something else.  That function
appears to exist since Windows 95 according msdn[1] and OpenGL
1.1[2].

[1] http://msdn.microsoft.com/en-us/library/dd368641(VS.85).aspx
[2] http://www.talisman.org/opengl-1.1/Reference/glTexParameter.html

HTH,

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


Re: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one!

2010-02-13 Thread Henk-Jan van Tuyl
On Thu, 11 Feb 2010 09:35:35 +0100, Patai Gergely  
 wrote:



I just uploaded the first public version of Dungeons of Wor [1], a



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


I tried it, but after briefly displaying a window, the program terminates  
with the message:
  dow: user error (unknown OpenGL extension entry glTexParameteri, check  
for OpenGL 3.1)


I suppose the program needs a newer version than is supplied with Windows  
(opengl.org states that Microsoft always includes an old version of OpenGL  
[1])

Does anybody know how to deal with this?

Regards,
Henk-Jan van Tuyl


[1] http://www.opengl.org/wiki/Getting_started#OpenGL_2.0.2B_and_extensions


--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there?

2010-02-13 Thread Simon Marlow

On 12/02/10 19:33, Andrew Coppin wrote:

Simon Marlow wrote:

On 11/02/2010 20:57, Alp Mestanogullari wrote:

It seems quite big for a 3 months project made by a student, though.


No kidding :-) I last rewrote the RTS in 1998:

but even so, it was about 20k lines.


Man, that's at least two orders of magnitude larger than anything I've
ever written in my entire life! And to think that's just the RTS - the
part of GHC that most people don't neven notice. ;-)

Did you really write all that code single-handedly?


Not entirely, I cribbed heavily from the old RTS which was written by 
various people but mostly Will Partain, and some was written by Alastair 
Reid who was working on porting Hugs to use GHC's RTS at the time - it 
was the death of that project that prompted us to build GHCi, which 
first appeared in GHC version 5.00.


Cheers,
Simon


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


[Haskell-cafe] Re: What is the meaning of tilde ("~") symbol

2010-02-13 Thread Maciej Piechotka
On Sat, 2010-02-13 at 14:03 +0100, kg wrote:
> Hi,
> 
> I'm reading the following subject :
> http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html
> 
> In the sample code, we can see :
> 
> instance ReadAsAnyOf () ex
>  where readAsAnyOf ~() = mzero
> 
> 
> 
> And, I've search the meaning of the symbol "~", but I've found nothing 
> about this (note that's not easy to search "~" on google ...)
> 
> Could you give me a link about this, or explain me it ?
> 
> Thx in advance.

http://www.haskell.org/tutorial/patterns.html - Section lazy patterns

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-13 Thread kg

Hi,

I'm reading the following subject :
http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html

In the sample code, we can see :

instance ReadAsAnyOf () ex
where readAsAnyOf ~() = mzero



And, I've search the meaning of the symbol "~", but I've found nothing 
about this (note that's not easy to search "~" on google ...)


Could you give me a link about this, or explain me it ?

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


[Haskell-cafe] ANN: atom-1.0.0

2010-02-13 Thread Tom Hawkins
Atom is a Haskell DSL for designing hard realtime embedded software.
The 1.0 release is meant to indicate some level of stability; most of
the core has been unchanged for quite some time.

That said, there are a few interesting changes in 1.0.  First the var'
family of variable declarations (bool', word8', double', etc.) are no
longer part of the Atom monad.  For example:

bool' :: Name -> V Bool

This cleaned up quite a bit of code in our production design.  This
also made the randomization in Atom's unit testing framework monadless
as well.

The other significant change with 1.0 is all state variables are now
packed into a hierarchical C structure that matches the hierarchy of
the Atom design.  Not only does this make the generated C a bit more
legible, it is now possible to interface external C code directly to
Atom's state variables and arrays.  Prior to this change, all
interfacing had to be done through var' declarations and action calls
-- too often a messy process.  To further aid interfacing to external
code, Atom now generates a header file that exposes both the iterative
function and the hierarchical state structure.

-Tom

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


[Haskell-cafe] hsWidgets: yet another GUI library

2010-02-13 Thread Yuras Shumovich
Hello

First of all, sorry my pure english...

My aim was to prove that haskell GUI library can be:
   - pure: does not use any kind of mutable variables
   - statically typed: does not use existential types, Data.Dynamic, etc.
   - easy to use: simple things should be simple
   - easy to extend: writing new widgets should be as simple as possible

The result is here:
http://community.haskell.org/~YurasShumovich/hsWidgets/
Usage example:
http://community.haskell.org/~YurasShumovich/hsWidgets/src/Test.hs

The library is based on X11 and is tested on Linux and Mac OS.
It is only an experiment in haskell GUI design, so it is mainly
useless (currently only label, button and button with label are
implemented) and looks ugly.

Your comments and ideas are highly welcome.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe