Re: [Haskell-cafe] Stacking data types

2011-04-11 Thread Job Vranish
bout Datatypes a la carte, I just found it overly > complicated. > > Thanks for you solution, Job. However (and even if it doesn't work without > it) I fail to see why you need the functional dependency on Has... > Doesn't it implies here that for one 'a' there can

Re: [Haskell-cafe] Stacking data types

2011-04-06 Thread Job Vranish
I think you want something like this: {-# Language MultiParamTypeClasses , FlexibleInstances , FunctionalDependencies , UndecidableInstances , FlexibleContexts , OverlappingInstances #-} data Character a = Character { life :: Int,

[Haskell-cafe] Missing MaybeT MonadFix instance

2011-04-01 Thread Job Vranish
Is there a particular reason that the transformersversion of the MaybeT monad does not have a MonadFix instance? It seems like the following instance would be suitable: instance (Mona

Re: [Haskell-cafe] makeTokenParser + LanguageDef

2011-03-08 Thread Job Vranish
The tutorial here: http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#Lexical analysis is for parsec 2, but it's still quite relevant. - Job On Tue, Mar 8, 2011 at 6:22 AM, Hauschild, Klaus (EXT) < klaus.hauschild@

Re: [Haskell-cafe] Convert a function to a string of operators?

2011-03-04 Thread Job Vranish
Make your own expression type and make it an instance of the Num typeclass. Then you can build your expression using the usual operators and then use show to convert to a string. For example: https://github.com/jvranish/grhug/blob/master/SymbolicDifferentiation/SymbolicDifferentiation.hs It proba

Re: [Haskell-cafe] monadic plumbing

2011-02-22 Thread Job Vranish
You need the MaybeT and EitherT monad transformers: http://hackage.haskell.org/packages/archive/MaybeT/0.1.2/doc/html/Control-Monad-Maybe.html http://hackage.haskell.org/packages/archive/EitherT/0.0.1/doc/h

Re: [Haskell-cafe] Infinite types should be optionally allowed

2011-02-22 Thread Job Vranish
Thanks, Perhaps my algorithm works then. I shall have to read up more on these things :) - Job On Mon, Feb 21, 2011 at 4:54 PM, Luke Palmer wrote: > On Sun, Feb 20, 2011 at 6:01 PM, Job Vranish wrote: > > My current algorithm says that neither of the types you gave is strictly

Re: [Haskell-cafe] Faster timeout but is it correct?

2011-02-21 Thread Job Vranish
I'm curious, is it possible that your new timeout implementation would fix this problem?: doesntWork :: Int -> Int doesntWork x = last $ cycle [x] test :: IO (Maybe Bool) test = timeout 1 $ evaluate $ doesntWork 5 == 5 -- never terminates, even with the timeout >From what I can gather, this prob

Re: [Haskell-cafe] Infinite types should be optionally allowed

2011-02-21 Thread Job Vranish
On Sun, Feb 20, 2011 at 8:56 PM, Brandon Moore wrote: > > > Typechecking with regular types isn't hard. So do I have the right idea then? To check against a signature, I can just unify the two types and then check if the unified type is 'equivalent' (is there a special word for this kind of equiv

Re: [Haskell-cafe] Infinite types should be optionally allowed

2011-02-20 Thread Job Vranish
someone pointing out the flaw in my reasoning/code :) My test code is on github here: https://github.com/jvranish/InfiniteTypes Also, is there a book you'd recommend that would explain this in further detail? Thanks, - Job On Mon, Feb 16, 2009 at 5:16 PM, Luke Palmer wrote: > On S

Re: [Haskell-cafe] Timeout exceptions sometimes don't work, even in pure (non FFI) code

2011-02-01 Thread Job Vranish
nsistently. This behavior is quite annoying. Thanks for your help, - Job On Tue, Feb 1, 2011 at 11:18 AM, Daniel Fischer < daniel.is.fisc...@googlemail.com> wrote: > On Tuesday 01 February 2011 16:40:43, Job Vranish wrote: > > I'm trying to test some properties with quickcheck.

[Haskell-cafe] Timeout exceptions sometimes don't work, even in pure (non FFI) code

2011-02-01 Thread Job Vranish
I'm trying to test some properties with quickcheck. If these tests fail, they will almost certainly fail by nontermination. I've been using the 'within' function to catch these nontermination cases. However, I was surprised to find that this doesn't always work. 'within' uses the 'timeout' function

Re: [Haskell-cafe] REPL loop

2010-12-20 Thread Job Vranish
The answer is yes, but could you elaborate? What exactly are you wanting? Do you want something similar to ghci? Are you wanting to implement a REPL for some other language in haskell? REPL for haskell, in haskell? - Job On Mon, Dec 20, 2010 at 12:47 PM, Aaron Gray wrote: > Is it possible to imp

Re: [Haskell-cafe] Couple of questions about *let* within *do*

2010-08-10 Thread Job Vranish
Yes, and yes :) For example: import Data.Char main = do let prompt s = do putStrLn s getLine firstName <- prompt "What's your first name?" lastName <- prompt "What's your last name?" let bigFirstName = map toUpper firstName bigLastName = map toUpper lastName putStrLn

