I'm binding to `wcwidth` to determine the column widths of
various Unicode characters. I noticed a lot of -- in fact all
-- Chinese characters were being given widths of `-1` when of
course they should have width `2`. This only showed up when I
compiled my program though -- within GHCi, it never happened.
Below my signature is a parred down example that demoes the
bug. It tries to get the width of only one Chinese character.
You can see it like this:
:; ghc --make DemoFailure.hs -o demo && demo
[1 of 1] Compiling Main ( DemoFailure.hs, DemoFailure.o )
Linking demo ...
0x00005cff -1 峿
:; chmod ug+x DemoFailure.hs && DemoFailure.hs
0x00005cff 2 峿
Switching between safe/unsafe does not make any difference. This
was run on a Macintosh.
--
Jason Dusek
#!/usr/bin/env runhaskell
{- DemoFailure.hs -}
{-# LANGUAGE ForeignFunctionInterface
#-}
import Foreign.C
import Data.Char
import Text.Printf
import qualified System.IO.UTF8 as UTF8
Hi all,
This email is literate Haskell. I'm trying to use type families to
express some dependencies between type classes, and I'm running into
trouble, I think because I'm producing chains of dependencies which
the checker can't resolve... Here's a minimised version of the state
I've got myself into. :-)
> {-# LANGUAGE FlexibleContexts #-}
> {-# LANGUAGE TypeFamilies #-}
> module Families where
First a type family where the type Y is functionally dependent on
the type X, and we have a function from Y to ().
> class X a where
> type Y a
> enact :: Y a -> ()
Now another type family, where the type Q is functionally dependent
on the type P, _and_ it must also be an instance of the X
class.
> class (X (Q s)) => P s where
> type Q s
(Perhaps there's a better way to express that dependency?)
Now a function which takes a value whose type is an instance of the Y
depending on the Q depending on the P. (Phew!) The function just
tries to call enact on that value.
> bar :: P s => Y (Q s) -
Haskellers,
I have heard many complaints about the average quality on
documentation. Therefore, I'd like to encourage you all to read Jacob
Kaplan-Moss's series on writing great documentation:
http://jacobian.org/writing/great-documentation/. The articles are
themselves well-written and contain excellent advice (though I
disagree somewhat with the comments on automatically-generated
documentation: I find many libraries are excellently haddocumented).
Jacob Kaplan-Moss is a developer on the Django project, which is well
known for the quality of its documentation.
One issue he brings up is having different types of documentation. My
impression of many Haskell libraries (my own included) is that, while
they may have good reference documentation, they lack tutorials and
topic guides.
Perhaps we could bring up some examples of Haskell projects with
particularly good documentation, as examples to look up to. XMonad has
very good overviews and guides for developers, and I like how each
user-facing xmonad-contrib
Hi,
I have looked the concept of monoid and something related, but
still, I do not know why we use it?
Hello,
I'm currently developing some applications with explicit threading
using forkIO and have strange behaviour on my freshly installed Ubuntu
Karmic 9.10 (Kernel 2.6.31-14 SMP).
Setup:
Machine A: Quadcore, Ubuntu 9.04, Kernel 2.6.28-13 SMP
Machine B: AMD Opteron 875, 8 cores, 2.6.18-164 SMP- (some redhat)
Machine C: Dual-Core, Ubuntu 9.10, Kernel 2.6.31-14 SMP
Compiler on all machines: ghc 6.10.4 (downloaded from GHCs official website)
Program, Compilation, Execution
A simple taskqueue with independent tasks and explicit parallelization
(hence should deliver more or less perfect speedup).
For one core wall-times around 16 are ok, for 2 a bit more than 8 seconds.
Since I used the same sources and Makefiles on all machines all files
were compiled with -threaded and started with +RTS -N2 -RTS.
Testing:
Machine A: Ok (meaning works and delivers the expected speedup)
Machine B: Ok
Machine C: Not ok (with -N2 wall times around 14-15 seconds)
Looking at the core usage, for example with htop, I see that t
Hello,
I'm currently developing some applications with explicit threading
using forkIO and have strange behaviour on my freshly installed Ubuntu
Karmic 9.10 (Kernel 2.6.31-14 SMP).
Setup:
Machine A: Quadcore, Ubuntu 9.04, Kernel 2.6.28-13 SMP
Machine B: AMD Opteron 875, 8 cores, 2.6.18-164 SMP- (some redhat)
Machine C: Dual-Core, Ubuntu 9.10, Kernel 2.6.31-14 SMP
Compiler on all machines: ghc 6.10.4 (downloaded from GHCs official website)
Program, Compilation, Execution
A simple taskqueue with independent tasks and explicit parallelization
(hence should deliver more or less perfect speedup).
For one core wall-times around 16 are ok, for 2 a bit more than 8 seconds.
Since I used the same sources and Makefiles on all machines all files
were compiled with -threaded and started with +RTS -N2 -RTS.
Testing:
Machine A: Ok (meaning works and delivers the expected speedup)
Machine B: Ok
Machine C: Not ok (with -N2 wall times around 14-15 seconds)
Looking at the core usage, for example with htop, I see that t
[Deadlines extended: Abstract due Nov 18; Full paper due Nov 25]
********************************************************************
Final Call For Papers
19th International Workshop on Functional
and (Constraint) Logic Programming
Madrid, Spain, January 17, 2010
http://babel.ls.fi.upm.es/events/wflp2010/
*********
colocated with
Principles of Programming Languages
POPL 2010
http://www.cse.psu.edu/popl/10/
********************************************************************
IMPORTANT DATES
Abstract Submission: November 18, 2009 **extended**
Full Paper Submission: November 25, 2009 **extended**
Acceptance Notification: December 20, 2009
Preliminary Proceedings: January 7, 2010
Workshop: January 17, 2010
SCOPE
The aim of the Workshop on Functional and (Constraint) Logic
Programming is to br
I've been generating Haskell using haskell-src-exts but the prettyprinter isn't
producing what I would expect.
I would expect parse . prettyPrint == id i.e. the AST should be unchanged if
you prettyprint it then parse it.
Here's an example generated expression:
App (App (Var (UnQual (Ident "pay"))) (Var (UnQual (Ident "tPD")))) (App (Var
(UnQual (Ident "a"))) (InfixApp (App (Var (UnQual (Ident "length"))) (Var
(UnQual (Ident "tOD")))) (QVarOp (UnQual (Symbol "+"))) (Lit (Int (-1)))))
Here's what prettyPrint produces:
pay tPD a length tOD + -1
Parsing it gives this (i.e. not the expression I first thought of):
InfixApp (App (App (App (App (Var (UnQual (Ident "pay"))) (Var (UnQual
(Ident "tPD")))) (Var (UnQual (Ident "a")))) (Var (UnQual (Ident "length"))))
(Var (UnQual (Ident "tOD")))) (QVarOp (UnQual (Symbol "+"))) (NegApp (Lit (Int
1)))
I would have expected the prettyprinter to produce this:
pay tPD (a (length tOD + -1))
Do I have to write my own prettyprinter? Do I have to put in explicit
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users< at >haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Hello everyone.
What about passing complex c-types (structures) to c-functions.
More detailed: I have an application in production which was written in
Delphi. IT has ability to create pluggable modules to it. Interface
realized by sending Win32Api messages to application.
function in haskell Win32
Graphics.Win32.sendMessage :: HWND -> WyidowMessage-> WPARAM -> LPARAM
-> IO RESULT
Application wants to get different data in WPARAM and LPARAM. Such as
window descriptor (HWND), string pointers and datastructer pointers.
The latter i don't know how to create.
I need anyones experience.
Why in a pattern match like
score (1 3) = 7
can I not have
sizeMax = 3
score (1 sizeMax) = 7
--
Regards,
Casey
Hello,
sure, your program could use a database with HDBC. But I'll guess
(since you love static typing so much) you dislike formulating queries
in strings and to check the positions of your ?-placeholders and to
convert your values with fromSql/toSql. Maybe you would prefer
for your select query a list of tuples instead of a list of lists,
because your beloved pattern matching needs always a dummy case.
And here [1] is hesql... it's a preprocessor, which rewrites SQL-Queries
as haskell functions. You put all your SQL-Queries
(for example
verifyLogin login' password' =
select1' Accountid, Login, RealName, Email from Account
where (password is null or password = md5(password')) and Lower(Login) = login'
and not Locked;
)
in a module (example/Account.hesql) and run
$ hesql example/Account.hesql dbname=example
which will write example/Account.hs, the real haskell module.
It will generate code for a haskell function with the type:
verifyLogin :: Stmts -> String -> Str
Hi, all,
Hackage shows a log failure for 'bindings-gsl':
Configuring bindings-gsl-0.1.1...
cabal-setup: At least the following dependencies are missing:
bindings-DSL ==1.0.*
But here is, at version 1.0.1, no building problems:
http://hackage.haskell.org/package/bindings-DSL
There's one thing special about bindings-DSL. It's
a package with a set of macros for hsc2hs, and contains
no Haskell code. Maybe this revealed some hidden error
in package dependency checking.
Thanks,
Maurício
Why can I run (runghc) some Haskell scripts but I cannot seem to
compile them?
e.g. http://www.haskell.org/all_about_monads/examples/example25.hs
I've changed the import listing to the following:
import IO
import System
import Monad
import Data.Maybe
import Data.List
import Data.Char (toLower)
import Control.Monad.State
import Control.Monad.Writer
The compiler errors are like the following:
N-Queens.o:fake:(.text+0x2fe): undefined reference to
`mtlzm1zi1zi0zi2_Controlzi
MonadziStateziLazzy_zdf9_closure'
N-Queens.o:fake:(.text+0x422): undefined reference to
`mtlzm1zi1zi0zi2_Controlzi
MonadziStateziLazzy_zdf7_closure'
N-Queens.o:fake:(.text+0x66f6): undefined reference to
`mtlzm1zi1zi0zi2_Controlz
iMonadziWriterziLazzy_zdf1_closure'
--
Regards,
Casey
Why can I run (runghc) some Haskell scripts but I cannot seem to
compile them?
e.g. http://www.haskell.org/all_about_monads/examples/example25.hs
I've changed the import listing to the following:
import IO
import System
import Monad
import Data.Maybe
import Data.List
import Data.Char (toLower)
import Control.Monad.State
import Control.Monad.Writer
--
Regards,
Casey
Does anyone know here how GHC links in object files from other
languages? I am getting a strange issue where it seems to be getting
the calling convention on Fortran calls wrong.
Specifically, on one computer (Gentoo Linux) I have with gcc and
gfortran v4.4 and ghc compiled using gcc v4.3, I have no problems at
all.
On another computer (a Mac) I have with gcc 4.0 and gfortran 4.4 and a
binary of ghc installed (as downloaded from haskell.org), I run into
problems. Specifically, I noticed that the first parameter seems to
get eaten when I declared a fortran routine as a function but not when
I declare it as a subroutine. So I went ahead and converted the
fortran routines into subroutines, but then I get another crash
elsewhere in the code where a module calls a LAPACK routine for
reasons unknown; I do not get this crash when running the same code
path but called using a Python wrapper that uses gcc + gfortran + f2py
rather than from my Haskell wrapper.
I thought that this might
Hi all,
Another, probably simple, question regarding cabalization.
Part of wxcore, the low level abstraction in wxHaskell, consists of
haskell modules which are generated automatically by parsing C headers
using another tool, wxdirect.
When trying to create an sdist package, we run into the problem that
because we export modules which are automatically generated, after a
'clean', they do not exist, so the sdist package generation fails.
We have tried using 'extra-tmp-files' to list the modules which are
autogenerated, but this isn't working.
Is this because we are generating the autogen modules in an autogen
directory, or is this approach likely to fail wherever we put the
autogenerated files? Our use case seems a reasonable one, as it could
reasonably exist for any project which relies on automatically
generated code.
Thanks for any suggestions.
Jeremy
Geoffg is playing a lawyer in declaring his interpretation of the GPL as the truth, lambasting the Free Software Foundation for not updating some old articles, accusing them of spreading FUD and declaring the iphone as a missed marketing opportunity.
He makes the mistake however of reading the GPLv2 as a definition of freedom, rather than an implementation of it. As this fine person pointed out last year, it’s no good being able to change software if you can’t run it. This is the freedom to change software and use it as toilet paper.
Fine, maybe you can run GPLv2 software on your iphone, but you can’t exercise all the freedoms which the FSF campaign for. According to them, GPLv2 software in closed DRM is exploiting a loophole which GPLv3 was in part written to close.
I can see it’s difficult for people to reconcile their love for free software and their love for Apple products, but maybe it’s best to be mindful of the fact that you’ve bought a computer that you can’t run software on without the permission of a large corporation.
There’s a lot of weirdness in the computer music community around this. RJDJ is a port of the free PureData language to the iphone. Many of those involved are free software developers, but have to give up all their rights to RJDJ, a venture capital funded company. RJDJ in turn license the code back to them under the GPLv3. This means they are free to change and run the code under open operating systems, but not on the iphone. This is weird, using the GPLv3 as a firewall to protect commercial interests on a closed platform, while exploiting the work of a free software community.
Just to clarify; I’m not saying that people shouldn’t run open source software on the iphone, particularly when a permissive license like MIT or BSD is involved. I’m just objecting to ignorance of the FSFs definition of software freedom, which I happen to subscribe to and which is incompatible with the iPhone. I find the RJDJ case weird, but while I know of at least some cognitive dissonance in the RJDJ team, I don’t know that any of the authors are otherwise unhappy with the situation.
UPDATE: Michael from RJDJ contacted me to point out something I got wrong. RJDJ don’t release their whole iphone port of PureData, just part of it — rjlib. This is indeed released under a GPLv3 though; if you want to contribute towards rjlib, you have to transfer your rights to RJDJ or fork the code.
BTW they are also releasing a rather nice looking cross-platform gui-less version of PureData under the LGPLGPLv3 and LGPLv3 called zengarden.
My favorite quote from Edsger Dijkstra comes from his Turing Award Lecture, The Humble Programmer:"In their capacity as a tool, computers will be but a ripple on the surface of our culture. In their capacity as intellectual challenge, they are without precedent in the cultural history of mankind."I've just listened to the best defense of this thesis that I've ever heard, courtesy of Bob Constable. A paper on the same topic of his is linked above.
Other relevant papers on the same subject are Alan Bundy's
Computational Thinking is Pervasive and Jeanette Wing's
Computational Thinking.
I was also fortunate to see Jeanette Wing address this topic in her recent OOPSLA keynote. In the question period, I mentioned Dijkstra's quote, and also my interpretation of it. I believe that in his usual style, Dijkstra was exaggerating. I think there are two precedents: the invention of writing and the discovery of mathematics. Computing give us, with prose and mathematics, a third way to describe our discoveries.
Please add to the documentation for :set prompt:
If you enclose \i{prompt} in quotes, you can use Haskell
syntax for String literals.
Actually, :set prompt is nearly useless without quotes, because
GHCi strips off trailing spaces from commands. We should either
add a space at the end of a prompt entered without quotes,
or just require quotes. Or at least change the help text
to be:
:set prompt \"<prompt>\" set the prompt used in GHCi\n
so that people will know the right thing to do. Perhaps add
a few more words of explanation to the docs in section 2.7
once we decide which of these to do.
The :run command is not documented in section 2.7 - the
only mention of it is buried within the documentation for
the :main command. It is also not mentioned in helpText.
Thanks,
Yitz