Re: [Haskell-cafe] "Wrong kind" when attempting to build a monad for a circular list of functions

2008-02-27 Thread Luke Palmer
On Thu, Feb 28, 2008 at 7:28 AM, Aaron Altman <[EMAIL PROTECTED]> wrote:
>  newtype CircularFuncList funcList arg = CircularFuncList (funcList ->
>  arg -> (arg, funcList))
>
>  instance Monad (CircularFuncList funcList arg) where
>   return a = CircularFuncList (\funcList a -> (a, funcList))
>   CircularFuncList currentFuncList currentArg >>= argTransform =
> let result = argTransform $ (head currentFuncList) currentArg
> newFuncList = map argTransform $ shiftActionList currentFuncList
> in CircularFuncList newFuncList result

So some standard monads are:

  instance Monad [] where ...
  instance Monad Maybe where ...

Note how they are all "missing" a type argument, i.e. not:

  instance Monad (Maybe Int) where ...

So your monad needs to be, say:

  instance Monad (CircularFuncList funcList) where ...

But see below...

>  -
>
>  I get an error that CircularFuncList funcList arg has kind * while Monad
>  is looking for * -> *.  This is a first attempt so it may be I'm a ways
>  off from a monad that implements a circular list of functions.  That is
>  the goal though.  What advice can you offer?

I'm not sure how CircularFuncList is a monad.  In fact it doesn't even
look like a Functor (because arg appears both as an argument and a
return in your data type definition).  How do you intend your monad to
be used?  That is, when a user writes:

foo :: CircularFuncList func a
foo = do
x <- ...
y <- ... x
...

What are the primitive operations (the ...s here) and what does it
mean to sequence them like this?  Describing this in words might help
you implement this, or more likely, help you realize that a monad
isn't what you thought it is :-)

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


[Haskell-cafe] "Wrong kind" when attempting to build a monad for a circular list of functions

2008-02-27 Thread Aaron Altman
Hi everybody.  I'm working towards a better understanding of Haskell 
monads the only way I know how: by working through an example.


I am working on an AI agent that will perform a finite series of actions 
before starting the sequence over again.  I figured a circular list of 
functions that shifts as you apply them would be the way to do it.  Here 
is my test code:


-

import Control.Monad

runActionAndIterate :: [a -> a] -> a -> (a, [a -> a])
runActionAndIterate (currentAction:actionList) actionInput = 
(currentAction actionInput, concat [actionList, [currentAction]])


shiftActionList :: [a -> a] -> [a -> a]
shiftActionList (currentHead:rest) = concat [rest, [currentHead]]

newtype CircularFuncList funcList arg = CircularFuncList (funcList -> 
arg -> (arg, funcList))


instance Monad (CircularFuncList funcList arg) where
 return a = CircularFuncList (\funcList a -> (a, funcList))
 CircularFuncList currentFuncList currentArg >>= argTransform =
   let result = argTransform $ (head currentFuncList) currentArg
   newFuncList = map argTransform $ shiftActionList currentFuncList
   in CircularFuncList newFuncList result

-

I get an error that CircularFuncList funcList arg has kind * while Monad 
is looking for * -> *.  This is a first attempt so it may be I'm a ways 
off from a monad that implements a circular list of functions.  That is 
the goal though.  What advice can you offer?


Thanks,

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


Re: [Haskell-cafe] Rendering TTF fonts in Haskell and OpenGL

2008-02-27 Thread Jeremy Shaw
At Fri, 22 Feb 2008 15:13:46 -,
Claus Reinke wrote:

> i got the impression that accessing freetype2 via ftgl
> might make things slightly easier, while also offering
> more options (geometry instead of texture fonts), or 
> did I misread?
> 
> http://ftgl.wiki.sourceforge.net/

It appears to be written in C++, which makes it hard to bind to from
Haskell. I did not see any C bindings for it (though, I probably did
not look too hard). So, given the choice of writing a C binding for it
so I could call it from Haskell, or just reimplementing it in Haskell,
I opted for the latter -- and got neither done :)

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


[Haskell-cafe] Bay Area talk tomorrow, on concurrent/parallel Haskell

2008-02-27 Thread Bryan O'Sullivan
Satnam Singh of Microsoft Research will be speaking about concurrent  
and parallel programming at Stanford tomorrow.