Re: [Haskell-cafe] More Flexible Monad Transformer OR Bad Coding Style

2010-08-09 Thread Job Vranish
For monads like StateT, WriterT, ReaderT, the order doesn't matter (except perhaps for some pesky performance details). However, for monad transformers like ErrorT or ListT, the order _does_ matter. The code you have there is perfectly fine, sometimes the added generality can be quite handy (espec

Re: [Haskell-cafe] real-time audio processing [Was: can Haskell do everyting as we want?]

2010-08-05 Thread Job Vranish
Yeah Atom is pretty slick, though unfortunately it's not quite powerful enough for much of the stuff that we do. John Van Enk and I are actually working on a language that's similar to C (and compiles to C), but has polymorphism, type inference and other goodies. The goal is to make working on emb

Re: [Haskell-cafe] real-time audio processing [Was: can Haskell do everyting as we want?]

2010-08-04 Thread Job Vranish
+ 1 This is probably the biggest obstacle to using Haskell where I work. (Aviation industry, software for flight management systems for airplanes) We often need to perform some computations with hard deadlines, say every 20ms, with very little jitter. Major GC's spoil the fun; It's quite easy to

Re: [Haskell-cafe] ANNOUNCE: DSTM 0.1.1

2010-08-04 Thread Job Vranish
Both Git and GitHub are fantastic. (and very convenient for contributors) Also if you're the kind of person who's into GUI's, SmartGit is quite good as well. - Job On Wed, Aug 4, 2010 at 3:28 PM, Frank Kupke wrote: > John, > > a very nice idea. I have not worked with git yet but used an svn rep

Re: [Haskell-cafe] Problem with haskell types

2010-07-30 Thread Job Vranish
Yeah I recently ran into this myself. ( http://osdir.com/ml/haskell-cafe@haskell.org/2010-07/msg00020.html). It's not a bug, just a limitation of haskell's inference algorithm for mutually recursive groups of functions. The problem is that haskell infers groups (the strongly connected components)

Re: [Haskell-cafe] [Yi Editor]Cabal Problem

2010-07-30 Thread Job Vranish
I think you can just install the windows gtk dev libraries from here: http://www.gtk.org/download.html - Job On Thu, Jul 29, 2010 at 5:20 PM, Alessandro Stamatto wrote: > Installing Yi Editor i get the following error: > -- > --

Re: [Haskell-cafe] Fail to install SDL with Cabal

2010-07-30 Thread Job Vranish
You might try emailing the maintainer directly. The package appears to be actively maintained. - Job On Fri, Jul 30, 2010 at 3:17 AM, Eitan Goldshtrom wrote: > I'm trying to install SDL through Cabal -- I don't know another way to > install it. However, I'm getting this: > > setup.exe: The pack

Re: [Haskell-cafe] OpenGL Speed!

2010-07-29 Thread Job Vranish
Yeah, using openGL Points to draw 2D images will probably be pretty slow. However, if you don't need to change your points every frame, a display list might improve the speed quite a bit (you could still transform the points as a whole). Also, you could try the SDL bindings for haskell: http://hac

Re: [Haskell-cafe] Memory and Threads - MVars or TVars

2010-07-29 Thread Job Vranish
You might try pulling downloading the package ('cabal fetch org' will do this) and changing the base dependency (to >= 4.1) in the orc.cabal file and then build it manually (cabal configure && cabal build && cabal install (while in the same directory as the .cabal file)) and see what happens. I d

Re: [Haskell-cafe] Memory and Threads - MVars or TVars

2010-07-28 Thread Job Vranish
Atomic operations are special operations where you don't have to worry about some other process messing with things while the operation is taking place. For a simple example of why atomic operations are important: (taken from: http://en.wikipedia.org/wiki/Linearizability#Non-atomic) The naive, no

Re: [Haskell-cafe] Haskell Forum

2010-07-26 Thread Job Vranish
I agree. A web forum would be more friendly to newcomers, easier to browse, and better organized, than the mailing list. Some people will still prefer the mailing list of course, but I think there will be enough demand to justify a forum :) - Job On Mon, Jul 26, 2010 at 9:57 AM, Daniel Díaz w

