Hello,
I'm trying to write code that will take a mutable 2D array and normalize it
by dividing all elements by the largest element.
I managed to write code to do this, but it seems overly complex. I could
write something much simpler in Clean or C++. Most likely, my code is
complex because I
I prerequest your forgiveness if I sound patronizing, I'm just writing
everything that comes to mind.
2008/2/2 Jeff φ [EMAIL PROTECTED]:
{-# OPTIONS_GHC -fglasgow-exts -fbreak-on-exception #-}
-- normalize_ary This takes a mutable array. Determines the largest
-- element in the array
On Feb 1, 2008 10:33 PM, Wolfgang Jeltsch [EMAIL PROTECTED] wrote:
Actually it would maybe be better to create common high-level
interface that could include unary, binary and decimal arithmetic so
that the library could be easily reused in other projects (people like
Bjorn, seem to be
This is my attempt at some nicer code:
maximum' (x:xs) = foldl' max x xs
maximum' _ = undefined
modifyArray :: (MArray a e m, Ix i) = (e - e) - a i e - m ()
modifyArray fn arr = do
bounds - getBounds arr
forM_ (range bounds) (modifyElement fn arr)
modifyElement :: (MArray a e m, Ix i) =
Sorry, I was lazy. New maximum':
maximum' = foldl1' max
On 02/02/2008, Rodrigo Queiro [EMAIL PROTECTED] wrote:
This is my attempt at some nicer code:
maximum' (x:xs) = foldl' max x xs
maximum' _ = undefined
modifyArray :: (MArray a e m, Ix i) = (e - e) - a i e - m ()
modifyArray fn arr =
On Feb 1, 2008 10:32 PM, Wolfgang Jeltsch [EMAIL PROTECTED] wrote:
Am Freitag, 1. Februar 2008 13:00 schrieb Alfonso Acosta:
On Jan 31, 2008 11:35 PM, Wolfgang Jeltsch [EMAIL PROTECTED]
This is essentially what I had in mind. While Oleg's implementation
needs a thrusted core, the GADT
On Feb 2, 2008 2:54 PM, Alfonso Acosta [EMAIL PROTECTED] wrote:
Just compare
f :: List (() :- D1 :- D0 :- D0 :- 1000) Int - List (() :- D1 :- D0
:- D0 :- D0) Int
I meant
f :: List (() :- D1 :- D0 :- D0 :- D0) Int - List (() :- D1 :- D0 :-
D0 :- D0) Int
sorry for the typo
On Fri, 2008-02-01 at 11:42 +, Magnus Therning wrote:
Is it possible to get Cabal to use 'cl' (Microsoft's C/C++ compiler
shipped with Visual Studio Express)?
The problem is to get GHC to use 'cl'. That's a longer term project that
GHC HQ are interested in. There's something about it on
On Fri, 2008-02-01 at 17:05 -0500, bbrown wrote:
There seems to be an issue with the hsql-sqlite3. Anyone have a fix. Should
I use what is from darcs?
HSQL is currently unmaintained. Frederik Eaton was considering taking it
over: http://www.nabble.com/HSQL-defunct--td14978532.html
Gentoo
Just noticed, by the way, that haskelldb doesn't build correctly
because it still hasn't updated the cabal for the base split. On the
other hand, the development repo (which is 0.11 -- 0.10 is on
hackage) builds fine. Are the maintainers planning to get an updated
version on hackage?
--S
2008/2/2, Rodrigo Queiro [EMAIL PROTECTED]:
Sorry, I was lazy. New maximum':
maximum' = foldl1' max
Sorry but none of those propositions change the heart of the problem :
the list of elements is totally produced before she can be consumed
due to the strict monadic (IO or ST) nature of getElems.
Magnus Therning wrote:
Is it possible to get Cabal to use 'cl' (Microsoft's C/C++ compiler
shipped with Visual Studio Express)?
Duncan Coutts wrote:
The problem is to get GHC to use 'cl'. That's a longer term project that
GHC HQ are interested in. There's something about it on the GHC dev
On Jan 28, 2008 12:45 AM, [EMAIL PROTECTED] wrote:
It seems strange that you need the types e and e' (perhaps this is a
quirk or a bug of GHC 6.8). With GHC 6.6, I have derived the following
instance (Floating f, MetricSpace e f, HFoldr ApplyDistSum Float l1 f,
HZip (HCons e l)
On Sat, Feb 02, 2008 at 12:57:47PM +, Rodrigo Queiro wrote:
This is my attempt at some nicer code:
maximum' (x:xs) = foldl' max x xs
maximum' _ = undefined
modifyArray :: (MArray a e m, Ix i) = (e - e) - a i e - m ()
modifyArray fn arr = do
bounds - getBounds arr
forM_
On Sat, 2008-02-02 at 18:15 +0100, Felix Martini wrote:
Magnus Therning wrote:
Is it possible to get Cabal to use 'cl' (Microsoft's C/C++ compiler
shipped with Visual Studio Express)?
Duncan Coutts wrote:
The problem is to get GHC to use 'cl'. That's a longer term project that
GHC HQ
On Sat, 2008-02-02 at 12:33 -0500, Denis Bueno wrote:
Is it possible to use the ST monad as a (drop-in) replacement for the
State monad in the following situation? If not, is there a best
practice for refactoring?
I have a bunch of functions that return state actions:
type MyState =
Duncan Coutts wrote:
[..]
It would be reasonable to use the system C compiler rather than ghc,
however we will have to do more work to find what extra include dirs get
used and have Cabal pass those.
Currently we pass the -package flags to ghc which ghc uses to look up
what include dirs
On Sat, 2008-02-02 at 18:50 +, Magnus Therning wrote:
Duncan Coutts wrote:
[..]
It would be reasonable to use the system C compiler rather than ghc,
however we will have to do more work to find what extra include dirs get
used and have Cabal pass those.
Currently we pass the
You can also do something like the following:
newtype StateST st s a = StateST { internalRunStateST :: ReaderT
(STRef st s) (ST st) a }
instance MonadState s (StateST s st) where
get = ask = readSTRef
put s = ask = \ref - writeSTRef ref s
runStateST :: StateST st s a - s - ST st a
Yes. It would be nice to have an updated HSQL release first though.
/Björn
On Feb 2, 2008 6:07 PM, Sterling Clover [EMAIL PROTECTED] wrote:
Just noticed, by the way, that haskelldb doesn't build correctly
because it still hasn't updated the cabal for the base split. On the
other hand, the
On Sat, 2 Feb 2008, [ISO-8859-7] Jeff ö wrote:
Hello,
I'm trying to write code that will take a mutable 2D array and normalize it
by dividing all elements by the largest element.
Are you sure you need the arrays to be mutable? Maybe it's fast enough to
do the copying - it's significantly
Hello all,
I've been working on a source code syntax highlighting library. It is
now somewhat usable, and help would be welcome in testing it further, so
I'm making it publicly available:
darcs get http://johnmacfarlane.net/repos/highlighting-kate
Currently, the following languages are
I am working on haskell bindings to C functions using FFI. I have
a callback function that returns IO (). When I pass in the callback
function:
foo = printf foo
it crashes (is there an easy way to debug this exception using ghc6.8.2?)
bot: SilcClient_d1al: uncaught exception
however,
Thanks for all the responses. I have never used monad transformers
before, but StateT is welcome and really cool. I didn't even think to
look them up.
I have a follow up question. I eventually get to a point where I have
a value of type (ST s (Maybe (STUArray s Int Int))), and I need
somehow
Duncan Coutts wrote:
[..]
Just so I'm sure I understand...
Sure thing.
Or are you just trying to link some C code statically into a haskell
program, but it just so happens that this C code relies on being built
with MS's C compiler rather than gcc.
Yes, this is exactly it. I mean, I could
Am Samstag, 2. Februar 2008 schrieb Tim Newsham:
I am working on haskell bindings to C functions using FFI. I have
a callback function that returns IO (). When I pass in the callback
function:
I suspect this has to do with printf returning 'undefined' if you use it
with an IO type.
Am Samstag, 2. Februar 2008 23:17 schrieb Denis Bueno:
Thanks for all the responses. I have never used monad transformers
before, but StateT is welcome and really cool. I didn't even think to
look them up.
I have a follow up question. I eventually get to a point where I have
a value of
I'm not a fan of parameterizing the Stream class over the monad parameter `m':
class Stream s m t | s - t where
uncons :: s - m (Maybe (t,s))
which leads to instance declarations like so:
instance Monad m = Stream [tok] m tok where
uncons [] = return $ Nothing
uncons (t:ts)
Hello
I'm
trying
to
define
functions
that
allow
you
to
traverse
a
bounded
enumeration,
wrapping
at
the
start
and
the
end.
My implementation looks like this:
next,
prev
::
(Enum
a,
Bounded
a)
=
a
-
a
next
=
turn
1
prev
=
turn
(-1)
turn
::
[Resending
with
formatting
fixed.]
Hello
I'm
trying
to
define
functions
that
allow
you
to
traverse
a
bounded
enumeration,
wrapping
at
the
start
and
the
end.
My
implementation
looks
like
this:
next,
prev
::
(Enum
a,
Bounded
a)
=
a
-
a
next
=
On Feb 2, 2008, at 18:41 , Ben Butler-Cole wrote:
No instance for (Bounded a)
arising from use of `maxBound' at Hbot.hs:6:34-41
(...)
My (clearly flawed) understanding of the signature I've specified
for 'turn' means *exactly* that a is Bounded.
The problem is that the scope of a
On
Feb
2,
2008,
at
18:41
, I
wrote:
No
instance
for
(Bounded
a)
arising
from
use
of
`maxBound'
at
Hbot.hs:6:34-41
(...)
My
(clearly
flawed)
understanding
of
the
signature
I've
specified
for
'turn'
means
*exactly*
that
a
is
Bounded.
I'm getting a weird build error:
[ 9 of 95] Compiling Plugin.Pl.Common ( Plugin/Pl/Common.hs,
dist/build/lambdabot/lambdabot-tmp/Plugin/Pl/Common.o )
/tmp/ghc52608_0/ghc52608_0.s: Assembler messages:
/tmp/ghc52608_0/ghc52608_0.s:36:0: Error: unassigned file number 1
[... more of these ...]
I
On Sat, 2 Feb 2008, Antoine Latter wrote:
I'm not a fan of parameterizing the Stream class over the monad
parameter `m':
snip
I looked through the sources and I didn't see anywhere where this
parameterization gained anything. As a proof of this I did a
mechanical re-write removing the
On Sat, 2008-02-02 at 22:33 +, Magnus Therning wrote:
Duncan Coutts wrote:
[..]
Just so I'm sure I understand...
Sure thing.
Or are you just trying to link some C code statically into a haskell
program, but it just so happens that this C code relies on being built
with MS's C
On Feb 2, 2008 5:28 PM, Antoine Latter [EMAIL PROTECTED] wrote:
I'm not a fan of parameterizing the Stream class over the monad parameter
`m':
class Stream s m t | s - t where
uncons :: s - m (Maybe (t,s))
which leads to instance declarations like so:
instance Monad m = Stream
On Sat, 2 Feb 2008, Antoine Latter wrote:
To expand on this point, side-effect instances of Stream don't play
nice with the backtracking in Text.Parsec.Prim.try:
import Text.Parsec
import Text.Parsec.Prim
import System.IO
import Control.Monad
type Parser a = (Stream s m Char) =
On Sat, 2008-02-02 at 20:43 -0600, Antoine Latter wrote:
On Feb 2, 2008 5:28 PM, Antoine Latter [EMAIL PROTECTED] wrote:
I'm not a fan of parameterizing the Stream class over the monad parameter
`m':
class Stream s m t | s - t where
uncons :: s - m (Maybe (t,s))
which leads to
Hey everyone:
I'd like to make a short announcement that with the permission of its
maintainer, I've uploaded HList v0.1 to Hackage. You can find the Hackage page
here: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HList-0.1.
'cabal install HList' should also work.
HList for
39 matches
Mail list logo