Details here:

http://www.realworldhaskell.org/blog/2008/02/28/stanford-haskell-talk-2008-02-28/

http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: type-level 0.1: Haskell type-level programming library

2008-02-27 Thread Alfonso Acosta
The goal of the "Type-level" library is to standardize and extend the
features offered by the multiple (and heterogeneous) type-level
programming implementations already around.

To date, type-level Booleans and arbitrary sized Naturals  are supported.

I implemented a few things I didn't see in any other type-level
programming libraries:

* Numerals use decimal representation to make error reports friendlier.

* Type-level numerals can be intuitively typed in different bases
(although everything is internally represented in base 10) by using
aliases:

D16 represents the type-level decimal 16
B1010 represents the type-level binary 1010
076 represents the type-level octal 76
HFF represents the type-level hexadecimal FF

* All basic arithmetic operations are supported (including logarithm
and exponentiation in any base)

* The library provides reification of Naturals and Booleans (from
value-level to type-level) .

To get the code:

HackageDB page (including haddock documentation):
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/type-level-0.1

Darcs repository: http://code.haskell.org/type-level/


Big Thanks to Oleg and Wolfgang for their suggestions and
contributions. Actually, most of the implementation of Naturals is
based on Oleg's  "Binary Type Arithmetic"
http://okmij.org/ftp/Haskell/types.html#binary-arithm
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell Jobs

2008-02-27 Thread Tom Hawkins
Hi,