Re: [Haskell-cafe] Actors and message-passing a la Erlang

2010-07-26 Thread Job Vranish
I think most of the Erlang style actors with message passing can be done in Haskell with just TChan and forkIO. http://en.wikibooks.org/wiki/Haskell/Concurrency - Job On Sun, Jul 25, 2010 at 4:55 PM, Yves Parès wrote: > Hello ! > > I've been studying Erlang and Scala, and I was wondering if so

Re: [Haskell-cafe] Yet another monad transformer or silly usage of Either?

2010-07-25 Thread Job Vranish
Yeah, ErrorT should do what you want (EitherT is probably essentially the same thing) login would have the type: login :: String -> String -> ErrorT DServError IO LoginResponse and you would use it like this: result <- runErrorT $ authenticatedReq You can use runErrorT, or catch when you want to

Re: [Haskell-cafe] Tiger compiler in Haskell: annotating abstract syntax tree

2010-07-19 Thread Job Vranish
questions about it. - Job <http://hpaste.org/fastcgi/hpaste.fcgi/view?id=27823#a27823> 2010/7/19 Job Vranish > I didn't get any attachments from you, but haskell-cafe might filter them > out (I'm not sure). > > But, the usual derived instances for Show should work fi

Re: [Haskell-cafe] qtHaskell

2010-07-19 Thread Job Vranish
I haven't used the Gtk bindings much, but the qtHaskell bindings work quite well. If you've used Qt before, it should be pretty easy to pick up. - Job On Mon, Jul 19, 2010 at 10:19 AM, Ali Razavi wrote: > Greetings, > I have only used the wxHaskell library before, but I am looking into > tryin

Re: [Haskell-cafe] Tiger compiler in Haskell: annotating abstract syntax tree

2010-07-19 Thread Job Vranish
Martijn van Steenbergen has a good blog post that describes the method I generally use: http://martijn.van.steenbergen.nl/journal/2010/06/24/generically-adding-position-information-to-a-datatype/ In his example he annotates the expression tree with position information, but you can use the same me

Re: [Haskell-cafe] use of modules to save typing

2010-07-08 Thread Job Vranish
For working with record fields inside of state monads I would recommend trying out one of these packages: lenses fclabels data-accessor (I think I'm forgetting a couple) They all have special mechanisms for working with record fields inside state monads (and have lots of other cool stuff) I'm part

Re: Re: [Haskell-cafe] Criteria for determining if a recursive function can be implemented in constant memory

2010-07-06 Thread Job Vranish
If your integers have a bounded size, then your Turing machine is not Turing complete and can't run a Haskell interpreter. You might be tempted to just make the numbers really big, but bounded, and then say that you can still run most interesting programs while skirting the issue of non computabil

[Haskell-cafe] Inferring the most general type

2010-06-22 Thread Job Vranish
Esteemed fellow haskellers, I recently ran into a very simple real life case where Haskell's rules for inferring the types for mutually recursive definitions resulted in a type that was less general than it could be. It took me a while to realize that the type error I was getting wasn't actually a

Re: [Haskell-cafe] How to browse code written by others

2010-06-14 Thread Job Vranish
I've been using the geany editor recently and I was shocked to find that it has decent source browsing capabilities (that work with haskell even!). You can find where something is defined and find other usages of things. It's a bit crude, but gets the job done well enough.

Re: [Haskell-cafe] Re: Using the ContT monads for early exits of IO ?

2010-06-10 Thread Job Vranish
Yeah, I might actually prefer calling it EitherT instead of ErrorT. It doesn't have to be used for error, it's just what it is most often used for. - Job On Thu, Jun 10, 2010 at 3:57 PM, Maciej Piechotka wrote: > On Thu, 2010-06-10 at 14:09 -0500, Tim Wawrzynczak wrote: > > Actually, on second t

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Job Vranish
Yeah I don't see why not. The ContT monad should work great. Also, depending on what you're doing, the ErrorT monad might do what you want as well. - Job 2010/6/10 Günther Schmidt > Hi everyone, > > I'm about to write a rather lengthy piece of IO code. Depending on the > results of some of the

Re: [Haskell-cafe] Proposal to solve Haskell's MPTC dilemma

2010-06-08 Thread Job Vranish
Sorry for reopening an old thread, but I thought I'd counter some of the negative feedback :) I think this proposal is a great idea! It seems like this would make working with MPTCs much easier. When programming, I generally want to only specify the minimum amount of information to make my code

Re: [Haskell-cafe] Good US Grad schools for functional languages?

2010-05-13 Thread Job Vranish
here > too. > > > Cheers, > PE > > > El 13/05/2010, a las 13:41, Job Vranish escribió: > > > Anybody know of a good grad school in the US for functional languages? > > (good = has Ph.D. program that covers functional languages, type systems, > correctness pr

[Haskell-cafe] Good US Grad schools for functional languages?

2010-05-13 Thread Job Vranish
Anybody know of a good grad school in the US for functional languages? (good = has Ph.D. program that covers functional languages, type systems, correctness proofs, etc...) So far Indiana University is the only one I've found that has a strong showing in this area. A way to get into one of the aw

Re: [Haskell-cafe] Re: GSoC: Hackage 2.0

2010-04-09 Thread Job Vranish
On Fri, Apr 9, 2010 at 10:46 AM, Malcolm Wallace < malcolm.wall...@cs.york.ac.uk> wrote: > > It would be even nicer if you could post comments to individual haskell >> > definitions on the haddock page, and then hide most of them by default >> under >> > an expander of some sort. >> >> Rather than

Re: [Haskell-cafe] Re: GSoC: Hackage 2.0

2010-04-09 Thread Job Vranish
On Fri, Apr 9, 2010 at 10:31 AM, Edward Kmett wrote: > On Fri, Apr 9, 2010 at 10:21 AM, Job Vranish wrote: > >> On Fri, Apr 9, 2010 at 9:46 AM, Ivan Lazar Miljenovic < >> ivan.miljeno...@gmail.com> wrote: >> >>> Job Vranish writes: >>> > I v

Re: [Haskell-cafe] Re: GSoC: Hackage 2.0

2010-04-09 Thread Job Vranish
On Fri, Apr 9, 2010 at 9:46 AM, Ivan Lazar Miljenovic < ivan.miljeno...@gmail.com> wrote: > Job Vranish writes: > > I vote for adding a feature that would let people post comments/code > > snippets to the documentation of other peoples packages :) > > You mean turn

Re: [Haskell-cafe] Re: GSoC: Hackage 2.0

2010-04-09 Thread Job Vranish
I vote for adding a feature that would let people post comments/code snippets to the documentation of other peoples packages :) It would be even nicer if you could post comments to individual haskell definitions on the haddock page, and then hide most of them by default under an expander of some s

