Re: [Haskell-cafe] ANNOUNCE: vector 0.1 (efficient arrays with lots of fusion)

2008-07-13 Thread Levi Stephen
On Sun, Jul 13, 2008 at 12:31 AM, Roman Leshchinskiy [EMAIL PROTECTED] wrote: Hi all, the vector library will eventually provide fast, Int-indexed arrays with a powerful fusion framework. It's very immature at the moment (I haven't tested most of the code) and implements just a few

[Haskell-cafe] (Lazy) SmallCheck and peano numbers

2008-06-19 Thread Levi Stephen
Hi, I have the following definitions type Zero type Succ a so that I can muck around with a Vector type that includes its length encoded in its type. I was wondering whether it was possible to use SmallCheck (or QuickCheck) to generate random Peano numbers? Is there an issue here in that what

[Haskell-cafe] Re: (Lazy) SmallCheck and peano numbers

2008-06-19 Thread Levi Stephen
If so, you could write a SmallCheck Series instance as follows. instance Serial (Vec Zero a) where series = cons0 nil instance (Serial a, Serial (Vec n a)) = Serial (Vec (Succ n) a) where series = cons2 (|) If we have the property prop_vector :: Vec (Succ (Succ Zero)) Bool -

[Haskell-cafe] Re: (Lazy) SmallCheck and peano numbers

2008-06-19 Thread Levi Stephen
On Fri, Jun 20, 2008 at 3:30 AM, Benedikt Huber [EMAIL PROTECTED] wrote: Levi Stephen schrieb: Hi, I have the following definitions type Zero type Succ a so that I can muck around with a Vector type that includes its length encoded in its type. I was wondering whether it was possible

[Haskell-cafe] hmp3 compilation problem

2008-05-18 Thread Levi Stephen
Hi, I am trying to compile hmp3. I have the version from darcs at http://code.haskell.org/~dons/code/hmp3 I am getting the following errors: Tree.hs:190:14: No instance for (Binary FilePathP) arising from a use of `get' at Tree.hs:190:14-16 Possible fix: add an instance declaration

Re: [Haskell-cafe] First go at reactive programming

2008-01-17 Thread Levi Stephen
Hi, Below is a version that was aimed at getting rid of the (Handle,IO (Request a)) tuples and as a result made it easier to remove the IO monad from some types, but I don't think it removed it completely from any methods. module Main where import Control.Applicative import

[Haskell-cafe] First go at reactive programming

2008-01-15 Thread Levi Stephen
Hi, Listed below is my first experiment with reactive programming. It is a simple web server written using the Data.Reactive[1] library. The intended interface is given by the runHttpServer function, so the remainder is intended to be internal. I'd be happy to hear comments on any parts of

Re: [Haskell-cafe] FP design

2007-11-07 Thread Levi Stephen
Bulat Ziganshin wrote: Hello Andrew, Tuesday, November 6, 2007, 10:55:58 PM, you wrote: for me, abstraction is anything that i want to be an abstraction. i just write code in the close-to-natural language and it becomes Haskell program when appropriate syntax applied. Well, in my

Re: [Haskell-cafe] FP design

2007-11-07 Thread Levi Stephen
Donn Cave wrote: But in the specific matter I'm wrestling with, the Java library's OOP model is, to its credit, allowing me to do some things. I'm using their standard LDAP client library, but swapping in my own function to read X509 certificates for the SSL. Actually, swapping in my own SSL

Re: [Haskell-cafe] FP design

2007-11-07 Thread Levi Stephen
Tim Docker wrote: levi.stephen wrote: My concern (which may be inexperience ;) ) is with the monads here though. What if I hadn't seen that the IO monad (or any other Monad) was going to be necessary in the type signatures? You'd have some refactoring to do :-) But actually, it's not

Re: [Haskell-cafe] FP design

2007-11-07 Thread Levi Stephen
Tim Docker wrote: levi.stephen wrote: I have similar questions about Haskell abstracting away implementations behind interfaces as well. I have become used to an approach where I will not worry about databases/persistence when beginning. I will create an interface to a database layer (e.g.,

[Haskell-cafe] FP design

2007-11-05 Thread Levi Stephen
Hi, I'm was wondering how most people work during when designing a functional program. Do you create data structures/types first? Do you work from some type signatures? For example, take a blog. Is the first step likely to be something like: data BlogEntry = BlogEntry {

[Haskell-cafe] Help understanding type error

2007-09-06 Thread Levi Stephen
Hi, I'm after some help understanding either what I'm doing wrong, or why this error occurs. I have a data type: data T a = forall b. (Show b) = T b a and I want to use/extract 'b' from this. extShow (T b _) = b This gives the following compilation error: extest.hs:5:0: Inferred

[Haskell-cafe] Help understanding a partial application

2007-08-26 Thread Levi Stephen
Hi, I was browsing through the source code for Data.Foldable and having trouble comprehending it (which was kind of the point of browsing the code, so I could learn something ;) ) I'm looking at foldl foldl :: (c - d - c) - c - t d - c foldl f z t = appEndo (getDual (foldMap (Dual . Endo .

Re: [Haskell-cafe] Help understanding a partial application

2007-08-26 Thread Levi Stephen
Ryan Ingram wrote: Just expand out the function composition: Dual . Endo . flip f = (\x - Dual (Endo (flip f x))) which has the type d - Dual (Endo c). -- ryan Aha. I didn't get this straight away, but once I looked at the type signature for function composition, it became clear.

[Haskell-cafe] Re: I'm stuck in my thought experiment

2007-08-21 Thread Levi Stephen
If I wanted to develop the widgets themselves separately from the layout, I would probably do something like this: class Widget a where render :: a - Html bbox :: a - Size type Layout = forall a. Widget a = Widget a | Rows Spacing [Layout] | Columns Spacing [Layout] |

Re: [Haskell-cafe] Re: I'm stuck in my thought experiment

2007-08-20 Thread Levi Stephen
Al Falloon wrote: Maybe I am misunderstanding your requirements, but it seems to me that the simplest solution would be best in this case: data Widget = BlogWidget [Article] | TextWidget String | MenuWiget Menu | Rows Spacing [Widget] | Columns Spacing [Widget] You can also

[Haskell-cafe] I'm stuck in my thought experiment

2007-08-16 Thread Levi Stephen
Hi, Apologies for a long post that may not be totally clear. I was thinking through a problem and how the data might be represented in Haskell. I'm now stuck and frustrated. Now, I'm not even sure whether I'm on the right track (I might still be thinking too OO). Suggestions/ideas would be much

Re: [Haskell-cafe] Avoiding boilerplate retrieving GetOpt cmd line args

2007-07-26 Thread Levi Stephen
Hi, Not sure if this will help avoid the boilerplate, but I've always liked the approach at http://leiffrenzel.de/papers/commandline-options-in-haskell.html (particularly the section Towards a higher level) for being able to specify defaults. It's the best resource I've found on command line

[Haskell-cafe] Parsec question

2007-06-21 Thread Levi Stephen
Hi, Fairly new to Haskell and trying some parsec. (Also, new to parsers/interpreters) I had come up with this, which works, but I can't help thinking there's a better way :) | newtype Identifier = Identifier String newtype Literal = StringLiteral String -- to be extended later data

Re: [Haskell-cafe] Parsec question

2007-06-21 Thread Levi Stephen
Tillmann Rendel wrote: My self-defined monadic combinator of choice to use with parsec is a ~ b = a = \x - b return x It works like (), but returns the result of the first instead of the result of the second computation. It is kind of an alternative for between: between lparen rparen