We have an opening for a software engineer, with the potential for a
lot of Haskell development.  Our group at Eaton
(http://www.eaton.com/) develops real-time control software for
vehicle and machinery applications.  This position is specifically for
the design and verification of hydraulic hybrid vehicle systems.
Think Toyota Prius, but with a accumulator
and hydraulic pump instead of a battery and an electric motor.  That,
and these vehicles can weight over 30,000 pounds.

The primary tasks would include vehicle software design, system
verification with simulation and possibly formal analysis, telemetry
development for remote diagnostics, and tool development to further
automate our design flows.

Currently we use Haskell for our in-house data analysis tools, and
some vehicles run code partially generated by a Haskell DSL.  We hope
to expand our use of Haskell, especially for simulation regression
suites -- maybe QuickCheck in combination with a system modeling and
verification DSL.

If interested, send a resume.

Thanks!

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


Re: [Haskell-cafe] ANNOUNCE: hsparklines 0.1.0 - A sparklines implementation in Haskell

2008-02-27 Thread Hitesh Jasani
On Wed, Feb 27, 2008 at 5:05 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> hitesh.jasani:
>
>
> > Sparklines are small, word sized graphs that can be interspersed with
>  > text to provide context and enhance communication.  There are
>  > implementations in many languages and even some web services that will
>  > generate them on the fly.  I was looking for a Haskell solution and
>  > finding none, wrote my own.
>  >
>  > * 
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsparklines-0.1.0
>  > * http://www.jasani.org/2008/02/initial-release-of-hsparklines-010.html
>  >
>  > On a side note, while writing my blog entry I decided to generate a
>  > sparkline for the number of uploads to hackage.  If it's any
>  > indication, the Haskell community is growing by leaps and bounds.
>  >
>  > - Hitesh
>
>  Lovely work!
>
>  Is there a darcs repository available for the source? (Or would you
>  like to host it on hackage?)
>
>  Also, how did you generate the month-by-month data for hackage uploads?
>
>  -- Don
>

Sorry, there's no darcs repo.  Hosting it on hackage might be
interesting, but finding the time to learn how to do it is kind of
tough for me right now.  I guess it depends on whether others want to
contribute code to it.

I took the raw data off of the main page
(http://hackage.haskell.org/packages/archive/log) and wrote some quick
and dirty Haskell to parse and process it.  Basically I counted an
upload as a unique event -- it didn't matter to me whether it was a
bug fix upload on an existing project or a new project.  The way I
looked at it, each upload represented people contributing to the
community.

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


Re: [Haskell-cafe] where is module System.Posix.Types?

2008-02-27 Thread Neil Mitchell
Hi

>  I don't see the types modules in with the other modules in the Posix
> pacakage, ??

It is in the base library. I answered this question by searching with Hoogle:

http://haskell.org/hoogle/?q=types

Thanks

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


Re: [Haskell-cafe] ANNOUNCE: hsparklines 0.1.0 - A sparklines implementation in Haskell

2008-02-27 Thread Don Stewart
hitesh.jasani:
> Sparklines are small, word sized graphs that can be interspersed with
> text to provide context and enhance communication.  There are
> implementations in many languages and even some web services that will
> generate them on the fly.  I was looking for a Haskell solution and
> finding none, wrote my own.
> 
> * http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsparklines-0.1.0
> * http://www.jasani.org/2008/02/initial-release-of-hsparklines-010.html
> 
> On a side note, while writing my blog entry I decided to generate a
> sparkline for the number of uploads to hackage.  If it's any
> indication, the Haskell community is growing by leaps and bounds.
> 
> - Hitesh

Lovely work!

Is there a darcs repository available for the source? (Or would you
like to host it on hackage?)

Also, how did you generate the month-by-month data for hackage uploads?

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


Re: [Haskell-cafe] ANNOUNCE: hsparklines 0.1.0 - A sparklines implementation in Haskell

2008-02-27 Thread Justin Bailey
On Wed, Feb 27, 2008 at 1:37 PM, Hitesh Jasani <[EMAIL PROTECTED]> wrote:
> Sparklines are small, word sized graphs that can be interspersed with
>  text to provide context and enhance communication.  There are
>  implementations in many languages and even some web services that will
>  generate them on the fly.  I was looking for a Haskell solution and
>  finding none, wrote my own.

Impressive! Looks really nice.

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


[Haskell-cafe] ANNOUNCE: hsparklines 0.1.0 - A sparklines implementation in Haskell

2008-02-27 Thread Hitesh Jasani
Sparklines are small, word sized graphs that can be interspersed with
text to provide context and enhance communication.  There are
implementations in many languages and even some web services that will
generate them on the fly.  I was looking for a Haskell solution and
finding none, wrote my own.

* http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsparklines-0.1.0
* http://www.jasani.org/2008/02/initial-release-of-hsparklines-010.html

On a side note, while writing my blog entry I decided to generate a
sparkline for the number of uploads to hackage.  If it's any
indication, the Haskell community is growing by leaps and bounds.

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


[Haskell-cafe] where is module System.Posix.Types?

2008-02-27 Thread Galchin Vasili
Hello,

 I don't see the types modules in with the other modules in the Posix
pacakage, ??


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


[Haskell-cafe] Re: Just a quick question

2008-02-27 Thread Chad Scherrer
Imam Tashdid ul Alam  yahoo.com> writes:
> A few days back, I *think* I stumbled upon the
> statement "the interaction between GADTs and
> functional dependencies is not yet well understood".
> Then I glossed over it. Now that I have (finally)
> started understanding what GADTs are meant to do, I am
> somewhat terrified. Did I read that one correctly? Or
> was it "... between GADTs and *typeclasses*..."?
> 
> Was it?
> 
> Gah. That would be disastrous. 


"Functional dependencies" might mean something different than you think. See
section 8.6.2 of this:

http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html

Chad

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


Re: [Haskell-cafe] Re: fast integer base-2 log function?

2008-02-27 Thread Taral
On 2/27/08, Chad Scherrer <[EMAIL PROTECTED]> wrote:
>  Is {-# LANGUAGE MagicHash #-} documented somewhere? I've seen it referenced a
>  few times now, but I can't find any details about it.

No. http://hackage.haskell.org/trac/ghc/ticket/1297

-- 
Taral <[EMAIL PROTECTED]>
"Please let me know if there's any further trouble I can give you."
-- Unknown
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: fast integer base-2 log function?

2008-02-27 Thread Chad Scherrer
Jens Blanck  gmail.com> writes:

>  {-# LANGUAGE MagicHash #-} import GHC.Exts import Data.Bits -- experiment
with using a LUT here (hint: FFI + static arrays in C)
> ...

Sorry I don't have an answer, only more questions.

Is {-# LANGUAGE MagicHash #-} documented somewhere? I've seen it referenced a
few times now, but I can't find any details about it.

Chad

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


Re: [Haskell-cafe] Trouble finding exception source

2008-02-27 Thread Denis Bueno
On Wed, Feb 27, 2008 at 12:06 AM,  <[EMAIL PROTECTED]> wrote:
>  Fortuitously, I recently came across a bunch of bioinformatics software in 
> Haskell. One of the libraries was called 'interlude', and it claims to be 
> able to give line locations for errors in the Prelude. I was intending to 
> upload them all as a group once I'd finished, but you might be able to make 
> use of it here.
>
>  You can find it here: 
> .
>
>  If it does work out for you, be sure to let me know. I haven't run across 
> any Prelude errors in my code since I installed it, so I haven't really tried 
> it out.

Although I had to change my source code a bit (changing calls to e.g.
`any' and `all' to have a Foldable prefix), this did work.  My error
message now is:

dsat: Prelude.maximum: empty list

which tells me where my bug is.  Thanks!

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


Re: [Haskell-cafe] Stack overflow

2008-02-27 Thread Grzegorz Chrupala


Bryan O'Sullivan wrote:
> 
> On Feb 27, 2008, at 3:02 AM, Grzegorz Chrupala wrote:
>>
>> I was getting stack overflows when using Data.Binary with a few other
>> datastructures so I decided to try this option. I hacked a
>> Data.Binary.Strict module which is basically a copy and paste of
>> Data.Binary, [...]
> 
> We've recently hit the point where it makes sense to check Hackage  
> before you embark on small hacking projects like this:
> 
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict-0.3.0
> 

My module uses the Get monad from the above binary-strict package, but
defines and exports the equivalents of functions in Data.Binary, which are
missing from binary-strict, most importantly the (strict version) of the
decode function.
Best,
-- 
Grzegorz

-- 
View this message in context: 
http://www.nabble.com/Stack-overflow-tp15479718p15717389.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] Stack overflow

2008-02-27 Thread Bryan O'Sullivan

On Feb 27, 2008, at 3:02 AM, Grzegorz Chrupala wrote:


I was getting stack overflows when using Data.Binary with a few other
datastructures so I decided to try this option. I hacked a
Data.Binary.Strict module which is basically a copy and paste of
Data.Binary, [...]


We've recently hit the point where it makes sense to check Hackage  
before you embark on small hacking projects like this:


http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict-0.3.0

http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Just a quick question

2008-02-27 Thread Imam Tashdid ul Alam
A few days back, I *think* I stumbled upon the
statement "the interaction between GADTs and
functional dependencies is not yet well understood".
Then I glossed over it. Now that I have (finally)
started understanding what GADTs are meant to do, I am
somewhat terrified. Did I read that one correctly? Or
was it "... between GADTs and *typeclasses*..."?

Was it?

Gah. That would be disastrous. 


  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble finding exception source

2008-02-27 Thread Denis Bueno
On Wed, Feb 27, 2008 at 2:01 AM, Judah Jacobson
<[EMAIL PROTECTED]> wrote:
> Hi Denis,
>
>  I was unable to run your program; it looks like there's a missing
>  module 'Properties'.  To include it in the sdist you probably need to
>  add it under the other-modules field in the .cabal file.

Sorry about this.  I'm new to Cabal, and to Haskell in general.
Attached is a version that built on my machine independently of the
source tree.

-- 
  Denis


DPLLSat-0.1.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] Stack overflow

2008-02-27 Thread Grzegorz Chrupala


Philip Armstrong wrote:
> 
> On Sun, Feb 17, 2008 at 11:45:26PM +, Adrian Hey wrote:
>> But I guess this rant is not much help to the OP :-)
> 
> Can the Get Monad from Data.Binary be replaced by the one in
> Data.Binary.Strict.Get?
> 
> Would probably require some hacking on the library I guess.
> 

I was getting stack overflows when using Data.Binary with a few other
datastructures so I decided to try this option. I hacked a
Data.Binary.Strict module which is basically a copy and paste of
Data.Binary, but exports a strict decode which uses the Get monad from 
Data.Binary.Strict.Get.
It's just a hack and I'm sure there are better ways of doing it but it works
for me so I'm attaching it.
--

Grzegorz
http://www.nabble.com/file/p15710959/Strict.hs Strict.hs 

-- 
View this message in context: 
http://www.nabble.com/Stack-overflow-tp15479718p15710959.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