Re: [Haskell-cafe] Why does Haskell not infer most general type?

2010-04-06 Thread Job Vranish
Thank you all for your replies. This is all much more clear now :) - Job On Tue, Apr 6, 2010 at 7:00 PM, Ross Paterson wrote: > On Tue, Apr 06, 2010 at 05:18:34PM -0400, Job Vranish wrote: > > So in Haskell 98, would the added constraints result in a type error? > > Yes, becau

Re: [Haskell-cafe] Why does Haskell not infer most general type?

2010-04-06 Thread Job Vranish
So in Haskell 98, would the added constraints result in a type error? - Job On Tue, Apr 6, 2010 at 5:12 PM, Ross Paterson wrote: > On Tue, Apr 06, 2010 at 03:56:32PM -0400, Job Vranish wrote: > > f _ = undefined > > where > > _ = y :: Int -> Int > > &

[Haskell-cafe] Why does Haskell not infer most general type?

2010-04-06 Thread Job Vranish
Is haskell supposed to always infer the most general type (barring extensions)? I found a simple case where this is not true: f _ = undefined where _ = y :: Int -> Int y x = undefined where _ = f x Haskell infers the types of 'y' and 'f' as: f :: Int -> a y :: Int -> Int This confu

Re: [Haskell-cafe] ANN: fixed-list -- A fixed length list library

2010-03-21 Thread Job Vranish
mplement a more sophisticated way to keep track of the list lengths that doesn't have this problem, but I really like the simplicity of the current implementation. - Job On Sun, Mar 21, 2010 at 2:37 AM, Casey McCann wrote: > Job Vranish wrote: > > Its main advantages are: > > Ver

[Haskell-cafe] ANN: fixed-list -- A fixed length list library

2010-03-20 Thread Job Vranish
I uploaded a new fixed length list library to hackage: http://hackage.haskell.org/package/fixed-list Its main advantages are: Very easy to use. Almost entirely Haskell98 (the non Haskell98 pieces are not critical, just nice) The datatype is a member of Foldable, Traverable, Applicative, M

Re: [Haskell-cafe] Parsec monad transformer with IO?

2010-03-18 Thread Job Vranish
Hoogle is a great tool for finding haskell functions: http://www.haskell.org/hoogle/ You can punch in the type of a function you want and it will give you a list of functions that might do what you need. Generalizing the types a bit usually helps. Searching for either m a -> n m a or IO a ->

