Haskell's record syntax is quite nice, for a number of reasons. However,
suppose I have some record:
data Foobar = Foobar {foo1, foo2, foo3...}
Now suppose that foo3 :: [Int], and I want to prepend 5 to it. I end up
having to write something like
let v1 = v0 {foo3 = 5 : (foo3 v0)}
If the
Take a look at Data.Accessor on hackage:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor-template
-- ryan
On Sun, Mar 29, 2009 at 2:13 AM, Andrew Coppin
andrewcop...@btinternet.com wrote:
I've uploaded my CMonad package to Hackage. It allows you to write
Haskell code in a C style.
Unfortunately, GHC lacks certain optimizations to make efficient code
when using CMonad,
so instead of C speed you get low speed.
Example: Computing some Fibonacci numbers:
fib = do {
a -
Excerpts from Henning Thielemann's message of Sat Mar 28 21:49:33 +0100 2009:
On Sat, 28 Mar 2009, John Lato wrote:
From: Donn Cave d...@avvanta.com
I have never felt that I really understood that one.
Honestly, me neither, until recently. I'm only barely starting to
understand
Ryan Ingram wrote:
Take a look at Data.Accessor on hackage:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor-template
So, to summarise, it provides a datatype to encapsulate a pair of
get/set
On Sat, Mar 28, 2009 at 9:49 PM, Henning Thielemann
lemm...@henning-thielemann.de wrote:
On Sat, 28 Mar 2009, John Lato wrote:
From: Donn Cave d...@avvanta.com
I have never felt that I really understood that one.
Honestly, me neither, until recently. I'm only barely starting to
Now suppose that foo3 :: [Int], and I want to prepend 5 to it. I end
up having to write something like
let v1 = v0 {foo3 = 5 : (foo3 v0)}
There used to be a feature in pre-Haskell'98 called named field
puns, which allows to use a shorter form of field access. Your
example would come out
There is a page for extensible records in the wiki:
http://www.haskell.org/haskellwiki/Extensible_record
Haskell's records system has many insuficiencies.
Some libraries (see grapefruit or HaskellDB) encode records as
classes, but although some proposals Haskell still lacks a good
implementation
2009/03/29 Lennart Augustsson lenn...@augustsson.net:
...GHC lacks certain optimizations to make efficient code when
using CMonad, so instead of C speed you get low speed.
Is this surprising to anyone?
--
Jason Dusek
___
Haskell-Cafe mailing list
Hi,
I'm trying to have hsc2hs interpret this snippet that picks a calling
convention to use for FFI imports:
#if !defined(CALLCONV)
#ifdef WITH_WINSOCK
#define CALLCONV stdcall
#else
#define CALLCONV ccall
#endif
#endif
foreign import CALLCONV unsafe send
c_send :: CInt - Ptr a - CSize -
On Sunday 29 March 2009, Lennart Augustsson wrote:
I've uploaded my CMonad package to Hackage. It allows you to write
Haskell code in a C style.
Now I've heard that Haskell makes a fine (if not the finest) imperative
language, but isn't this taking that thought a bit too far ;)
On Sat, 2009-03-28 at 12:51 +0300, Gregory Petrosyan wrote:
On Sat, Mar 28, 2009 at 10:53 AM, Ketil Malde ke...@malde.org wrote:
So the difference between an exception or an error type is mainly what
you intend to do about it. There's no point in wrapping divisions in
Maybe unless you
Well, yes and no. GHC actually does a decent job when given very
imperative code with references and mutable arrays.
Now the type I use to wrap the references to get type safe l-values
and r-values makes it tricker, and ghc lacks a crucial optimization
for specialization of constructor returns.
If my primary concern is speed I'll write in C.
2009/3/29 Marcin Kosiba marcin.kos...@gmail.com:
On Sunday 29 March 2009, Lennart Augustsson wrote:
I've uploaded my CMonad package to Hackage. It allows you to write
Haskell code in a C style.
Now I've heard that Haskell makes a fine (if not
Hi,
Thanks again for the help last night.
The second function cf2 is an attempt to reverse the process of the first
function, i.e., given a rational number it returns a list of integers, possibly
infinite, but you shouldn't get into trouble if you use 98%67 as input (output
should be
Henning Thielemann schlepp...@henning-thielemann.de wrote:
Actually, I really object to have exception handling built into IO
monad.
I couldn't agree more. If I want to write non-recovering code, I can
always just say
(Right foo) - readLine
, and hope that the RTS is smart enough to print
I think you probably mean ==, the comparison operator (function), not
= (assignment in let-forms or where-forms)
-Ross
On Mar 29, 2009, at 1:40 PM, michael rice wrote:
Hi,
Thanks again for the help last night.
The second function cf2 is an attempt to reverse the process of the
first
Hi,
when I tried to reorganize some code to use the data-accessor and
data-accessor-template packages, i stumbled across a strange effect:
When using template haskell some things are out of scope that really
shouldn't be. Let me give an example:
== T.hs ==
{-# LANGUAGE
Mmm, my email was indeed very unclear about my question.
A very simple example: suppose a development team is working on a program.
This program consist of modules A and B. Each module has it's own Darcs
repository.
Module A requires B. When a new developer wants to get the source code, he
does a
You can use floor in a Rational directly, no need to take it apart and divide.
There is no need to write (toRational 1), just write 1.
Don't write (subtract ai a), write (ai - i).
You also have a type error; the ai should no be a Rational, so you
need to move to toRational call to the
Am Sonntag 29 März 2009 19:40:19 schrieb michael rice:
Hi,
Thanks again for the help last night.
The second function cf2 is an attempt to reverse the process of the
first
function, i.e., given a rational number it returns a list of integers,
possibly infinite,
Not for rational numbers.
Peter Verswyvelen bugf...@gmail.com wrote:
To me, any version control system should be able to track dependencies
between repositories. Something similar like Cabal's dependency
system.
So my question is really, how do you solve the dependency tracking
between several Darcs repositories?
Hi Martijn,
Martijn van Steenbergen wrote:
[...]
Apart from the specific problematic file you gave, I had some other
scoping issues when using TH to generate the accessors. I worked around
this by defining my data types in a separate module Types and calling
the TH functions in that module
Hi.
As with a previous post, I think I have found a possible memory problem
with the uvector package.
I have this data structure (for, again, my Netflix Prize project):
IntMap (UArr (Word16 :*: Word8))
I was adding elements to the map using something like:
v = map singletonU (a :*:
manlio_perillo:
Hi.
As with a previous post, I think I have found a possible memory problem
with the uvector package.
I have this data structure (for, again, my Netflix Prize project):
IntMap (UArr (Word16 :*: Word8))
I was adding elements to the map using something like:
v =
Hi Stephan,
Stephan Friedrichs wrote:
Hi,
when I tried to reorganize some code to use the data-accessor and
data-accessor-template packages, i stumbled across a strange effect:
When using template haskell some things are out of scope that really
shouldn't be.
Apart from the specific
It looks like the scope is interrupted just above $( ... ) - but I'd
like to know why and find a more beautiful way than just moving all th
calls to the bottom of the module file :)
Top-level splices can introduce bindings. IIRC, the current TH
implementation uses a simple sequencing approach,
On Sun, 29 Mar 2009, Peter Verswyvelen wrote:
Module A requires B. When a new developer wants to get the source code, he
does a darcs get server://program/A, which gives him only the latest
version of A. So he manually needs to do darcs get server://program/B
(that B is required is usually
Don Stewart ha scritto:
[...]
So the question is: why appending an array of only one element to an
existing array causes memory problems?
It must copy the entire array.
Isn't it the same with snocU?
And, since the final result is the same, what happens to the temporary
memory used for
On Sun, Mar 29, 2009 at 10:04 PM, Ganesh Sittampalam gan...@earth.liwrote:
There's an (unimplemented) proposal by David Roundy for darcs sub-repos
that would solve this problem: you have a darcs patch type that means
depend on this patch from this other darcs repo which will be checked out
in
Correct, if it can be stated as a Rational then it terminates. I was messing
around last night with the first function on a sequence that approximates
sqrt(2)
cf (take 25 (1: [2,2..]))
forgetting that while the sequence is infinite, I only grabbed the first 25
elements.
Your replacement code
manlio_perillo:
Don Stewart ha scritto:
[...]
So the question is: why appending an array of only one element to an
existing array causes memory problems?
It must copy the entire array.
Isn't it the same with snocU?
And, since the final result is the same, what happens to the
I'm a Lisper, kind of feeling my way around here in Haskell, so please bear
with me.
I did the things you suggested, but I think the last one may have gotten
garbled. Anyway, this is what I ended up with
cf2 :: Rational - [Int]
cf2 a = let ai = floor a
in
if a ==
Peter Verswyvelen bugf...@gmail.com writes:
Mmm, my email was indeed very unclear about my question.
A very simple example: suppose a development team is working on a program.
This program consist of modules A and B. Each module has it's own Darcs
repository.
Module A requires B. When a
On 2009 Mar 29, at 16:19, michael rice wrote:
but I'm still at least one error short of a clean run
Main :load cf.hs
ERROR cf.hs:7 - Type error in application
*** Expression : ai : cf2 (1 / (a - ai))
*** Term : ai
*** Type : Ratio Integer
*** Does not match : Int
Where
On 2009 Mar 29, at 16:26, Xiao-Yong Jin wrote:
Peter Verswyvelen bugf...@gmail.com writes:
Module A requires B. When a new developer wants to get the source
code, he
does a darcs get server://program/A, which gives him only the
latest version
of A. So he manually needs to do darcs get
On 2009 Mar 29, at 16:27, Brandon S. Allbery KF8NH wrote:
cf2 a = let ai = floor a
rai = toRational ai
in
if a == rai
then [ai]
else rai : cf2 (1 / (a - ai))
Nope, went a bit too fast there, ignore me
--
brandon s. allbery
cf2 :: Rational - [Int]
cf2 a = let ai = floor a -- Doesn't this make ai an Int? -Michael
in
if a == (toRational ai)
then [ai]
else ai : cf2 (1 / (a - ai))
--- On Sun, 3/29/09, Brandon S. Allbery KF8NH allb...@ece.cmu.edu
IntMap (UArr (Word16 :*: Word8))
I was adding elements to the map using something like:
v = map singletonU (a :*: b)
insertWith appendU k v m
However doing this eats a *lot* of memory.
Since 'insertWith' doesn't actually do the 'appendU', the appends
will also be compressed in
cf2 a = let ai = floor a
air = toRational ai
in ai : if a == air then [] else cf2 (1 / (a - air))
On 30 Mar 2009, at 00:19, michael rice wrote:
I'm a Lisper, kind of feeling my way around here in Haskell, so
please bear with me.
I did the things you suggested, but I
Works like a charm. Here's a final copy for those interested.
Michael
=
import Data.Ratio
cf2 :: Rational - [Int]
cf2 a = let ai = floor a
air = toRational ai
in ai : if a == air then [] else cf2 (1 / (a - air))
--- On Sun, 3/29/09, Miguel Mitrofanov
Manlio Perillo ha scritto:
Hi.
As with a previous post, I think I have found a possible memory problem
with the uvector package.
I have this data structure (for, again, my Netflix Prize project):
IntMap (UArr (Word16 :*: Word8))
[...]
Today I have rewritten my program to use `alter`
I was playing with Text.XHtml.Table but couldn't use it to output tables.
( cell . toHtml $ a ) `beside` (cell . toHtml $ b )
tr
a b /tr
already seems wrong -- should be two cells, right? And the result
doesn't get embedded in a table tag?
Is there something I'm missing?
Working code
Claus Reinke ha scritto:
IntMap (UArr (Word16 :*: Word8))
I was adding elements to the map using something like:
v = map singletonU (a :*: b)
insertWith appendU k v m
However doing this eats a *lot* of memory.
Since 'insertWith' doesn't actually do the 'appendU', the appends
Don Stewart ha scritto:
manlio_perillo:
Don Stewart ha scritto:
[...]
So the question is: why appending an array of only one element to an
existing array causes memory problems?
It must copy the entire array.
Isn't it the same with snocU?
And, since the final result is the same, what
On Sun, Mar 29, 2009 at 10:26 PM, Xiao-Yong Jin xj2...@columbia.edu wrote:
Now assume you don't have 2 modules but dozens...
I can't imagine such kind of situation, unless you are
really working on a very big project. Usually, if your
project depends on other projects, mostly it should
But Claus was right, appendU is lazy; this seems to be the cause of the
problem.
appendU is strict, insertWith just doesn't force it (follow the source link
in the haddocks to see why).
However now I don't really understand why the two implementations
differs in lazyness.
Or, to ask a
I've been doing some basic work on a support library for type level
programming ( see
http://hackage.haskell.org/trac/summer-of-code/ticket/1541 ). I know
there have been similar attempts using fundeps ( Edward Kmett showed me
some of his work, but I've lost the address... ) but this approach
Thomas Hartman wrote:
I was playing with Text.XHtml.Table but couldn't use it to output tables.
( cell . toHtml $ a ) `beside` (cell . toHtml $ b )
tr
a b /tr
already seems wrong -- should be two cells, right? And the result
doesn't get embedded in a table tag?
'cell' is not a TD
Nested constructed product returns? Or constructed sums?
lennart:
Well, yes and no. GHC actually does a decent job when given very
imperative code with references and mutable arrays.
Now the type I use to wrap the references to get type safe l-values
and r-values makes it tricker, and ghc
On Fri, 27 Mar 2009 15:34:06 +0100, Henk-Jan van Tuyl
hjgt...@chello.nl wrote:
On Thu, 26 Mar 2009 20:41:57 +0100, Henk-Jan van Tuyl hjgt...@chello.nl
wrote:
Your space ship enters an asteroid belt, try to avoid
collisions!
wxAsteroids is a game demonstrating the wxHaskell GUI.
More about
51 matches
Mail list logo