Re: [Haskell-cafe] How to translate Haskell to other languages?

2008-10-11 Thread Matthew Naylor
Hi Jason, I don't know Python, but let me share some thoughts that you might find useful. First, a few questions about your manual translations. Are your functions curried? For example, can I partially apply zipWith? Also, you put a "thunk" around things like "cons(...)" --- should it not be t

Re: [Haskell-cafe] FPGA / Lava and haskell

2008-07-10 Thread Matthew Naylor
Hi Marc, > The Chalmers Lava homepage tells abouta Xilinx version which should > be merged in soon. But on the xilinx homepage there was no reference > to neither Lava nor haskell.. > I'm thinking about designing a similar tool to www.combimouse.com. you also might consider using a PIC or some su

Re: [Haskell-cafe] Copy on read

2008-05-13 Thread Matthew Naylor
Hi Andrew, my probably dodgy reason for mentioning deforestation is that sharing of intermediate values is a major stumbling block; code that uses data linearly is possibly well suited for deforesting. See Frankau's SASL for a language that deforests all lists simply by not letting you copy them!

Re: [Haskell-cafe] Copy on read

2008-05-11 Thread Matthew Naylor
> Uniqueness typing does not lead to in-place update. If a value is > only used once, then there is no need to update it at all! my understanding is that if a value is uniquely-typed then it is statically known never to have more than one reference, thus it can be modified in-place. Some poten

Re: [Haskell-cafe] Functional board games

2008-04-21 Thread Matthew Naylor
Hi Dougal, > Does anyone know of functional-style implementations of > chess/draughts/go/anything else that might give me ideas? there's the Mate-in-N solver in the nofib suite: ftp://www.cs.york.ac.uk/pub/haskell/nofib.tar.gz It takes quite a simple approach, representing the board as two li

Re: [Haskell-cafe] Designing DSL with explicit sharing [was: I love purity, but it's killing me]

2008-02-16 Thread Matthew Naylor
Hi Oleg, at the possible risk of straying from Tom's original problem, consider the following generator that could conceivably occur in practice: > sklansky f [] = [] > sklansky f [x] = [x] > sklansky f xs = left' ++ [ f (last left') r | r <- right' ] > where > (left, right) = splitAt (leng

Re: [Haskell-cafe] Designing DSL with explicit sharing [was: I love purity, but it's killing me]

2008-02-13 Thread Matthew Naylor
> tricky 0 = constant 0 > tricky d = add e0 e1 > where > (e0, e1) = fork (tricky (d-1)) Oops, I just realised that this isn't a very good example of expressible sharing! The problem is that it doesn't take any inputs, and expressible sharing just collapses (partially evaluates) oper

Re: [Haskell-cafe] Designing DSL with explicit sharing [was: I love purity, but it's killing me]

2008-02-13 Thread Matthew Naylor
Hello again, since Oleg presented an approach to the sharing problem that works on acyclic graphs, I may as well mention an alternative, pure, standard Haskell solution which is to express the fork points in the circuit (or expression), i.e. the points at which an expression is duplicated. You nee

Re: [Haskell-cafe] Designing DSL with explicit sharing [was: I love purity, but it's killing me]

2008-02-13 Thread Matthew Naylor
Hi Oleg, it's not immediately clear (to me at least) how efficient your method will be in "practice". Any method based on common sub-expression elimination surely must inspect every node in the flattened graph. In the worst case, an acyclic graph containing n nodes could have 2^n nodes when flat

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-10 Thread Matthew Naylor
Hi Tom, > So is the general strategy with observable sharing to use > unsafePerformIO with Data.Unique to label expressions at > construction? something like that, yes. Basically, you just need: {-# NOINLINE ref #-} ref x = unsafePerformIO (newIORef x) and you can write expressions like

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-09 Thread Matthew Naylor
: > Emil Axelsson wrote: > > I know of a few of ways to express sharing in a pure language: > > > > 1) "Observable sharing", which, in general, is unsafe. > > 2) Using Template Haskell > > 3) Matthew Naylor has done some work on "expressible sharing&qu

Re: [Haskell-cafe] I love purity, but it's killing me.

2008-02-08 Thread Matthew Naylor
Hi, (Warning: longish message!) There is some concern, and rightly so, that observable sharing is dangerous, and that your Haskell program will explode if you use it, and perhaps even that anyone who uses it is "dirty" and should be sent to matron's for a good scrubbing! However, when used "safe

Re: [Haskell-cafe] Remember the future

2007-08-18 Thread Matthew Naylor
Hi Dan, > > import Control.Monad.State > > > test = do > > put $ x+1 > > x <- return 1 > > return undefined > > > go = execState test undefined I'd just like to point out that you can do something similar without mdo. For example, you can define a monad with newVar, readVar, and wr

Re: Re[6]: [Haskell-cafe] Re: monad subexpressions

2007-08-04 Thread Matthew Naylor
Hi Claus, > but the point is that you have a standard set of operations > when working at that level, including conditionals, assignments, > pointer increments, read/write, etc. you only need to define > lifted variants of each of those operations *once*, in a library. I think that defining lift

Re: [Haskell-cafe] ANNOUNCE: nobench: Haskell implementaion benchmarks. GHC v Hugs v Yhc v NHC v ...

2007-02-19 Thread Matthew Naylor
Hi all, > GHC v Hugs v Yhc v NHC v ... ...Hacle & Clean! I shoved 5 of the benchmarks that Donald used through Hacle, and compiled the outputs using version 2.1 of the Clean compiler. Results are below. As for the other examples, Hacle doesn't like non-Haskell98 and translates arb