Re: [Haskell-cafe] Abstraction in data types

2010-03-18 Thread Job Vranish
A phantom type might do what you want: -- notice the type parameter on point that isn't used in the type data Point a = Cartesian (Cartesian_coord, Cartesian_coord) | Spherical (Latitude, Longitude) -- make some dummy types data SphericalP data CartesianP --make some c

Re: [Haskell-cafe] GPL answers from the SFLC (WAS: Re: ANN: hakyll-0.1)

2010-03-05 Thread Job Vranish
This seems really confusing. It would imply that if I write a library that is designed to talk to some part of the linux kernel API (which is GPL'd) then I'd have to release my library under the GPL. And anything that used my libraries API would need to be GPL'd too, etc... Which would mean that e

Re: [Haskell-cafe] ANNOUNCE: Parsec 3.1.0

2010-03-04 Thread Job Vranish
Sweet :) I'm glad that notFollowedBy has been fixed. I've often had to redefine it because the type was to restrictive. - Job On Wed, Mar 3, 2010 at 11:45 PM, Derek Elkins wrote: > Parsec is a monadic combinator library that is well-documented, simple > to use, and produces good error messages.

Re: [Haskell-cafe] Haskell platform for GHC 6.12.1?

2010-03-04 Thread Job Vranish
I'm pretty sure you don't need mingw and all that. I've bootstrapped cabal-install on windows a few times now without needing anything more than ghc (though I haven't done 6.12 yet so I might be totally off base here...) You can't use the nice bootstrap script, but you can download and build the d

Re: [Haskell-cafe] Real-time garbage collection for Haskell

2010-03-01 Thread Job Vranish
On Mon, Mar 1, 2010 at 2:37 PM, Thomas Schilling wrote: > On 1 March 2010 16:27, Job Vranish wrote: > > My current area of work is on realtime embedded software programming for > > avionics systems. We do most of our coding in Ada but I've been dreaming > of > >

Re: [Haskell-cafe] Real-time garbage collection for Haskell

2010-03-01 Thread Job Vranish
My current area of work is on realtime embedded software programming for avionics systems. We do most of our coding in Ada but I've been dreaming of using haskell instaed. However, the garbage collector is actually one of the larger obsticles to making this happen. All of our avionics software ne

Re: [Haskell-cafe] save/restore of STRef state

2010-02-27 Thread Job Vranish
On Sat, Feb 27, 2010 at 11:53 AM, Andrew Coppin wrote: > > > If you use something like the State or Reader monad, it becomes trivial to > temporarily modify the carried state. But maybe something like this is > occasionally useful. (In particular, it seems to allow you to restore to a > point not

[Haskell-cafe] save/restore of STRef state

2010-02-27 Thread Job Vranish
I was using STRefs the other day and I ran across a case where I really wanted the ability to save the state of all my references, execute some action, and then restore the state later if needed. I didn't find anything that does this on hackage so I implemented a small wrapper around STRefs which d

[Haskell-cafe] haskell-src type inference algorithm?

2010-02-11 Thread Job Vranish
Anyone know of a type inference utility that can run right on haskell-src types? or one that could be easily adapted? I want to be able to pass in an HsExp and get back an HsQualType. It doesn't have to be fancy, plain Haskell98 types would do. It wouldn't be to hard to make one myself, but I figu

Re: [Haskell-cafe] matrix question

2010-02-02 Thread Job Vranish
I have a little haskell matrix library for fixed sized matricies on github: http://github.com/jvranish/VectorMatix which I've just realized is horribly out of date...I'll update it tonight and probably push it to hackage too... but if you're really want to stick with the [[Double]] type, you can a

Re: [Haskell-cafe] Re: OT: Literature on translation of lambda calculus to combinators

2010-01-29 Thread Job Vranish
Cool, Thanks :D also quickcheck says the two algorithms are equivalent :) On Fri, Jan 29, 2010 at 4:33 AM, Nick Smallbone wrote: > Job Vranish writes: > > > Ideally we'd like the type of convert to be something like: > > convert :: LambdaExpr -> SKIExpr > > b

Re: [Haskell-cafe] OT: Literature on translation of lambda calculus to combinators

2010-01-28 Thread Job Vranish
nvert (Lambda y e))) A while ago I tried modifying the algorithm to be pure top-down so that it wouldn't have this problem, but I didn't have much luck. Anybody know of a way to fix this? - Job On Thu, Jan 28, 2010 at 10:21 AM, Felipe Lessa wrote: > On Thu, Jan 28, 2010 at 09:23

Re: [Haskell-cafe] OT: Literature on translation of lambda calculus to combinators

2010-01-28 Thread Job Vranish
There is a nice simple algorithm on wikipedia: http://en.wikipedia.org/wiki/Combinatory_logic (for both SKI and BCKW) translated to haskell: -- The anoying thing about the algorithm is that it is difficult to separate the SKI and LC expression types -- it's easiest to just combine them. data Exp

Re: [Haskell-cafe] Re: Why?

2009-12-10 Thread Job Vranish
> > I won't mention the name so as not to offend anyone. Oh I'm sure we can handle it ;) Though I'm curious as to how a language could be effect free in a practical sense, but not a strict one? could you give an example? To answer your original question, there are many benefits haskell gains fr

Re: [Haskell-cafe] IORefs and weak pointers

2009-11-04 Thread Job Vranish
Wow, this looks like a bug to me. If it's not a bug, then it's horribly unintuitive. I extended your example in an effort to figure out what was going on. Apparently weak pointers loath live IORefs: import Data.IORef import Data.Maybe import System.Mem import System.Mem.Weak import Control.Monad

Re: [Haskell-cafe] IORefs and weak pointers

2009-11-02 Thread Job Vranish
Could mkWeakPair do what you want? http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-Weak.html#v:mkWeakPair Or are you trying to do something else? - Job 2009/11/2 Patai Gergely > Hello all, > > I wanted to create a weak pointer with an IORef as the key and something > else as

Re: [Haskell-cafe] Applicative but not Monad

2009-10-30 Thread Job Vranish
If you use a monad instance for ZipLists as follows: instance Monad ZipList where return x = ZipList $ repeat x ZipList [] >>= _ = ZipList [] xs >>= f = diagonal $ fmap f xs (where diagonal pulls out the diagonal elements of a ziplist of ziplists) It will satisfy all the monad laws _except

Re: [Haskell-cafe] Test cases for type inference

2009-10-21 Thread Job Vranish
I was recently working on an type inference algorithm and to test it I did the following: Used the quickcheck Arbitrary typeclass to generate expressions Inferred types of the expressions using my algorithm, converted the expressions that passed inference to haskell and wrote them to a file (

Re: [Haskell-cafe] Genuine Need For Persistent Global State?

2009-10-16 Thread Job Vranish
Stable pointers might do what you want: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-StablePtr.html Though an IORef would probably work just as well, depending on how you needed to use it.. - Job On Fri, Oct 16, 2009 at 2:59 PM, Alan Carter wrote: > Hi, > I've been looking at

Re: [Haskell-cafe] Why there is not standard Monoid instance for ZipList a?

2009-10-16 Thread Job Vranish
Nope, Other than possibly adding library clutter. I have a package that provides many instances and common functions for ZipLists. Eventually I might stick it on hackage, but currently it's here: http://github.com/jvranish/ZipList I really with there was a way to switch Applicative (or other) ins

Re: [Haskell-cafe] Num instances for 2-dimensional types

2009-10-05 Thread Job Vranish
In what way is it not a number? data MyNumber a = MyNum a a deriving (Show, Eq) instance Functor MyNum where fmap f (MyNum a b) = MyNum (f a) (f b) instance Applicative MyNum where pure a = MyNum a a MyNum f g <*> MyNum a b = MyNum (f a) (g b) instance (Num a) => Num (MyNum a) where

Re: [Haskell-cafe] Num instances for 2-dimensional types

2009-10-05 Thread Job Vranish
You are in luck! Such an instance is very simple with Applicative. If the type you want a Num instance for is a member of the Applicative type class you can define it like this: instance (Num a) => Num (Vector2 a) where a + b = pure (+) <*> a <*> b a - b = pure (-) <*> a <*> b a * b = pure

Re: [Haskell-cafe] Splitting data and function declarations over multiple files

2009-10-01 Thread Job Vranish
ilerplate associated with this technique. - Job On Thu, Oct 1, 2009 at 11:35 AM, Job Vranish wrote: > Along the projection/co-algebra lines (I actually didn't know that's what > they were called until today :) yay for learning new things!) > > How about something like t

Re: [Haskell-cafe] Splitting data and function declarations over multiple files

2009-10-01 Thread Job Vranish
Along the projection/co-algebra lines (I actually didn't know that's what they were called until today :) yay for learning new things!) How about something like this: -- Define "prototypes" for your class of actions here data Actor = Actor {pos::Vector2 Float, move::Vector2 Float -> Actor} -- s

Re: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc.

2009-09-29 Thread Job Vranish
Andrew Coppin wrote: > how do we fix all this? > I think the key here is to reduce the cost of contribution to a minimum. Make it as easy as possible to contribute an example, or to fill in some missing documentation (and to find it later). Cabal and hackage have made it very easy to contribut

Re: [Haskell-cafe] Market Place for Haskell development teams?

2009-09-29 Thread Job Vranish
If there is demand for shops to work on smaller jobs in haskell then I think a having a more specific marketplace/communication platform for haskell work would be very helpful. If there is a perceived demand, supply will soon follow. - Job On Tue, Sep 29, 2009 at 5:48 AM, Jörg Roman Rudnick < jo

Re: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell

2009-09-25 Thread Job Vranish
Short answer: There is no good way of doing what you want. This is actually one of my biggest annoyances with haskell (right up there with disallowing infinite types). They are many techniques that work better or worse depending on the application, but non are very satisfactory IMO. Your typeclass

Re: [Haskell-cafe] code-build-test cycle

2009-09-18 Thread Job Vranish
Yeah linking in windows is _very_ slow. Supposedly this is because the linker forks a lot of processes. In linux this is fine as forking is dirt cheap, but in windows (at least older versions, not completely sure about vista or 7) forking is expensive. Building a Qt app on my EEE in linux only tak

Re: [Haskell-cafe] weak pointers and memoization (was Re: memoization)

2009-09-18 Thread Job Vranish
Hey it works :D Here is a proof of concept: http://gist.github.com/189104 Maybe later today I'll try to make a version that can be safely used outside IO. - Job On Fri, Sep 18, 2009 at 10:19 AM, Job Vranish wrote: > Yeah it seems like the general solution to the problem would be s

Re: [Haskell-cafe] weak pointers and memoization (was Re: memoization)

2009-09-18 Thread Job Vranish
a server-like application. If the parts pruned > > aren't garbage collected, the space leak will eventually be > > catastrophic. Either the memo table or the graph structure itself will > > outgrow available memory. > > > > -Rod > > > > > > On

Re: [Haskell-cafe] Peano axioms

2009-09-17 Thread Job Vranish
The problem is that you are using 'suc' as if it is a constructor: ((suc m) `eq` (suc n) = m `eq` n) You'll have to change it to something else, and it will probably require adding an unpacking function to your class and it will probably be messy. I'd suggest you make use of the Eq typeclass and d

Re: [Haskell-cafe] weak pointers and memoization (was Re: memoization)

2009-09-17 Thread Job Vranish
What are you trying to use this for? It seems to me that for memo tables you almost never have references to they keys outside the lookup table since the keys are usually computed right at the last minute, and then discarded (otherwise it might be easier to just cache stuff outside the function).

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-09-17 Thread Job Vranish
(-) happens to be the only prefix operator in haskell, it also an infix operator. so: > 4 - 2 2 > -3 -3 > ((-) 5) 3 -- note that in this case (-) is treated like any regular function so 5 is the first parameter 2 > (5 - ) 3 2 > (-5 ) -5 > (flip (-) 5) 3 -2 It's a little wart brought about by th

[Haskell-cafe] Fixed length list type?

2009-09-09 Thread Job Vranish
Does anyone know of a hackage package that has fixed length list type that is an instance of Applicative, Foldable and Traversable? (a list type that somehow encodes its length in the type) I've found lots of fixed length list types, but non that are members of the common typeclasses. I've impleme

Re: [Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses

2009-09-03 Thread Job Vranish
n van Steenbergen < mart...@van.steenbergen.nl> wrote: > Job Vranish wrote: > >> A simple but powerful implementation of function lenses (aka functional >> references, accessors, etc..). >> > > Nice! I will definitely give it a whirl when I pick up my MUD again. I&#

[Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses

2009-09-02 Thread Job Vranish
A simple but powerful implementation of function lenses (aka functional references, accessors, etc..). This library provides a convenient way to access and update the elements of a structure. It is very similar to Data.Accessors, but simpler, a bit more generic and has fewer dependencies. I partic

Re: [Haskell-cafe] Cabal install specific version of a package

2009-09-02 Thread Job Vranish
cabal install derive-0.1.4 On Wed, Sep 2, 2009 at 1:12 PM, Grigory Sarnitskiy wrote: > How to install specific version of a package (derive 0.1.4)? > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/h

Re: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory)

2009-09-02 Thread Job Vranish
Did you by chance use the prebuilt ghc binaries? or build ghc manually? - Job On Mon, Aug 31, 2009 at 5:23 PM, Paulo Tanimoto wrote: > Hello, > > On Mon, Aug 31, 2009 at 3:29 PM, Job Vranish wrote: > > I got around this problem by downgrading to 6.10.3 (I think I rebuilt >

Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Job Vranish
t function, stable names are not that useful I guess? they > would cause a space leak? > > On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish wrote: > >> I also would like a isStableNameTargetAlive function. >> Though if you had such a function then you probably _could_ make a >&

Re: [Haskell-cafe] GUI library

2009-09-01 Thread Job Vranish
> into trouble. I hope that qtHaskell is straightforward. > > Qt depends on deriving user classes. How is this handled in qtHaskell? > > Thanks, > > -Mike > > > Job Vranish wrote: > >> I recommend qtHaskell. >> I am a big fan of Qt in general. It has good documen

Re: Re[2]: [Haskell-cafe] GUI library

2009-09-01 Thread Job Vranish
Deallocation is automatic (just like C++ Qt) C++ Qt has excellent unicode support. I haven't explicit tried it in qtHaskell, but as far as I know it should work just fine. Unfortunatly it does not currently build just with cabal, however the build scripts are very clean (no configure) and the has

Re: [Haskell-cafe] GUI library

2009-08-31 Thread Job Vranish
I recommend qtHaskell. I am a big fan of Qt in general. It has good documentation and extensive examples, is very well designed, and has a good license. I'd even say the C++ version is good choice for beginners (certainly easier to understand/use than say GTK). The qtHaskell bindings are also prett

Re: [Haskell-cafe] Cleaning up stable names?

2009-08-31 Thread Job Vranish
I also would like a isStableNameTargetAlive function. Though if you had such a function then you probably _could_ make a deRefStableName function, which, since there isn't one, probably means that such a function would be hard to make. - Job On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen wrot

Re: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory)

2009-08-31 Thread Job Vranish
rade to the Haskell platform, I deleted ghc but not my original cabal >> installation. >> >> When I got the error, I deleted my (old) copy of >> >> ~/.cabal/config >> >> and it seemed to fix the problem. I'd assumed something in the config file >&g

Re: [Haskell-cafe] Re: Time constrained computation

2009-08-28 Thread Job Vranish
I tried this using timeout, but was never able to get it to work. The timeout doesn't behave like I expect. I can take several seconds for it to timeout, even with very low timeouts. Any ideas? - Job module Main where import Data.IORef import System.Timeout import System.IO.Unsafe tailScan f (

Re: [Haskell-cafe] Applicative and Monad transformers

2009-08-27 Thread Job Vranish
You could test your instance using the checkers package on hackage (has quickcheck properties for common typeclasses) to see if it fulfills the applicative laws. But I'm not sure if it is acceptable to define applicative instances that don't match the monad instance. Does anyone know of libraries

Re: [Haskell-cafe] Re: Keeping an indexed collection of values?

2009-08-21 Thread Job Vranish
at 12:24 PM, Sebastian Fischer < s...@informatik.uni-kiel.de> wrote: > > On Aug 21, 2009, at 5:11 PM, Job Vranish wrote: > > I also added an extra phantom type parameter to the collection (and key) >> so that I can prevent keys from being used on different collections even

Re: [Haskell-cafe] Re: Keeping an indexed collection of values?

2009-08-21 Thread Job Vranish
bleName as the key in the collection, if they don't match either raise an error or return Nothing. Not sure if I feel that evil though :D Thanks again for the input :) - Job On Fri, Aug 21, 2009 at 7:26 AM, Heinrich Apfelmus < apfel...@quantentunnel.de> wrote: > Heinrich Apfelmus wrote: &

Re: [Haskell-cafe] Re: Parsec lookahead and <|>

2009-08-20 Thread Job Vranish
try works in this case, but it won't if we are using a parser which can consume and then fail (instead of char 'a'). In which case we may want it to fail without exploring the second option. Hmmm though you might be right. Having lookAhead return Consumed is only a problem if the parser passed to

Re: [Haskell-cafe] Right way to implement setPixel function

2009-08-20 Thread Job Vranish
Opps: setPixel = State setPixel' should be: setPixel x y rgb = State $ setPixel' x y rgb - Job On Thu, Aug 20, 2009 at 1:05 PM, Job Vranish wrote: > Your setPixel function is almost ready to work in a State monad > If you modify your setPixel function slightly like so: >

Re: [Haskell-cafe] Right way to implement setPixel function

2009-08-20 Thread Job Vranish
Your setPixel function is almost ready to work in a State monad If you modify your setPixel function slightly like so: setPixel' :: Int -> Int -> Color -> B.ByteString -> ((), B.ByteString) setPixel' x y (r,g,b) image = ((), B.concat [beforePixel, pixel, afterPixel]) and then wrap it in the Stat

  1   2   >