Re: getWorkingDirectory/changeWorkingDirectory

2013-12-04 Thread Christopher Done
How does it differ to getCurrentDirectory/setCurrentDirectory in
System.Directory?


On 4 December 2013 14:38, Benjamin Franksen 
benjamin.frank...@helmholtz-berlin.de wrote:

 Module System.Posix.Directory of the unix package defines

   getWorkingDirectory :: IO FilePath
   changeWorkingDirectory :: FilePath - IO ()

 I believe the functionality is quite portable and not limited to unix-like
 systems. I know that e.g. Windows has chdir and getcwd. Module Filesystem
 of
 the system-fileio package has

   getWorkingDirectory :: IO FilePath
   setWorkingDirectory :: FilePath - IO ()

 I propose to add these functions to System.Environmant or maybe
 System.Directory.

 Rationale:

 (1) This is standard functionality that should at least be in the Haskell
 Platform, if not in the standard libraries.

 (2) I would like to avoid depending on an extra package just to have these
 two very basic functions available in a OS independent way.

 (3) system-fileio.Filesystem does not seem to be the right place for
 this.

 The last point may be arguable, but the first two are plain common sense
 IMO.

 Cheers
 Ben
 --
 Make it so they have to reboot after every typo. ? Scott Adams


 ___
 Haskell-prime mailing list
 Haskell-prime@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-prime

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: Anonymous records. A solution to the problems of record-system.

2013-10-14 Thread Christopher Done
So basically, TRex?

On 14 October 2013 18:13, Nikita Volkov nikita.y.vol...@gmail.com wrote:
 Anonymous records. A solution to the problems of record-system.

 The current record system is notorious for three major flaws:

 It does not solve the namespacing problem. I.e., you cannot have two records
 sharing field names in a single module. E.g., the following won't compile:

 data A = A { field :: String }
 data B = B { field :: String }

 It's partial. The following code will result in a runtime error:

 data A = A1 { field1 :: String } | A2 { field2 :: String }

 main = print $ field1 $ A2 abc

 It does not allow you to use the same field name for different types across
 constructors:

 data A = A1 { field :: String } | A2 { field :: Int }

 This proposal approaches all the problems above and also a fourth one, which
 is unrelated to the current record system: it allows one to avoid
 declaration of intermediate types (see details below).

 Gentlemen, I want you to meet,

 Anonymous Records

 When a record-syntax is used in Haskell it's almost always a
 single-constructor ADT. A question rises then: why use ADT when you don't
 need its main feature (i.e., the multiple constructors)? This main feature
 is actually the root of the second and the third problem of record-syntax
 from the list above. In such situations one doesn't actually need ADT, but
 something more like a tuple with ability to access its items by name. E.g.:

 f :: (a :: Int, b :: String) - String
 f rec = rec.b ++ show rec.a

 application:

 f (a = 123, b = abc)

 So now you think Okay, but how about naming it?. Well, not a problem at
 all - use the existingtype-construct:

 type TheRecord = (a :: Int, b :: String)

 Now, about the avoidance of intermediate types:

 type Person = (name :: String, phone :: (country :: Int, area :: Int, number
 :: Int))

 See? No need to declare separate types for inner values. But, of course, if
 you need, you still can:

 type Phone = (country :: Int, area :: Int, number :: Int)
 type Person = (name :: String, phone :: Phone)

 We can nicely access the deeply nested fields, e.g.:

 personCountryCode :: Person - Int
 personCountryCode person = person.phone.country

 Okay. What about the type ambiguity? E.g., in the following the Person is
 actually the same type asCompany:

 type Person = (name :: String, phone :: Phone)
 type Company = (name :: String, phone :: Phone)

 Easily solvable with a help of newtype:

 newtype Person = Person (name :: String, phone :: Phone)
 newtype Company = Company (name :: String, phone :: Phone)

 What about ADTs? Again, easy:

 data Product = Tea (brand :: Company)
  | Milk (brand :: Company, fatness :: Float)

 Now, the beautiful fact:

 This solution does not conflict with any existing feature of Haskell! As the
 examples show, it easily fits into the language as an extension. It can
 peacefully coexist with the existing record system of ADTs. Hence a complete
 backwards compatibility with old codebase. There's also a potential for many
 other additional features.

 Links

 Source of this proposal.


 ___
 Haskell-prime mailing list
 Haskell-prime@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-prime

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: [Haskell-cafe] Store type-class polymorphic values generically

2013-10-11 Thread Christopher Done
 Wait... what do you mean Core cannot generate new names to be exported.

I meant if I add a new name in the Core transformation, that doesn't
change the module's export list as seen by everything outside that
module. Which makes sense, it just means I have to change my approach.

 Maybe you mean that you want your plugin to transform

 module M( f ) where
   f = e
 into
 module M( f_ ) where
   f_ = ...f...
   f = e


No, I meant that

module M(f) where f = e

should be come

module M (f, f_) where f = readRefOf f_; f_ = makeSomeRef e

In other words, the API is only changed in that an additional binding
has been exported for each top-level definition to which you can write
(only of the correct type) a new definition. This is something that
you could do manually, write it by hand, but I want it automatic for
any module I load into GHCi!

 That seems pretty drastic, because now the programmer's API for the module 
 has changed.  Are you sure you don't want to do this

 module M( f ) wehre
   f_ = e
   f = ...f_...

 by renaming the existing f with some local name.

Sure -- but both need to be exported otherwise you can't update the
definition of `f` by writing to `f_`. With both, all other modules
(and the module itself) just refer to `f' as they normally would, it's
just that `f` gets its definition from some kind of mutable cell.

I discussed with Daniel Peebles an approach to this with the new kind
polymorphic Typeable landing in GHC 7.8, in which I could safely write
functions in and out with Fun from HList:
http://code.haskell.org/~aavogt/HList/docs/HList/Data-HList-FakePrelude.html#t:Fun
Hypothetically I can use bog standard Typeable deriving for that type,
and actually use Data.Dynamic to store all functions, using
fromDynamic :: a - Maybe safe coercion. Don't get me wrong, I don't
want the plugin to break any APIs or do anything unsafe (beyond using
unsafePerformIO to hold a Map Name Dynamic or so), I just want
in-place update of IO-ish actions. I'm compiling GHC from Git at the
moment to see if this approach is worthwhile.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Compiling arbitrary Haskell code

2013-10-11 Thread Christopher Done
Is there a definitive list of things in GHC that are unsafe to
_compile_ if I were to take an arbitrary module and compile it?

E.g. off the top of my head, things that might be dangerous:

* TemplateHaskell/QuasiQuotes -- obviously
* Are rules safe?
* #includes — I presume there's some security risk with including any old file?
* FFI -- speaks for itself

I'm interested in the idea of compiling Haskell code on lpaste.org,
for core, rule firings, maybe even Th expansion, etc. When sandboxing
code that I'm running, it's really easy if I whitelist what code is
available (parsing with HSE, whitelisting imports, extensions). The
problem of infinite loops or too much allocation is fairly
straight-forwardly solved by similar techniques applied in mueval.

SafeHaskell helps a lot here, but suppose that I want to also allow
TemplateHaskell, GeneralizedNewtypeDeriving and stuff like that,
because a lot of real code uses those. They only seem to be restricted
to prevent cheeky messing with APIs in ways the authors of the APIs
didn't want -- but that shouldn't necessarily be a security—in terms
of my system—problem, should it? Ideally I'd very strictly whitelist
which modules are allowed to be used (e.g. a version of TH that
doesn't have runIO), and extensions, and then compile any code that
uses them.

I'd rather not have to setup a VM just to compile Haskell code safely.
I'm willing to put some time in to investigate it, but if there's
already previous work done for this, I'd appreciate any links.

At the end of the day, there's always just supporting a subset of
Haskell using SafeHaskell. I'm just curious about the more general
case, for use-cases similar to my own.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Compiling arbitrary Haskell code

2013-10-11 Thread Christopher Done
On 12 October 2013 01:19, Johan Tibell johan.tib...@gmail.com wrote:
 Whatever guarantees GHC offers (e.g. using Safe Haskell), I would always run
 things like these in a sandbox. It's much better for security to dissallow
 everything and then whitelist some things (e.g. let the sandbox communicate
 with the rest of the world in some limited way) than the other way around.

Yeah, the impression I'm getting is that compiling pretty much
anything other than simple expressions (a la lambdabot) is that all
bets are off.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: carriage returns on Windows from quasi-quotes

2013-10-05 Thread Christopher Done
They're on Windows?

On 5 October 2013 01:36, Greg Weber g...@gregweber.info wrote:
 A Windows user rerported using Data.Text.IO.writeFile to write out
 quasi-quoted text.

 writeFile automatically translates '\r' to \r\n, so the user ended up
 writing out \r\r\n to a file.

 Haskell seems to be adopting the policy or removing '\r' from Haskell land.
 Is there any reason why quasi-quotes should not automatically strip carriage
 returns?

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Store type-class polymorphic values generically

2013-10-04 Thread Christopher Done
On 4 October 2013 10:56, Heinrich Apfelmus apfel...@quantentunnel.de wrote:
 In particular, the  Locker  stores arbitrary values like  Dynamic , except
 that values are extracted and removed with the help of a  Key . This gets
 rid of the  Typeable  constraint.

lock :: Key a - a - Locker

I can't pass anything with class constraints to that.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Christopher Done
On 3 October 2013 10:57, Roman Cheplyaka r...@ro-che.info wrote:
 An interesting use case is my time-lens library.
 http://hackage.haskell.org/package/time-lens-0.3/docs/Data-Time-Lens.html

 You can do things like

modL minutes (+5) (TimeOfDay 16 57 13)
   17:02:13

 But one has to be somewhat lenient about the lens laws here.

Relatedly the thyme package (really fast time implementation) provides
lenses for all its data types:
http://hackage.haskell.org/package/thyme
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Store type-class polymorphic values generically

2013-10-03 Thread Christopher Done
It's very easy to state this problem without enough details and mislead
people into providing a solution for a different problem, so I'll try to
include all the information and use-case. I need a function that can
store a value in a concrete opaque type. I know the type of the value
when I store it, and I know the type of the value when I extract it,
insofar as I know the type inclusive of a class constraint context. But
the container must store many different things at once. Given that I
know the type of the thing when I store it and when I extract it, there
ought to be a “safe’ way to do this, in the same way that Data.Dynamic
is “safe”.

The use-case is I want to store a table of IO-like actions in an opaque
like [(Name,Dynamic)] and I write into it statically, e.g. in GHCi.

The reason is due to this approach:

go_ref = newIORef go_

go_ = putStrLn Hello, World!

go = do
  go' - liftIO $ readIORef go_ref
  go'

main = forkIO $ forever $ go

then in GHCi I writeIORef go_ (putStrLn What's up?)

then go will now start printing What's up? This works now, I can do
this presently. However, I want to write this as a core-to-core
translation as a ghc-plugin. I want the definition go = putStrLn Hello
World! to be translated to what I wrote above. Core cannot generate new
names to be exported from a module, so go_ is now gone. So how does the
`go' function read and write the IORef? With a table:

table = unsafePerformIO $ newIORef [(go,Dynamic go_ref)]

Hurrah! I can now put table in some module like DynamicUpdate.table and
then read/write to it from Core in the generated definition of
go. Done. But how do I update it from the GHCi REPL? What follows is
where I'm stuck.

So with Data.Dynamic, I have:

toDyn :: Typeable a = a - Dynamic

With toDyn I can store concrete values and functions and then extract
them:

λ fmap ($ 12) (fromDynamic (toDyn ((*2) :: Int - Int)) :: Maybe (Int - Int))
Just 24

But the problem with toDyn is that it can only store concrete values due
to the Typeable constraint. So then I turn to existentials and
unsafeCoerce:

λ data Anything = forall a. Anything a
λ let x = Anything id
λ case x of Anything (unsafeCoerce - (id' :: Int - Int)) - id' 123
123

Great, I was able to store a value which contained non-concrete
types. But now consider the case of a value with type-class
polymorphic type in it:

y = Anything (print :: Show a = a - IO ())

Which cannot be type checked, because the Show instance is
ambiguous. So you might propose to use rank-N types, like this:

data Anything = Anything (Show a = a - IO ())

Now I can store print in there happily. But now the type is not
Anything, it's not generic anymore. Maybe I want to store `print', maybe
I want to store `readLn'. Dead end. I don't want to have to generate
existential wrappers for all functions I might possibly want to store.

The support of Constraints in this page
http://blog.omega-prime.co.uk/?p=127 makes me think that it's still
possible. It would be cool to somehow store a tuple of the dictionary of
the constraint and the value itself and then I'd later be able to
extract it. But I'm finding it difficult developing anything even
simple.

Any ideas/help appreciated!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HTML framework for web-ui

2013-10-01 Thread Christopher Done
Threepenny is now ready for public consumption,  FIW.

On 23 May 2013 08:34, Vlatko Basic vlatko.ba...@gmail.com wrote:
 Hi Heinrich,

 Looks simple and interesting. I browsed the git, but not much docs yet.
 Just examples, or have I looked at wrong places?


 I see that API is still under heavy design. When do you expect the API might
 stabilize?

 (BTW, examples in Readme do not work.)

 vlatko



 Vlatko Basic wrote:

 I'd like to start using web pages as the UI for apps. I found out for
 yesod,
 snapp and happstack as the candidates.
 Would you recommend any of them as better for app ui (not classical web
 pages)? Or maybe another one?


 Not sure if that's what you are looking for, but with help from Daniel
 Austin,
 I'm currently working on a small GUI library that use the web browser to
 display
 GUI elements.

https://github.com/HeinrichApfelmus/threepenny-gui

 It's derived from Chris Done's former Ji project.

 It's not quite ready for public consumption yet, but any feedback is
 appreciated, of course.


 Best regards,
 Heinrich Apfelmus

 --
 http://apfelmus.nfshost.com


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] inv f g = f . g . f

2013-08-17 Thread Christopher Done
Anyone ever needed this? Me and John Wiegley were discussing a decent
name for it, John suggested inv as in involution. E.g.

inv reverse (take 10)
inv reverse (dropWhile isDigit)
trim = inv reverse (dropWhile isSpace) . dropWhile isSpace

That seems to be the only use-case I've ever come across.

There's also this one:

co f g = f g . g

which means you can write

trim = co (inv reverse) (dropWhile isSpace)

but that's optimizing an ever rarer use-case.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [Haskell] Spam on the Haskell wiki

2013-08-03 Thread Christopher Done
Anyone ran SpamAssassin on the offending content created by the spammers?
I've been using it on hpaste and it's been very effective at cutting out
the crap.


On 4 August 2012 19:15, Gwern Branwen gwe...@gmail.com wrote:

 On Fri, Aug 3, 2012 at 10:34 PM, damodar kulkarni
 kdamodar2...@gmail.com wrote:
  So, another doubt, if detecting spam is trivial, then why not just send
 the
  detected spam to trash directly without any human inspection?
  This may mean some trouble for the posters due to false positives; but
 the
  moderator's job can be reduced to some extent.

 Which is pretty much what this whole thread is about: asking that the
 sysadmins Do Something about this trivial yet overwhelming spam.

 --
 gwern
 http://www.gwern.net

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: How to fix DatatypeContexts?

2013-07-18 Thread Christopher Done
Why not this?

data Pair = forall a. Eq a = Pair {x::a, y::a}
equal :: Pair - Bool
equal (Pair x y) = x == y
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: How to fix DatatypeContexts?

2013-07-18 Thread Christopher Done
Hm, also, with equality constraints you can make the type parametrized, too:

data Pair a' = forall a. (a ~ a', Eq a) = Pair {x::a, y::a}
equal :: Pair a - Bool
equal (Pair x y) = x == y


On 18 July 2013 13:00, Christopher Done chrisd...@gmail.com wrote:

 Why not this?

 data Pair = forall a. Eq a = Pair {x::a, y::a}
 equal :: Pair - Bool
 equal (Pair x y) = x == y


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: How to fix DatatypeContexts?

2013-07-18 Thread Christopher Done
Good point, classic use-case for GADTs.


On 18 July 2013 13:11, Sjoerd Visscher sjo...@w3future.com wrote:

 I'd use GADT syntax for this:

 {-# LANGUAGE GADTs #-}
 data Pair a where Pair :: Eq a = {x::a, y::a} - Pair a

 Sjoerd

 On Jul 18, 2013, at 1:05 PM, Christopher Done chrisd...@gmail.com wrote:

  Hm, also, with equality constraints you can make the type parametrized,
 too:
 
  data Pair a' = forall a. (a ~ a', Eq a) = Pair {x::a, y::a}
  equal :: Pair a - Bool
  equal (Pair x y) = x == y
 
 
  On 18 July 2013 13:00, Christopher Done chrisd...@gmail.com wrote:
  Why not this?
 
  data Pair = forall a. Eq a = Pair {x::a, y::a}
  equal :: Pair - Bool
  equal (Pair x y) = x == y
 
 
  ___
  Glasgow-haskell-users mailing list
  Glasgow-haskell-users@haskell.org
  http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Christopher Done
JHC compiles to C and last time I tried this it looked very much like the
original C version:
http://www.reddit.com/r/haskell/comments/1bcru7/damn_lies_and_haskell_performance/c9689a3

This is the same thing. Compile with --tdir=/tmp/ajhc and then cat
/tmp/ajhc/main_code.c. Output should be like this:

static uint32_t A_STD
fW$__fMain_1__ack(gc_t gc,uint32_t v105553376,uint32_t v61835120)
{
if (0 == v105553376) {
return 1 + v61835120;
} else {
uint32_t v16;
uint32_t v22;
struct tup1 x2;
if (0 == v61835120) {
uint32_t v228308038 = (v105553376 - 1);
x2.t0 = v228308038;
x2.t1 = 1;
} else {
uint32_t v110947990;
uint32_t v215884490 = (v61835120 - 1);
uint32_t v62470112 = (v105553376 - 1);
v110947990 = fW$__fMain_1__ack(gc,v105553376,v215884490);
x2.t0 = v62470112;
x2.t1 = v110947990;
}
v22 = x2.t0;
v16 = x2.t1;
return fW$__fMain_1__ack(gc,v22,v16);
}
}

And it's as fast as C on my machine:

chris@midnight:~/Projects/me/ajhc$ time ./ack
65533

real 0m2.134s
user 0m2.124s
sys 0m0.000s
chris@midnight:~/Projects/me/ajhc$ gcc -O3 ack.c -o ack-c
ack.c: In function ‘main’:
ack.c:8:3: warning: incompatible implicit declaration of built-in function
‘printf’ [enabled by default]
chris@midnight:~/Projects/me/ajhc$ time ./ack-c
65533

real 0m2.255s
user 0m2.248s
sys 0m0.000s
chris@midnight:~/Projects/me/ajhc$




On 20 April 2013 10:55, Mikhail Glushenkov the.dead.shall.r...@gmail.comwrote:

 Hi all,

 This came up on StackOverflow [1]. When compiled with GHC (7.4.2 
 7.6.2), this simple program:

 main = print $ ack 4 1
   where ack :: Int - Int - Int
 ack 0 n = n+1
 ack m 0 = ack (m-1) 1
 ack m n = ack (m-1) (ack m (n-1))

 consumes all available memory on my machine and slows down to a crawl.
 However, when compiled with JHC it runs in constant space and is about
 as fast as the straightforward Ocaml version (see the SO question for
 benchmark numbers).

 I was able to fix the space leak by using CPS-conversion, but the
 CPS-converted version is still about 10 times slower than the naive
 version compiled with JHC.

 I looked both at the Core and Cmm, but couldn't find anything
 obviously wrong with the generated code - 'ack' is compiled to a
 simple loop of type 'Int# - Int# - Int#'. What's more frustrating is
 that running the program with +RTS -hc makes the space leak
 mysteriously vanish.

 Can someone please explain where the space leak comes from and if it's
 possible to further improve the runtime of this program with GHC?
 Apparently it's somehow connected to the stack management strategy,
 since running the program with a larger stack chunk size (+RTS -kc1M)
 makes the space leak go away. Interestingly, choosing smaller stack
 chunk sizes (256K, 512K) causes it to die with an OOM exception:

 $ time ./Test +RTS -kc256K
 Test: out of memory (requested 2097152 bytes)


 [1]
 http://stackoverflow.com/questions/16115815/ackermann-very-inefficient-with-haskell-ghc/16116074#16116074

 --
 ()  ascii ribbon campaign - against html e-mail
 /\  www.asciiribbon.org   - against proprietary attachments

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell-cafe] Idea: Source maps for GHC's -pgmF

2013-03-29 Thread Christopher Done
Here's an idea. For the -pgmF flag, because compile errors become
really obscure and line numbers rendered unhelpful, why don't we use
source maps as recently done for JavaScript in the browser?

Info:

https://wiki.mozilla.org/DevTools/Features/SourceMap

https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit

Here is an example I experimented with the Fay (Haskell→JS compiler):

https://dl.dropbox.com/u/62227452/Screenshots/Screenshot%20from%202012-09-26%2000%3A48%3A01.png

This shows the original source code and a backtrace of an exception
thrown in JavaScript.

We can use Mozilla/Google's format:
http://hackage.haskell.org/package/sourcemap Though it's kind of an
obscure format because it's aimed at being small, but if it's already
been done, why not? Otherwise a simple JSON format is probably
sufficient.

It could be used both in GHC's compilation, pattern match exceptions,
and even in debugger stepping, if desired. Provided with, e.g. -pgmFsm
foo.map. This would make things like the XML mode or other syntactical
extensions feel quite natural and not awkward in GHC's error messages.

What say you, -pgmF users and GHC hackers?

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Associated types for number coercion

2013-03-19 Thread Christopher Done
(But I get annoyed about having to convert between five string types
(String, Text, lazy Text, ByteString, lazy ByteString), so maybe I'm
just generally more bothered by the whole “not being able to just
write the program” than others.)

On 20 March 2013 00:22, Christopher Done chrisd...@gmail.com wrote:
 On 20 March 2013 00:05, Johan Tibell johan.tib...@gmail.com wrote:
 I prefer the current way (which is interestingly what Go chose as well).
 With implicit casts it's easy to shoot yourself in the foot e.g. when doing
 bit-twiddling.

 I don't think it's an either-or case, though, is it? I would use the
 magic implicitness when I don't care, like all the times I have to
 write fromIntegral because I have an Int here and an Integer there,
 and now I want to use them in a Double calculation, so my code ends up
 littered with fromIntegral, or fi. Elsewhere in the world,
 programmers just write arithmetic. When I would care, like in
 bit-twiddling, I would use the explicit conversions.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Some aggregation of Haskell content

2013-03-18 Thread Christopher Done
As a follow up, here's an implementation: http://haskellnews.org/

More info here:
http://www.reddit.com/r/haskell/comments/1ahgrn/haskell_news/c8xfp9s

On 10 February 2013 18:22, Daniel Díaz Casanueva dhelta.d...@gmail.com wrote:
 I'm totally with this. Also, it is exhausting to check in so many places to
 see what's going on. I have been looking for this for a while.


 On Sun, Feb 10, 2013 at 10:41 AM, Christopher Done chrisd...@gmail.com
 wrote:

 Is there a page somewhere that aggregates all of Haskell's community
 output into one place?

 As a consumer of Haskell content I neither have the time nor inclination
 to follow haskell-cafe and other various mailing lists, the reddits, the
 google+ community, planet haskell, hackage releases, twitter, youtube and
 whatever other submission places I haven't heard of.

 I made this page for the Lojban community some years ago:
 http://jbotcan.org/hub/

 Lojban doesn't have much community activity (tho this doesn't include
 mailing list posts), but Haskell's community is much larger and more active,
 it would be far more useful.

 I may write such a page for Haskell content, if not for the community then
 at least for myself, as I keep missing out on cool things because I didn't
 happen to check out that particular medium of exchange. For example, even
 this message will be lost on a thousand people who doesn't follow the
 mailing list but maybe follows G+ or reddit.

 Kind of like a Haskell Weekly news, except more like Haskell news right
 now or in some adjustable time frame. And the option to toggle between
 chronological order or categorized.

 Ciao!

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




 --
 E-mail sent by Daniel Díaz Casanueva

 let f x = x in x

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ticking time bomb

2013-02-01 Thread Christopher Done
Hey dude, it looks like we made the same project yesterday:

http://www.reddit.com/r/haskell/comments/17njda/proposal_a_trivial_cabal_package_signing_utility/

Yours is nice as it doesn't depend on GPG. Although that could be a
nice thing because GPG manages keys. Dunno.

Another diff is that mine puts the .sig inside the .tar.gz, yours puts
it separate.

=)

On 31 January 2013 09:11, Vincent Hanquez t...@snarc.org wrote:
 On 01/30/2013 07:27 PM, Edward Z. Yang wrote:

 https://status.heroku.com/incidents/489

 Unsigned Hackage packages are a ticking time bomb.

 I agree this is terrible, I've started working on this, but this is quite a
 bit of work and other priorities always pop up.

 https://github.com/vincenthz/cabal
 https://github.com/vincenthz/cabal-signature

 My current implementation generate a manifest during sdist'ing in cabal, and
 have cabal-signature called by cabal on the manifest to create a
 manifest.sign.

 The main issue i'm facing is how to create a Web of Trust for doing all the
 public verification bits.

 --
 Vincent


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: How to get started with a new backend?

2013-01-27 Thread Christopher Done
 The trac claims that ghc can compile itself to C so that only standard gnu C 
 tools are needed to build an unregistered compiler.

Wait, it can? Where's that?

On 28 January 2013 02:15, Jason Dagit dag...@gmail.com wrote:
 I would like to explore making a backend for .NET. I've done a lot of
 background reading about previous .NET and JVM attempts for Haskell. It
 seems like several folks have made significant progress in the past and,
 with the exception of UHC, I can't find any code around the internet from
 the previous efforts. I realize that in total it's a huge undertaking and
 codegen is only one of several significant hurdles to success.

 I would like to get a very, very, very simple translation working inside
 GHC. If all I can compile and run is fibonacci, then I would be quite happy.
 For my first attempt, proof of concept is sufficient.

 I found a lot of good documentation on the ghc trac for how the compilation
 phases work and what happens in the different parts of the backend. The
 documentation is excellent, especially compared to other compilers I've
 looked at.

 When I started looking at how to write the code, I started to wonder about
 the least effort path to getting something (anything?) working. Here are
 some questions:
   * Haskell.NET seems to be dead. Does anyone know where their code went?
   * Did lambdavm also disappear? (JVM I know, but close enough to be useful)
   * Would it make sense to copymodify the -fvia-C backend to generate C#?
 The trac claims that ghc can compile itself to C so that only standard gnu C
 tools are needed to build an unregistered compiler. Could I use this trick
 to translate programs to C#?
   * What stage in the pipeline should I translate from? Core? STG? Cmm?
   * Which directories/source files should I look at to get familiar with the
 code gen? I've heard the LLVM codegen is relatively simple.
   * Any other advice?

 Thank you in advance!
 Jason

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] HaskellDB-HDBC-PostgreSQL installation problem

2013-01-09 Thread Christopher Done
Tricky. For what it's worth, if you can't figure this out in the end,
you could perhaps use my pgsql-simple which is implemented in pure
haskell: https://github.com/chrisdone/pgsql-simple It's been in use on
hpaste.org for about 2 years.

On 9 January 2013 14:44, Johannes.Reiher johannes.rei...@fh-zwickau.de wrote:
 Hello Community,

 I have a problem installing the HaskellDB-HDBC-PostgreSQL package with cabal.
 I'm using Haskell Platform in Windows and I tried to install this package, 
 but there was the error could not find pq library. So I tried to install 
 libpq wich includes pq but there was another error: this package needs a 
 unix installation.
 Is there any way to install pq on Windows or get the 
 HaskellDB-HDBC-PostgreSQL in another way?

 Thanks for your advice

 Johannes Reiher

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times.

2013-01-06 Thread Christopher Done
A similar use-case and same solution with IORefs:
http://hpaste.org/diff/80055/80058 Guess which one threw a
stackoverflow and which one ran indefinitely when given a few hundred
million lines of input.

On 7 January 2013 07:35, Albert Y. C. Lai tre...@vex.net wrote:
 On 13-01-07 12:12 AM, Thomas Hartman wrote:

 I have a space leak in a function that increments a number inside
 IORef or STRef (either lazy or strict).


 IORef and STRef operations do not automatically evaluate contents.
 writeIORef r (x + 1) simply stores a pointer to the expression (thunk) x
 + 1 into the mutable cell. readIORef just reports back a pointer.
 modifyIORef just calls readIORef and writeIORef. No evaluation throughout.

 modifyIORef incr where

 incr !x = x + 1

 does not make a difference because it is just writeIORef r (incr x)),
 i.e., simply stores a pointer to the expression (thunk) incr x into the
 mutable cell. The whole process doesn't even care about how many bangs are
 in incr.

 (It is illuminating to consider how const True (incr x) does not evaluate
 x. A pointer to True and a pointer to incr x are passed to const, then
 const throws away the latter without even looking. See also const True
 undefined. One day, you will thank writeIORef r undefined; I certainly
 did.)

 Same for both Data.STRef.Strict and Data.STRef.Lazy. They do not mean what
 you think. Here is what they mean:

 Data.STRef.Strict means what Control.Monad.ST.Strict means
 Data.STRef.Lazy means what Control.Monad.ST.Lazy means

 Control.Monad.ST.Strict means that the following hangs:

 x = head (runST list) where
   list :: ST s [Bool]
   list = do {xs - list; return (True : xs)}

 Control.Monad.ST.Lazy means that the above terminates and gives the answer
 True.

 (Up to this point, same story for Control.Monad.State.Strict and
 Control.Monad.State.Lazy.)

 I still have not understood Control.Monad.ST.Lazy enough to articulate its
 full semantics, but I have some more examples to show what it does:

 http://hpaste.org/63925

 By understanding what Lazy in Control.Monad.ST.Lazy means, you also see
 what Strict does *not* mean.

 In IO or Control.Monad.ST.Strict, use

   let y = x+1 in y `seq` write[IO/ST]Ref r y

 to expedite the evaluation of x+1. Using the same idea, you may write your
 own modify[IO/ST]RefNOW to evaluate while updating.


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Documentation operator

2012-12-26 Thread Christopher Done
Hello chums,

I've been playing around with an idea, something that has obvious pros
and cons, but I'll sell it to you because there might be some positive
ideas out of it. Consider the following operator:

{-# LANGUAGE TypeOperators, DataKinds, KindSignatures #-}

module Docs where

import GHC.TypeLits

type a ? (sym :: Symbol) = a

First I'll describe how I'd want to use this and then what I think
are the advantages and disadvantages.

I call this (?) operator “the documentation operator”, to be used for:

* Things that either don't belong or can't be encoded in the type
  system, or for things need to be in English.
* Things that cannot be encoded in Haddock.

The simple case of ye olde days:

-- | Lorem ipsum dolor sit amet. Suspendisse lacinia nibh et
--   leo. Aenean auctor aliquam dapibus.
loremIpsum :: Int - Int - String

Which has since been somewhat evolved into:

loremIpsum :: Int-- ^ Lorem ipsum dolor sit amet.
   - Int-- ^ Suspendisse lacinia nibh et leo.
   - String -- ^ Aenean auctor aliquam dapibus.

But could now be written:

loremIpsum :: Int? Lorem ipsum dolor sit amet.
   - Int? Suspendisse lacinia nibh et leo.
   - String ? Aenean auctor aliquam dapibus.

Here is a contrived case I'll use later on:

data Person = Person

describeAge :: Int ? an age - String ? description of their
elderliness
describeAge n = undefined

personAge :: Person ? a person - Int ? their age
personAge = undefined

One could also encode previously informal specifications more formally,
so that

-- | The action 'hFlush' @hdl@ causes any items buffered for output
-- in handle @hdl@ to be sent immediately to the operating system.
--
-- This operation may fail with:
--
--  * 'isFullError' if the device is full;
--
--  * 'isPermissionError' if a system resource limit would be exceeded.
--It is unspecified whether the characters in the buffer are
discarded
--or retained under these circumstances.
hFlush :: Handle - IO ()
hFlush handle = wantWritableHandle hFlush handle flushWriteBuffer

with

type Throws ex (docs :: Symbol) = docs

could now be written

hFlush :: Handle ? flush buffered items for output on this handle -
IO ()
  ? Throws IsFullError if the device is full
  ? Throws IsPermissionError
   if a system resource limit would be exceeded. It is \
   \unspecified whether the characters in the  buffer are \
   \discarded or retained under these circumstances.
hFlush handle = wantWritableHandle hFlush handle flushWriteBuffer

With this in place, in GHCi you get documentation lookup for free:

 :t hFlush
hFlush
  :: (Handle ? flush buffered items for output on this handle)
 - (IO () ? Throws IsFullError if the device is full)
? Throws
IsPermissionError
if a system resource limit would be exceeded. It is
unspecified
 whether the characters in the  buffer are discarded or
retained
 under these circumstances.

And you get function composition, or “documentation composition” for free:

 :t describeAge . personAge
describeAge . personAge
  :: (Person ? a person)
 - String ? description of their elderliness

We could have a :td command to print it with docs, and otherwise docs
could be stripped out trivially by removing the ? annotations:

 :t describeAge . personAge
describeAge . personAge
  :: Person - String
 :td describeAge . personAge
describeAge . personAge
  :: (Person ? a person)
 - String ? description of their elderliness

You could even add clever printing of such “documentation types”:

 :t hFlush
hFlush
  :: Handle — flush buffered items for output on this handle
  - IO ()
Throws IsFullError if the device is full
Throws IsPermissionError if a system resource limit would be
  exceeded. It is unspecified whether the characters in the buffer
  are discarded or retained under these circumstances.

Unfortunately it doesn't work with monadic composition, of course.

So here are the advantages:

* You get parsing for free (and anyone using haskell-src-exts).
* You get checking for free (i.e. GHC can check that IsFullError exists
  for you).
* You get a continuity of documentation through your operations
  including composition.
* You can extend the documentation language easily by just defining
  some types (like the Throws I used above). SeeMore, Author,
  Deprecated, etc. Whatever.
* You can print out some helpful looking documentation in GHCi based on
  these simple types.
* There's no longer this informal it might throw this exception kind
  of pros we're forced to write.
* It could also be used for annotations other than pure documentation,
  including testing. E.g. add a Testable property and then your test

[Haskell-cafe] ANNOUNCE: haskell-docs - Given a module name and a name, it will find and display the documentation of that name.

2012-12-26 Thread Christopher Done
Ahoy hoy,

Just thought I'd announce a tool I whipped up these evening to take a
module name and a name and output the installed Haddock documentation
for it. Examples with my GHCi session:

λ :doc Data.List.Split split
Split a list according to the given splitting strategy. This is
 how to run a Splitter that has been built using the other
 combinators.
λ :doc Control.Concurrent.MVar swapMVar
Take a value from an MVar, put a new value into the MVar and
 return the value taken. This function is atomic only if there are
 no other producers for this MVar.
λ :doc Data.List sort
Ambiguous module, belongs to more than one package: base haskell2010-1.1.0.1
Continuing anyway...
Package: base
The sort function implements a stable sorting algorithm.
 It is a special case of sortBy, which allows the programmer to supply
 their own comparison function.

Please have a play with it, the package is at:
http://hackage.haskell.org/package/haskell-docs It has installation
instructions. Feel free to share any issues that you have, either
here, or on the Github page: https://github.com/chrisdone/haskell-docs
There are some issues to do with versioning that I'm not sure how to
solve in a standard way.

The obvious next step is to have a -package-conf flag so that it can
be used with cabal-dev.

The wizards on #haskell are currently thinking of a way to avoid
having to write the module name and just use what's in scope.

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: UHC-like JavaScript backend in GHC

2012-11-13 Thread Christopher Done
On 13 November 2012 16:33, J. Stutterheim j.stutterh...@me.com wrote:
 Yes, I did check out other work that's been done in this area, albeit only 
 briefly. Unless I've overlooked it (which is very much possible), none of the 
 other solutions (except Fay) support an FFI that bridges the gap between JS's 
 OO and the functional world, like our JS-like language in the foreign 
 imports. In real-life situations, where you want to get rid of writing JS 
 entirely, but still might want to use existing JS libraries such as jQuery, 
 this feature is essential.

Just a small point, but Fay's FFI differs from UHC/GHC's in that it
natively supports String/Double and functions without needing wrappers
and conversions from CString or whatnot. E.g. you write

addClassWith :: (Double - String - Fay String) - JQuery - Fay JQuery
addClassWith = ffi %2.addClass(%1)

and you're already ready to use it. If I recall in UHC last I tried, I
had to do some serializing/unserializing for the string types, and
make a wrapper function for the callback. Whether it makes any sense
for a UHC/GHC-backend to behave like this, I don't know. But people
really like it.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: UHC-like JavaScript backend in GHC

2012-11-13 Thread Christopher Done
You also need an accomplice web server to host the JS file containing
the JavaScript for the web worker to run. I don't see how you can
fork threads without such support.

On 13 November 2012 20:53, Luite Stegeman stege...@gmail.com wrote:
 Does/can cabal-install support GHCJS? I suppose that's a minor advantage of 
 extending GHC itself; you get cabal support almost for free.

 Yes. There are two GHCJS installation options. One is the standalone
 option that includes wrappers for cabal and ghc-pkg. You use
 `ghcjs-cabal` to install packages, see the result with `ghcjs-pkg
 list`. The standalone compiler can be installed with cabal-install,
 but it does require you to run `ghcjs-boot` in a configured GHC source
 tree, to install the core libraries (ghc-prim, base, integer-gmp).

 The alternative is the integrated compiler, where you completely
 replace your existing GHC with one that can output Javascript. You
 don't get separate package databases this way.

 How big are the JS files generated with either the new or the old code 
 generator? I recall there was a HS - JS effort out there that generated 
 huge JS files. UHC's output is relatively compact and doesn't grow as fast 
 with bigger programs.

 Relatively big for the new generator because I haven't focused on this
 yet. The generated code has lots of redundant assignments that can be
 weeded out later with a dataflow analysis pass. The old generator is a
 bit more compact (similar to haste compiler). Both versions have a
 function-level linker that only includes functions that are actually
 used.

 WebWorkers is quite limited indeed. I'm not yet sure how the serialisation 
 might complicate matters, but it seems that WebWorkers is only really a 
 possible backend for `fork`, and not `forkIO`.

 For one, you cannot serialize closures, so it will probably be similar
 to the restrictions in Cloud Haskell in that you can only call
 top-level things on the other side (Unless you don't use Javascript
 closures for your Haskell closures, the new GHCJS generator can
 actually move closures to a WebWorker, at least in theory, it's not
 yet implemented)

 luite

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GADTs in the wild

2012-08-18 Thread Christopher Done
On 18 August 2012 20:57, Bertram Felgenhauer
bertram.felgenha...@googlemail.com wrote:
 The natural encoding as a GADT would be as follows:

 data Command result where
 GetFoo :: Double - Command Foo
 PutFoo :: String - Command Double


Right, that's exactly what I wrote at the end of my email. And then
indeed dispatch would be `dispatch :: Command a - Snap a`. But how do
you derive an instance of Typeable and Read for this data type? The
Foo and the Double conflict and give a type error.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GADTs in the wild

2012-08-17 Thread Christopher Done
Funny, I just solved a problem with GADTs that I couldn't really see how
to do another way.


The context
===

In a fat-client web app (like GMail) you have the need to send requests
back to the server to notify the server or get information back, this is
normally transported in JSON format. For a Haskell setup, it would be:

JavaScript (Client) → JSON → Haskell (Server)

I made Fay, a Haskell subset that compiles to JavaScript to displace
JavaScript in this diagram and now it's:

Haskell (Client) → JSON → Haskell (Server)


Three problems to solve
===

There are three problems that I wanted to solve:

1. Make serialization just work, no writing custom JSON instances or
whatnot. That problem is solved. So I can just write:

get some-request $ \(Foo bar mu) - …

2. Share data type definitions between the client and server code. That
problem is solved, at least I have a solution that I like. It's like
this:

module SharedTypes where
… definitions here …

module Client where
import SharedTypes

module Server where
import SharedTypes

Thus, after any changes to the data types, GHC will force the programmer
to update the server AND the client. This ensures both systems are in
sync with one-another. A big problem when you're working on large
applications, and a nightmare when using JavaScript.

3. Make all requests to the server type-safe, meaning that a given
request type can only have one response type, and every command which is
possible to send the server from the client MUST have a response. I have
a solution with GADTs that I thing is simple and works.


The GADTs part
==

module SharedTypes where

I declare my GADT of commands, forcing the input type and the return
type in the parameters. The Foreign instance is just for Fay to allow
things to be passed to foreign functions.

-- | The command list.
data Command where
  GetFoo :: Double - Returns Foo - Command
  PutFoo :: String - Returns Double - Command
  deriving Read
instance Foreign Command

Where `Returns' is a simple phantom type. We'll see why this is
necessary in a sec.

-- | A phantom type which ensures the connection between the command
-- and the return value.
data Returns a = Returns
  deriving Read

And let's just say Foo is some domain structure of interest:

-- | A foobles return value.
data Foo = Foo { field1 :: Double, field2 :: String, field3 :: Bool }
  deriving Show
instance Foreign Foo

Now in the Server module, I write a request dispatcher:

-- | Dispatch on the commands.
dispatch :: Command - Snap ()
dispatch cmd =
  case cmd of
GetFoo i r - reply r (Foo i Sup? True)

Here is the clever bit. I need to make sure that the response Foo
corresponds to the GetFoo command. So I make sure that any call to
`reply` must give a Returns value. That value will come from the nearest
place; the command being dispatched on. So this, through GHC's pattern
match exhaustion checks, ensures that all commands are handled.

-- | Reply with a command.
reply :: (Foreign a,Show a) = Returns a - a - Snap ()
reply _ = writeLBS . encode . showToFay

And now in the Client module, I wanted to make sure that GetFoo can only
be called with Foo, so I structure the `call` function to require a
Returns value as the last slot in the constructor:

-- | Call a command.
call :: Foreign a = (Returns a - Command) - (a - Fay ()) - Fay ()
call f g = ajaxCommand (f Returns) g

The AJAX command is a regular FFI, no type magic here:

-- | Run the AJAX command.
ajaxCommand :: Foreign a = Command - (a - Fay ()) - Fay ()
ajaxCommand =
  ffi jQuery.ajax({url: '/json', data: %1,\
  dataType: 'json', success : %2 })

And now I can make the call:

-- | Main entry point.
main :: Fay ()
main = call (GetFoo 123) $ \(Foo _ _ _) - return ()


Summary
===

So in summary I achieved these things:

* Automated (no boilerplate writing) generation of serialization for
  the types.
* Client and server share the same types.
* The commands are always in synch.
* Commands that the client can use are always available on the server
  (unless the developer ignored an incomplete-pattern match warning, in
  which case the compiler did all it could and the developer deserves
  it).

I think this approach is OK. I'm not entirely happy about reply r. I'd
like that to be automatic somehow.


Other approaches / future work
==

I did try with:

data Command a where
  GetFoo :: Double - Command Foo
  PutFoo :: String - Command Double

But that became difficult to make an automatic decode instance. I read
some suggestions by Edward Kmett:
http://www.haskell.org/pipermail/haskell-cafe/2010-June/079402.html

But it looked rather hairy to do in an automatic way. If anyone has any
improvements/ideas to achieve this, please let me know.


Re: GADTs in the wild

2012-08-17 Thread Christopher Done
Oh, I went for a walk and realised that while I started with a GADT, I
ended up with a normal Haskell data type in a fancy GADT dress. I'll
get back to you if I get the GADT approach to work.

On 17 August 2012 15:14, Christopher Done chrisd...@gmail.com wrote:
 Funny, I just solved a problem with GADTs that I couldn't really see how
 to do another way.


 The context
 ===

 In a fat-client web app (like GMail) you have the need to send requests
 back to the server to notify the server or get information back, this is
 normally transported in JSON format. For a Haskell setup, it would be:

 JavaScript (Client) → JSON → Haskell (Server)

 I made Fay, a Haskell subset that compiles to JavaScript to displace
 JavaScript in this diagram and now it's:

 Haskell (Client) → JSON → Haskell (Server)


 Three problems to solve
 ===

 There are three problems that I wanted to solve:

 1. Make serialization just work, no writing custom JSON instances or
 whatnot. That problem is solved. So I can just write:

 get some-request $ \(Foo bar mu) - …

 2. Share data type definitions between the client and server code. That
 problem is solved, at least I have a solution that I like. It's like
 this:

 module SharedTypes where
 … definitions here …

 module Client where
 import SharedTypes

 module Server where
 import SharedTypes

 Thus, after any changes to the data types, GHC will force the programmer
 to update the server AND the client. This ensures both systems are in
 sync with one-another. A big problem when you're working on large
 applications, and a nightmare when using JavaScript.

 3. Make all requests to the server type-safe, meaning that a given
 request type can only have one response type, and every command which is
 possible to send the server from the client MUST have a response. I have
 a solution with GADTs that I thing is simple and works.


 The GADTs part
 ==

 module SharedTypes where

 I declare my GADT of commands, forcing the input type and the return
 type in the parameters. The Foreign instance is just for Fay to allow
 things to be passed to foreign functions.

 -- | The command list.
 data Command where
   GetFoo :: Double - Returns Foo - Command
   PutFoo :: String - Returns Double - Command
   deriving Read
 instance Foreign Command

 Where `Returns' is a simple phantom type. We'll see why this is
 necessary in a sec.

 -- | A phantom type which ensures the connection between the command
 -- and the return value.
 data Returns a = Returns
   deriving Read

 And let's just say Foo is some domain structure of interest:

 -- | A foobles return value.
 data Foo = Foo { field1 :: Double, field2 :: String, field3 :: Bool }
   deriving Show
 instance Foreign Foo

 Now in the Server module, I write a request dispatcher:

 -- | Dispatch on the commands.
 dispatch :: Command - Snap ()
 dispatch cmd =
   case cmd of
 GetFoo i r - reply r (Foo i Sup? True)

 Here is the clever bit. I need to make sure that the response Foo
 corresponds to the GetFoo command. So I make sure that any call to
 `reply` must give a Returns value. That value will come from the nearest
 place; the command being dispatched on. So this, through GHC's pattern
 match exhaustion checks, ensures that all commands are handled.

 -- | Reply with a command.
 reply :: (Foreign a,Show a) = Returns a - a - Snap ()
 reply _ = writeLBS . encode . showToFay

 And now in the Client module, I wanted to make sure that GetFoo can only
 be called with Foo, so I structure the `call` function to require a
 Returns value as the last slot in the constructor:

 -- | Call a command.
 call :: Foreign a = (Returns a - Command) - (a - Fay ()) - Fay ()
 call f g = ajaxCommand (f Returns) g

 The AJAX command is a regular FFI, no type magic here:

 -- | Run the AJAX command.
 ajaxCommand :: Foreign a = Command - (a - Fay ()) - Fay ()
 ajaxCommand =
   ffi jQuery.ajax({url: '/json', data: %1,\
   dataType: 'json', success : %2 })

 And now I can make the call:

 -- | Main entry point.
 main :: Fay ()
 main = call (GetFoo 123) $ \(Foo _ _ _) - return ()


 Summary
 ===

 So in summary I achieved these things:

 * Automated (no boilerplate writing) generation of serialization for
   the types.
 * Client and server share the same types.
 * The commands are always in synch.
 * Commands that the client can use are always available on the server
   (unless the developer ignored an incomplete-pattern match warning, in
   which case the compiler did all it could and the developer deserves
   it).

 I think this approach is OK. I'm not entirely happy about reply r. I'd
 like that to be automatic somehow.


 Other approaches / future work
 ==

 I did try with:

 data Command a where
   GetFoo :: Double - Command Foo

[Haskell-cafe] GHC type error pretty printing

2012-07-26 Thread Christopher Done
Is it me or is this output not right? The \ syntax doesn't indicate a newline.

chris@midnight:~$ ghci
GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude abc\n123 :: ()

interactive:2:1:
Couldn't match expected type `()' with actual type `[Char]'
In the expression:
abc\
\123 ::
  ()
In an equation for `it':
it
  = abc\
\123 ::
  ()

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Why GHC doesn't warn about LHS nullary-constructor pattern bindings?

2012-07-19 Thread Christopher Done
In your case the Nothing is unused so will never be a problem.

Perhaps more worrying:

foo :: Int - Int
foo n = x + 1
where
  Just x = Nothing

This gives no warnings.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Haskell's type inference considered harmful [Re: [Haskell] A riddle...]

2012-07-17 Thread Christopher Done
On 17 July 2012 09:27, Andreas Abel andreas.a...@ifi.lmu.de wrote:
   1. Haskell's type inference is NON-COMPOSITIONAL!

 In the riddle below, I am defining two things f (rgbliste) and g 
 (farbliste).  Even though they are not strongly connected, but g comes 
 after f in the definition order, the code of g influences the type of f.  
 THAT'S WRONG! :-(


Bindings at the same level in Haskell are mutually recursive. Order of
declaration does not matter. These two terms are unified by the type
system. So I'm not sure what you expect to happen here.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Christopher Done
On 17 July 2012 22:10, Bardur Arantsson s...@scientician.net wrote:
 On 07/17/2012 08:34 AM, Yifan Yu wrote:
 I can only tell if I browse the source code. So the question is, how can I
 determine all the exceptions that can be thrown by a given function?

 Look at its source.

Not sure that's the most productive comment. ;-P

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: How to describe this bug?

2012-07-10 Thread Christopher Done
Depends what the real offending code is. For example, if it contains
unsafePerformIO then it's not a bug.

On 10 July 2012 12:42, Sönke Hahn sh...@cs.tu-berlin.de wrote:
 Hi!

 I've discovered a strange bug that violates simple equational reasoning.
 Basically, something similar to this:

 let a = f x
 in a == f x

 evaluates to False.

 I'd like to report this on ghc-trac, but I realised, that I don't know a
 good name for behaviour like this. Is there one? Broken referential
 transparency, perhaps?

 Thanks,
 Sönke


 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

2012-07-05 Thread Christopher Done
I like \case as is proposed. It seems the least controversial one and
there's curry (\case ) for two-args, but even that seems a rare case.

For what it's worth, I like the idea of omission being partiality, as
in case of and if then. It seems perfectly natural to me, I don't need
a \ to tell me that an expression will result in a function. But some
do. So I'll go along with and vote for \case. The lack of a lambda
case is one of the few legitimate complaints I have about Haskell's
syntax so it would be marvey to see it in GHC.

P.S. \if then … else …?

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

2012-07-05 Thread Christopher Done
I like \case as is proposed. It seems the least controversial one and
there's curry (\case ) for two-args, but even that seems a rare case.

For what it's worth, I like the idea of omission being partiality, as
in case of and if then. It seems perfectly natural to me, I don't need
a \ to tell me that an expression will result in a function. But some
do. So I'll go along with and vote for \case. The lack of a lambda
case is one of the few legitimate complaints I have about Haskell's
syntax so it would be marvey to see it in GHC.

P.S. \if then … else …?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Template-haskell loading packages

2012-06-28 Thread Christopher Done
'Ello,

I'm using TH in a big project and whenever TH starts-up in the GHC
(6.4.2) compilation process it loads a number of packages:

[119 o 119] Compiling Main ( src/Main.hs,
dist/build/eudl/eudl-tmp/Main.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.4.0.0 ... linking ... done.
Loading package strict-0.3.2 ... linking ... done.
Loading package split-0.1.4.3 ... linking ... done.
Loading package safe-0.3.3 ... linking ... done.
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package binary-0.5.1.0 ... linking ... done.
Loading package cereal-0.3.5.2 ... linking ... done.
Loading package entropy-0.2.1 ... linking ... done.
Loading package largeword-1.0.1 ... linking ... done.
Loading package tagged-0.4.2.1 ... linking ... done.
Loading package crypto-api-0.10.2 ... linking ... done.
Loading package pureMD5-2.1.0.3 ... linking ... done.
Loading package dlist-0.5 ... linking ... done.
Loading package old-locale-1.0.0.4 ... linking ... done.
Loading package data-default-0.4.0 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package utf8-string-0.3.7 ... linking ... done.
Loading package printf-mauke-3000.0.5.0.1 ... linking ... done.
Loading package haskell-lexer-1.0 ... linking ... done.
Loading package pretty-show-1.2 ... linking ... done.
Loading package parallel-3.2.0.3 ... linking ... done.
Loading package transformers-0.2.2.0 ... linking ... done.
Loading package mtl-2.0.1.0 ... linking ... done.
Loading package text-0.11.2.1 ... linking ... done.
Loading package parsec-3.1.3 ... linking ... done.
Loading package unix-2.5.1.1 ... linking ... done.
Loading package network-2.3.0.14 ... linking ... done.
Loading package old-time-1.1.0.0 ... linking ... done.
Loading package HTTP-4000.2.3 ... linking ... done.
Loading package base64-bytestring-0.1.1.1 ... linking ... done.
Loading package blaze-builder-0.3.1.0 ... linking ... done.
Loading package blaze-html-0.4.3.4 ... linking ... done.
Loading package filepath-1.3.0.0 ... linking ... done.
Loading package directory-1.1.0.2 ... linking ... done.
Loading package syb-0.3.6.1 ... linking ... done.
Loading package hs-bibutils-4.12 ... linking ... done.
Loading package json-0.5 ... linking ... done.
Loading package pandoc-types-1.9.1 ... linking ... done.
Loading package time-1.4 ... linking ... done.
Loading package xml-1.3.12 ... linking ... done.
Loading package citeproc-hs-0.3.4 ... linking ... done.
Loading package extensible-exceptions-0.1.1.4 ... linking ... done.
Loading package regex-base-0.93.2 ... linking ... done.
Loading package regex-pcre-builtin-0.94.2.1.7.7 ... linking ... done.
Loading package highlighting-kate-0.5.1 ... linking ... done.
Loading package process-1.1.0.1 ... linking ... done.
Loading package random-1.0.1.1 ... linking ... done.
Loading package tagsoup-0.12.6 ... linking ... done.
Loading package temporary-1.1.2.3 ... linking ... done.
Loading package texmath-0.6.0.6 ... linking ... done.
Loading package digest-0.0.1.1 ... linking ... done.
Loading package zlib-0.5.3.3 ... linking ... done.
Loading package zip-archive-0.1.1.8 ... linking ... done.
Loading package pandoc-1.9.4.1 ... linking ... done.
Loading package convertible-1.0.11.1 ... linking ... done.
Loading package HDBC-2.3.1.1 ... linking ... done.
Loading package HDBC-postgresql-2.3.2.1 ... linking ... done.
Loading package haskelldb-2.1.3 ... linking ... done.
Loading package haskelldb-hdbc-2.1.0 ... linking ... done.
Loading package haskelldb-hdbc-postgresql-2.1.0 ... linking ... done.
Loading package QuickCheck-2.4.2 ... linking ... done.
Loading package has-0.5.0.1 ... linking ... done.
Loading package feed-0.3.8 ... linking ... done.
Loading package MonadCatchIO-mtl-0.3.0.4 ... linking ... done.
Loading package xhtml-3000.2.1 ... linking ... done.
Loading package cgi-3001.1.8.2 ... linking ... done.
Loading package fastcgi-3001.0.2.3 ... linking ... done.
Loading package ranges-0.2.4 ... linking ... done.
Loading package email-validate-0.2.8 ... linking ... done.
Loading package digestive-functors-0.2.0.0 ... linking ... done.
Loading package digestive-functors-blaze-0.2.1.0 ... linking ... done.
Loading package curl-1.3.7 ... linking ... done.
Loading package csv-0.1.2 ... linking ... done.
Loading package MonadRandom-0.1.6 ... linking ... done.
Loading package HUnit-1.2.4.3 ... linking ... done.
Loading package hslogger-1.1.5 ... linking ... done.
Loading package regex-posix-0.95.2 ... linking ... done.
Loading package regex-compat-0.95.1 ... linking ... done.
Loading package MissingH-1.1.1.0 ... linking ... done.
Loading package ConfigFile-1.1.1 ... linking ... done.

The TH is declared in a separate module, e.g.


Re: [Haskell-cafe] Long-running request/response protocol server using enumerator/iterator/iterIO/pipes/conduits/...

2012-06-26 Thread Christopher Done
On 26 June 2012 21:22, Nicolas Trangez nico...@incubaid.com wrote:
 Might sound easy (and actually it's pretty easy in most other languages
 I know, including an OCaml implementation), yet I fail to figure out how
 to get this done using some enumerator-style library.

Well, it's easy in Haskell, too. Just use the standard libraries.

If you want to mess around with these still-in-research iteratees and
eumerators for the composability then go for it, but when it's hard or
weird, you can't really blame that on the language. :-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How do people still not understand what FP is about? What are we doing wrong?

2012-06-18 Thread Christopher Done
On 18 June 2012 22:28, Ertugrul Söylemez e...@ertes.de wrote:
 You just have to live with the fact that there will always be a small
 percentage of retarded people.  It's best to just ignore them.

Well, they're not stupid. Just very stubborn. Like most programmers.
Stupid people can be taught to be smarter, stubborn people don't want
to be taught.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Noticed this change about infix decls in GHC 7.4.2

2012-06-17 Thread Christopher Done
So I have some module, in a work project that I'm portnig from GHC
6.12.3 to GHC 7.4.2,

module Data.Monoid.Operator where

import Data.Monoid

(++) :: Monoid a = a - a - a
(++) = mappend
infixr 5 ++

This compiles happily on GHC 6.12.3, but on 7.4.2 says:

src/Data/Monoid/Operator.hs:9:10:
Ambiguous occurrence `++'
It could refer to either `Data.Monoid.Operator.++',
 defined at src/Data/Monoid/Operator.hs:8:1
  or `Prelude.++',
 imported from `Prelude' at
src/Data/Monoid/Operator.hs:3:8-27
 (and originally defined in `GHC.Base')

It seems that it used to assign higher priority to the declared thing
in the current module over the imported one. Is this intentional? I'd
suspect not, given that if I comment the binding out:

-- (++) :: Monoid a = a - a - a
-- (++) = mappend

I get:

src/Data/Monoid/Operator.hs:9:10:
The fixity signature for `++' lacks an accompanying binding
  (The fixity signature must be given where `++' is declared)

Which seems to contradict the previous error message.

Bug?

Ciao!

P.S. Yes, I know I can fix this by not importing Prelude.
P.P.S Yes, I know there's a  or + defined now, but I prefer (++), thanks.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Current uses of Haskell in industry?

2012-06-13 Thread Christopher Done
On 14 June 2012 02:00, Chris Smith cdsm...@gmail.com wrote:
 It turns out I'm filling in for a cancelled speaker at a local open
 source user group, and doing a two-part talk, first on Haskell and
 then Snap.  For the Haskell part, I'd like a list of current places
 the language is used in industry.  I recall a few from Reddit stories
 and messages here and other sources, but I wonder if anyone is keeping
 a list.

The wiki goes without saying I suppose:
http://www.haskell.org/haskellwiki/Haskell_in_industry

We use it for web dev here at CREATE-NET. Two public facing sites:

http://confy.eai.eu/ -- For paper submission/review (like EasyChair).
About 17K lines of Haskell, 20K of JS (actually some pages are Haskell
compiled to JavaScript with my compiler). Couple hundred lines of
Java. It was supposed to be released open source last year but you
know what corporations are like.

http://eudl.eu/content -- A digital archive, like IEEEXplore or ACM
digital library. Not so big, about 11K lines of Haskell.

Both have lots of internal-only features, IEEE/ACM/Springer
communication stuff. Maybe I should add to the wiki list.

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: scrobble-0.1.0.1: Scrobbling server

2012-06-10 Thread Christopher Done
Heyo,

If you use Last.fm/Libre.fm you might be interested in running your own
local scrobbling server in Haskell.

$ cabal update
$ cabal install scrobble
$ scrobble-server 8910

Source is here with further instructions for audio players and such:

https://github.com/chrisdone/scrobble

Exactly what the server does with the scrobbles it receives is purely up to
you, use it as a library and do as you please. Personally I might work on a
Last.fm replacement, at least as far as the statistics/reporting generation
goes.

Ciao!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: stylish-haskell 0.2

2012-06-07 Thread Christopher Done
Excellent, I'll check these new features work in haskell-mode when I get home.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Explicit calls to the garbage collector.

2012-05-07 Thread Christopher Done
I would also be interested to know this. A web server is an example of
a Haskell program that could force garbage collection at the end of
every request reply, especially a multi-threaded server where the
memory use is localized to threads. For long-running applications, a
GC at this point would be nice.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: default instance for IsString

2012-04-21 Thread Christopher Done
Pretty sure it does default to String, anyway:

{-# LANGUAGE OverloadedStrings #-}

main = print (show Hello!)

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] strange GHCi type inference behavior involving map and partially applied functions

2012-04-15 Thread Christopher Done
On 16 April 2012 01:44, Ting Lei tin...@hotmail.com wrote:
 Kind of a newbie question, how can I automatically turn on 
 NoMonomorphismRestriction using emacs mode for haskell?
 I know there is the :set command, but I don't want to do it every time I 
 start up emacs.

You can just add it to your ~/.ghci or the .ghci file of your project directory.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A Modest Records Proposal

2012-04-02 Thread Christopher Done
On 2 April 2012 14:41, Michael Snoyman mich...@snoyman.com wrote:
 import Data.Time

 main = do
    now - getCurrentTime
    let (_, month, day) = toGregorian $ utctDay now
    putStrLn $
        if month == 4  day == 1
            then It's a joke
            else It's real

import Data.Time
main = do
   now - getCurrentTime
   let (_, month, day) = toGregorian $ utctDay now
   putStrLn $
   if month == 4  day == 1
   then It's a joke
   else It's real. (This output is not a joke. But run this
program again to be sure.)

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] A Modest Records Proposal

2012-04-02 Thread Christopher Done
On 2 April 2012 14:41, Michael Snoyman mich...@snoyman.com wrote:
 import Data.Time

 main = do
    now - getCurrentTime
    let (_, month, day) = toGregorian $ utctDay now
    putStrLn $
        if month == 4  day == 1
            then It's a joke
            else It's real

import Data.Time
main = do
   now - getCurrentTime
   let (_, month, day) = toGregorian $ utctDay now
   putStrLn $
   if month == 4  day == 1
   then It's a joke
   else It's real. (This output is not a joke. But run this
program again to be sure.)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A Modest Records Proposal

2012-04-01 Thread Christopher Done
I actually read the first couple paragraphs and thought “sounds
interesting I'll read it later”. After reading it properly, I lol'd.

 After some initial feedback, I'm going to create a page for the
 Homotopy Extensional Records Proposal (HERP) on trac. There are really
 only a few remaining questions. 1) Having introduced homotopies, why
 not go all the way and introduce dependent records? In fact, are HERP
 and Dependent Extensional Records Proposal (DERP) already isomorphic?
 My suspicion is that HERP is isomorphic, but DERP is not.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] ANNOUNCE: fast-tags-0.0.1

2012-04-01 Thread Christopher Done
On 1 April 2012 00:23, Evan Laforge qdun...@gmail.com wrote:
 Two of them use haskell-src which means they can't parse my code.  Two
 more use haskell-src-exts, which is slow and fragile, breaks on
 partially edited source, and doesn't understand hsc.

For what it's worth:

* As you say below, HSC is easily dealth with by ignoring # lines.

* haskell-src-exts is not slow. It can parse a 769 module codebase racking up
  to 100k lines of code in just over a second on my machine. That's
  good. Also, I don't think speed of the individual file matters, for
  reasons I state below.

* Broken source is not a big issue to me. Code is written with a GHCi session
  on-hand; syntactic issues are the least of my worries. I realise it
  will be for others.

The problem with haskell-src-exts is that it refuses to parse expressions for
which it cannot reduce the operator precedence, meaning it can't parse any
module that uses a freshly defined operator.

The reason I don't think individual file performance matters is that
the output can be cached. There's also the fact that if I modify a
file, and generate tags, I'm likely editing that file presently, and
I'm not likely to need jumping around which tags provides.

 Then there's the venerable hasktags, but it's buggy and the source
 is a mess. I fixed a bug where it doesn't actually strip comments
 so it makes tags to things inside comments, but then decided it
 would be easier to just write my own.

Hasktags is hardly buggy in my experience. The comments bug is minor. But I
agree that the codebase is messy and would be better handled as
Text. But again, speed on the individual basis isn't a massive issue here.

 fast-tags is fast because it has a parser that's just smart enough to
 pick out the tags.  It can tagify my entire 300 module program in
 about a second.

Unfortunately there appears to be a horrific problem with it, as the
log below shows:

$ time (find . -name '*.hs' | xargs hasktags -e)

real0m1.573s
user0m1.536s
sys 0m0.032s
$ cabal install fast-tags --reinstall --ghc-options=-O2
Resolving dependencies...
Configuring fast-tags-0.0.2...
Preprocessing executables for fast-tags-0.0.2...
Building fast-tags-0.0.2...
[1 of 1] Compiling Main ( src/Main.hs,
dist/build/fast-tags/fast-tags-tmp/Main.o )
Linking dist/build/fast-tags/fast-tags ...
Installing executable(s) in /home/chris/.cabal/bin
$ time (find . -name '*.hs' | xargs fast-tags)
^C
real10m39.184s
user0m0.016s
sys 0m0.016s
$

I cancelled the program after ten minutes. The CPU was at 100% and
memory usage was slowly climbing, but only slowly. It's not an
infinite loop, however. If I delete the tags file and restrict the
search to only the src directory, it completes earlier, but gets slower.

$ time (find src -name '*.hs' | xargs hasktags -e)

real0m0.113s
user0m0.112s
sys 0m0.008s
$ time (find src -name '*.hs' | xargs fast-tags)

real0m0.136s
user0m0.120s
sys 0m0.020s
$ time (find src -name '*.hs' | xargs fast-tags)

real0m0.250s
user0m0.244s
sys 0m0.012s

So there appears to be an exponential component to the program. E.g.

$ time (find . -name '*.hs' | xargs fast-tags)
./lib/text-0.11.1.5/tests/benchmarks/src/Data/Text/Benchmarks/Pure.hs:435:
unexpected end of block after data * =
./lib/split-0.1.2.3/Data/List/Split/Internals.hs:68: unexpected end of
block after data * =
./lib/QuickCheck-2.4.1.1/Test/QuickCheck/Function.hs:51: unexpected
end of block after data * =

real0m26.993s
user0m26.590s
sys 0m0.324s

If I try to run again it hangs again. I expect it's somewhere around
sort/merge/removeDups. This is on GHC 7.2.1.

 But it's also incremental, so it only needs to do that the first
 time.

For what it's worth to anybody using hasktags, I've added this to
hasktags: https://github.com/chrisdone/hasktags/commits/master

I save the file data as JSON. I tried using aeson but that's buggy:
https://github.com/bos/aeson/issues/75 At any rate, it should cache
the generated tags rather than the file data, but I'd have to
restructure the hasktags program a bit and I didn't feel like that
yet.

hasktags has no problem with this codebase:

$ time (find . -name '*.hs' | xargs hasktags --cache)

real0m1.512s
user0m1.420s
sys 0m0.088s

and with the cache generated, it's half the time:

$ time (find . -name '*.hs' | xargs hasktags --cache)

real0m0.780s
user0m0.712s
sys 0m0.072s

 I have vim's BufWrite autocommand bound to
 updating the tags every time a file is written, and it's fast enough
 that I've never noticed the delay.  It understands hsc directly
 (that's trivial, just ignore the # lines) so there's no need to run
 hsc2hs before tagifying.  The result is tags which are automatically
 up to date all the time, which is nice.

This is the use-case I (and the users who have notified me of it) have
with Emacs in haskell-mode.

 If people care about lhs and emacs tags then it wouldn't be hard to
 support 

Re: [Haskell-cafe] A Modest Records Proposal

2012-04-01 Thread Christopher Done
I actually read the first couple paragraphs and thought “sounds
interesting I'll read it later”. After reading it properly, I lol'd.

 After some initial feedback, I'm going to create a page for the
 Homotopy Extensional Records Proposal (HERP) on trac. There are really
 only a few remaining questions. 1) Having introduced homotopies, why
 not go all the way and introduce dependent records? In fact, are HERP
 and Dependent Extensional Records Proposal (DERP) already isomorphic?
 My suspicion is that HERP is isomorphic, but DERP is not.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: fast-tags-0.0.1

2012-04-01 Thread Christopher Done
By the way, I'm assuming that this library isn't an April Fools joke
by making a library called “fast” with explosive O(n²) time problems.
:-P

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Christopher Done
Similar proposal here:
http://www.reddit.com/r/haskell/comments/qy990/suggestion_for_flip_map/

It seems generally favorable. Might as well generalize it though and have
flip fmap.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Christopher Done
On 28 March 2012 22:05, Matthew Steele mdste...@alum.mit.edu wrote:
 Doesn't for already exist, in Data.Traversable?   Except that for =
 flip traverse.

Traverse doesn't fit the type of fmap, it demands an extra type constructor:

traverse :: (Traversable t,Applicative f) = (a - f b) - t a - f (t b)

fmap :: Functor f = (a - b) - f a - f b

Note the (a - f b) instead of (a - b).

E.g.

fmap :: (a - b) - [a] - [b]

can't be expressed with traverse, you can only get this far:

traverse :: (a - [b]) - [a] - [[b]]

Unless I'm missing something.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What happened with goa package repo?

2012-03-26 Thread Christopher Done
On 26 March 2012 07:24, Dmitry Malikov malikov@gmail.com wrote:
 Cloning into bare repository '/usr/portage/distfiles/egit-src/goa.git'...
 fatal: The remote end hung up unexpectedly
  * ERROR: dev-haskell/goa- failed (unpack phase):
  *   git-2_initial_clone: can't fetch from
 git://github.com/chrisdone/goa.git

 https://github.com/chrisdone/goa returns 404.

 So it seems like Chris dropped that repo. Did someone have clone of it? It
 will be nice to put it back on github.

This has been entirely unmaintained for some time. The repo is up
there now, but I haven't used it or maintained it in nearly a year.
Please clone this if you want the commits, but otherwise it is
available on hackage. I will remove it eventually.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: GHCi and line numbers (with ghc-7.4.1)

2012-03-22 Thread Christopher Done
On 22 March 2012 12:13, Simon Marlow marlo...@gmail.com wrote:
 On 20/03/2012 20:12, Simon Hengel wrote:
 They are now incremented with each evaluated expression.

Why *are* they incremented with each evaluation? Surely the only use
for line numbers would be in multi-line statements:

 :{
Prelude| do x - [1..10]
Prelude|    return y
Prelude| :}

interactive:6:11: Not in scope: `y'

Would it not make more sense to have

interactive:2:11: Not in scope: `y'

as it would do if compiling the file in a source file? From the older
GHCs, this always gives 1, indicating that multi-line statements are
somehow parsed and collapsed before being compiled, or maybe the line
number was just hard coded to 1.

FWIW, in my Emacs mode (making good progress on adding to
haskell-mode) I use the column number in the REPL to highlight on the
line where the problem is (e.g. here
http://chrisdone.com/images/hs-repl-error-demo.png), for GHC 7.* with
proper multi-line support I will automatically wrap any multi-line
expressions entered in the REPL in :{ and :}, it would be cool for
line numbers in errors to be useful for that. (Arguably we should be
using the GHC API and Scion or something like it, but these change
quite often and are hard to support whereas interfacing with GHCi is
quite stable across around seven releases and just works.)

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: String != [Char]

2012-03-17 Thread Christopher Done
On 17 March 2012 05:30, Tony Morris tonymor...@gmail.com wrote:
 Do you know if there is a good write-up of the benefits of Data.Text
 over String? I'm aware of the advantages just by my own usage; hoping
 someone has documented it rather than in our heads.

Good point, it would be good to collate the experience and wisdom of
this decision with some benchmark results on the HaskellWiki as The
Place to link to when justifying it.

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: [Haskell-cafe] In Haskell, because of the fine layers of abstraction that are possible, it pays to hone one's critical thinking skills.

2012-03-17 Thread Christopher Done
Are you creating these posts by accident or what's the point of them?
They are completely devoid of a message body.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] In Haskell, because of the fine layers of abstraction that are possible, it pays to hone one's critical thinking skills.

2012-03-17 Thread Christopher Done
On 17 March 2012 22:09, Brandon Allbery allber...@gmail.com wrote:
 I think KC is simply unfamiliar with mail clients, and is putting what is
 intended to be the body in the subject line.

Possibly. If that's the case I'm sorry KC if any offense was caused
with my blunt words.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Open-source projects for beginning Haskell students?

2012-03-16 Thread Christopher Done
On 16 March 2012 21:28, Brent Yorgey byor...@seas.upenn.edu wrote:
 So I'd like to do it again this time around, and am looking for
 particular projects I can suggest to them.  Do you have an open-source
 project with a few well-specified tasks that a relative beginner (see
 below) could reasonably make a contribution towards in the space of
 about four weeks? I'm aware that most tasks don't fit that profile,
 but even complex projects usually have a few simple-ish tasks that
 haven't yet been done just because no one has gotten around to it
 yet.

I have a bunch of small Haskell projects and I would enjoy helping
someone contribute to them. The problem would be finding projects that
are actually interesting to a student. The only ones I can think of,
that are trivial to work on, are:

* https://github.com/chrisdone/freenect  Requires a Kinect device
(your students have X-Box right?). This is my Kinect interface. Who
doesn't love devices with video and depth perception? Currently it
only supports depth perception, as that's all I wanted from it, but
one could fairly straight-forwardly add video support. This would
require some mentoring and helping along as it requires not only
Haskell knowledge, but it needs some C code and using the FFI. It took
me a weekend to figure out and write the depth perception part, with
help a newbie could tackle video within four weeks. Alternatively --
there's also the opportunity to write some simple motion detection
stuff with the existing code.

* https://github.com/chrisdone/stepeval This is benmachine's project
to evaluate Haskell in steps. It's currently on hpaste.org, but it's
rather incomplete. Fleshing this out to support more syntax would be
nice. Not sure if this is actually interesting to anyone else. But
it's a good way to solidify your understanding of Haskell's evaluation
model and syntax, maybe.

* https://github.com/chrisdone/css Making this very trivial CSS
library well-typed could be easy and useful.

* https://github.com/chrisdone/wordnik A little interface to the
Wordnik online dictionary service. I kinda started this but didn't
finish it. Once done though we can send it to Wordnik and they'll for
sure stick it on their libraries page.

* https://github.com/chrisdone/amelie (hpaste.org) The only one that
is relevant to the Haskell community, but I don't have any features
that need doing on it, as far as I'm aware. I think the code is fairly
easy to grok, though. Could be an opportunity for adding some feature,
and it'll be used by a fair chunk of the Haskell community.

* https://github.com/chrisdone/pgsql-simple The PostgreSQL library
that amelie uses, it's a raw tcp/ip socket interface to the server,
fairly trivial and yet interesting (to me) and useful. Needs more
authentication methods, and I have some opportunities for optimizing
some things. Tests and benchmarks for it would be good too, and
probably easy to write.

* https://github.com/chrisdone/hulk My IRC server that we use at work
could do with a better logging mechanism than a file full of JSON.
Probably a DB backend. I don't know if any student would care at all
about such a project.

Yeah… I don't really work on interesting projects, I won't bother
listing the rest. Nor are they a big deal for the community. I'm sure
the Hackage2 guys can do with some help. The ecosystem of Yesod,
Happstack and Snap always has a bunch of libraries that could do with
some fleshing out, I'd estimate. Another idea might be hacking on
Leksah, which can always have more features.

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functional programming podcast

2012-03-15 Thread Christopher Done
On 15 March 2012 06:53, Clint Moore cl...@ivy.io wrote:
 We're closing in on a month since this post.  Did everyone decide to
 do their own thing, do nothing, or ?

Ah, I'd been traveling after posting this and then settling back in
work, this remains on my TODO list in my organizer. I have no plans
laid out, it's something I've wanted for some time and this post is
the “Hey guys what if?”

We should continue—my time zone is UTC+1, I am usually free within
19-23:00 with varying degrees of freeness. Friday and the rest of the
weekend is better. We could try out G+ hangout and or I can setup a
Mumble on hpaste.org. These are good for group chats, and if the
quality isn't too great we can each record locally also and
synchronize the audio later.

Anyway, must dash.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: How to work around GHC bug

2012-03-14 Thread Christopher Done
On 14 March 2012 15:08, Ozgur Akgun ozgurak...@gmail.com wrote:

 On 14 March 2012 13:51, Volker Wysk p...@volker-wysk.de wrote:

 import System

 main = do

 [a] - getArgs

 putStrLn (show a)


 a here is already of type String. If you don't call show on it, it'll do
 the expected thing.


He means that the UTF-8 encoded string passed to the program should be
decoded into unicode points into Chars. So putStrLn (length a) should be 1
were it decoded, but it's actually 2. You can't use this string properly,
there is no Char containing the ä.  See?
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Christopher Done
Maybe an Emacs script to expand the nodes nicely:
http://www.youtube.com/watch?v=6ofEZQ7XoEA I don't find mere pretty
printing that useful compared to the “expanding” paradigm I'm used to in
Chrome and Firebug.

To try it just M-x eval-buffer on these two files,

http://www.emacswiki.org/emacs/download/peg.el
https://raw.github.com/chrisdone/haskell-emacs/master/src/hs-show.el

then make some fresh empty buffer with some demo Show output code:

BinJab 1 (Biny 2 Leaf Leaf) (Binpo 3 Leaf Leaf) (Binamr 3 Leaf (Lalar 3
Leaf Leaf))

and try, maybe, M-: (hs-show-replace (point-min) (point-max))

you should get “BinJab”, and then clicking it will give you more until you
have: http://i.imgur.com/a7rvz.png

The parser is of course a PEG parser within elisp so it kind of sucks for
large data structures (limited by Elisp's stack, and is super slow). My
haskell-emacs package has it in the REPL but I want to replace this parser
with a haskell-src-exts→sexp utility to make it faster and more reliable.
If anyone wants to replace the parser (and indeed the shower) as
described, I'd be very happy as this is a Super Nice feature and
indispensable in the REPL with “real” data.

Ciao!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Christopher Done
On 8 March 2012 10:53, Simon Hengel s...@typeful.net wrote:
 When writing library code that should work with both String and Text I
 find my self repeatedly introducing classes like:

    class ToString a where
      toString :: a - String

    class ToText a where
      toText :: a - Text

Text is already an instance of IsString which provides IsString. I've
defined ToString in my own projects though, it would be nice for it to
be defined somewhere (Data.String maybe?).

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] The (!) operation

2012-03-08 Thread Christopher Done
‘Ello.

Is there a generalization of this operator? It's all over the place,
it's basically

(!) :: (Monad m, Indexed collection index value) = index -
container - m value

We have `(!!)` on lists, `(!)` on maps, vectors, json objects, …
(doesn't seem there's one for bytestring)

(Though I seem to recall the monadic return value being frowned upon
but I don't recall why.)

Thoughts?

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The (!) operation

2012-03-08 Thread Christopher Done
On 8 March 2012 18:32, Anthony Cowley acow...@seas.upenn.edu wrote:
 Perhaps Data.Key meets your needs?

 http://hackage.haskell.org/packages/archive/keys/2.1.2/doc/html/Data-Key.html

Ah, perhaps indeed. Thanks!

On 8 March 2012 19:12, Francesco Mazzoli f...@mazzo.li wrote:
 The type signature that you wrote is very generic and doesn't help in
 introducing effects while retrieving the indexed value, which I imagine is
 what you wanted to do.

Because Maybe is already a monad and it's nice to fail in the monad of
choice, e.g. if I'm in the list monad I get empty list instead, or if
I'm in the Result monad from JSON it'll fail in there. ‘Course fail
is suboptimal and MonadError might be better.

 I guess you could define a type family for the monad type as well, e.g.:

 type family Index f
 type family IndexMonad f :: * - *

 class Functor f = Indexed f where
    index :: Index f - f a - (IndexMonad f) (Maybe a)

Right, that sounds interesting, similar to Data.Key above!

It seems like a type family is a good approach. I'll try this keys
library out.

Grazie mille, a dopo… ;-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The (!) operation

2012-03-08 Thread Christopher Done
On 8 March 2012 21:43, Brent Yorgey byor...@seas.upenn.edu wrote:
  ‘Course fail is suboptimal and MonadError might be better.

 Monads have nothing to do with failure.  Instead of Monad you would
 want to use something like MonadZero or MonadError.

Yeah that's what I said. GOSH. /NapoleanDynamite

 However, these are also suboptimal because in monads which carry
 extra information about the failure (i.e. anything other than [] or
 Maybe), the lookup function now has to make up an error message,
 when it almost certainly it doesn't know enough to give a good one.

Good point! I had sort of felt this way regarding the monadic return
in the past, but thought there might be some hidden wisdom behind the
idea that I hadn't seen, and why it was in some base libraries some
time back. Hadn't paid much attention to it, though.

Indeed, the lookup function can't show the key to provide a useful
exception message. Another problem, even if you make it like lookup ::
MonadError (LookupError key) m = key - collection - m a, there's
still the problem that the error isn't polymorphic in the same monad,
so if lookup throws e :: LookupError the whole monad needs to be that
because the functional dep is m - e. Making MonadError kinda
pointless. MonadZero gives no information and can't be handled
trivially like Maybe, too.

 This is why the use of Maybe is encouraged: Maybe is the *initial*
 instance of MonadZero, so you can map from it to failure in whatever
 monad you happen to be using.  Instead of being an annoyance this is
 encouraged style, because in doing the conversion *you* get to pick
 a meaningful error message.

Good points. I already use the fromMaybe style for this with lookup
and such-like.

Thanks for clarifying some things!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Summer of Code idea: Haskell Web Toolkit

2012-03-06 Thread Christopher Done
I might as well chime in on this thread as it is relevant to my
interests. I made a write up on a comparison of HJScript (JavaScript
EDSL) and my Ji (control browser from Haskell) library:
https://github.com/chrisdone/ji

HJScript is OK, hpaste.org uses it here:
https://github.com/chrisdone/amelie/blob/master/src/Amelie/View/Script.hs
output here: http://hpaste.org/js/amelie.js

Mini-summary of my experience: You're still stuck with JS semantics,
and it can be a little odd when you confuse what level of code (JS or
HS) you're working at, but at least it works right now and can be
well-typed. The library needs a bit of an overhaul, the GADT of
HJavaScript is simply flawed (take a brief look and you can see it can
express totally invalid JS in the syntax tree and the pretty printer
breaks operator/parens), but HJScript sorts the latter out, and I
would make all HJScript's functions generic upon MonadJS or something,
if you want a reader transformer or whatnot (i.e. to carry around some
state, a JS object), it breaks down with any higher-order
combinators taking actions as arguments. I also had some problems
making things generic AND type-accurate, but I don't recall them well
enough now. Problems aside, At Least It's Partially Well Typed.

I tried UHC out recently, made a little API for the canvas tag and
drew some pretty things. Had a little trouble with timers, though… the
callback for the timer /worked/, but the alert[1] printed the same
thing every time, as if the thunk forcing is somehow broken. I looked
at the outputted code but couldn't quite grok what was wrong with it.
Didn't get more time to investigate why. It may just be my code but it
looks sound to me, though I'm mostly winging it with the HTML5 part.

Anyway, look forward to watching ideas and work in this area.

Ciao!

[1]:

module Main where

import Control.Monad
import Language.UHC.JScript.Assorted
import Language.UHC.JScript.W3C.HTML5
import Language.UHC.JScript.ECMA.String
import Language.UHC.JScript.ECMA.Date
import Language.UHC.JScript.Types
import Language.UHC.JScript.Primitives
import Data.IORef

main = do
  doc - document
  bodies - documentGetElementsByTagName doc (toJS canvas)
  body - nodeListItem bodies 0
  ctx - getContext body 2d
  setFillStyle ctx rgb(200,0,0)
  start - newIORef 0
  setInterval 1000 $ do
st - readIORef start
forM_ [st..st+30] $ \i - do
  let ir = fromIntegral i
  fillRect ctx (20 + 10*round (sin ir)) (i*10) 2 2
writeIORef start (st + 1)
alert (show st)
  return ()

In HTML5.hs:

data Timer

foreign import jscript setInterval(%*)
  _setInterval :: FunPtr (IO ()) - Int - IO Timer

foreign import jscript wrapper
  makeIntervalCallback :: IO () - IO (FunPtr (IO ()))

setInterval delay haskellCallback = do
  jsCallback - makeIntervalCallback haskellCallback
  _setInterval jsCallback delay

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Summer of Code idea: Haskell Web Toolkit

2012-03-06 Thread Christopher Done
On 7 March 2012 06:14, Bardur Arantsson s...@scientician.net wrote:
 We get the output

 function (param0_0){var var_1 = true;return var_1;}(3);

 But this is invalid syntax in JavaScript, and should really be

 (function (param0_0){var var_1 = true;return var_1;})(3);

Right, that's one of the ones I picked up in HJavascript. Didn't
realise (or remember) it was present in HJScript, supposing that it
had its own pretty printer. Other stuff like this is present in the
HJavascript GADT.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

2012-02-22 Thread Christopher Done
On 21 February 2012 11:51, Mats Rauhala mats.rauh...@gmail.com wrote:
 You mentioned that haskelldb was the first library where you weren't
 forced to break the abstraction. Do you have a solution to a situation
 where you might want to retrieve the last inserted id after an insert?

That's a case where I would consider modifying
haskelldb-hdbc-postgresql, for example, to export an insertReturningId
or whatever, because some other engines don't support returning an ID,
and it wouldn't make sense to return Maybe Int or error for the ones
that don't support it. This way it's well-typed.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Functional programming podcast

2012-02-22 Thread Christopher Done
Show of hands, who would be interested in working on a podcast weekly
or biweekly and what would you like to provide? Light banter is an
acceptable answer. Some points that might be covered on such a podcast
might be:

* Latest FP conferences/hackathons/etc
* Competitions
* Interesting papers (new, or old and dug up)
* Interesting blog posts or stackoverflow questions
* New and interesting libraries/tech released
* Developments in the communities, funding, business developments
* Interviews with prominent FP chappies

This bleeds over a little with Haskell Weekly News, but it's more like
FP weekly interesting stuff, and therefore there would be a lot more
news to pack in. It would be something to listen to while you're
walking to work with your ipod.

On 21 February 2012 15:55, Mats Rauhala mats.rauh...@gmail.com wrote:
 On 15:15 Tue 21 Feb     , Christopher Done wrote:
 I recently thought it would be Pretty Cool to make an FP podcast, sort
 of a spoken Haskell Weekly News but covering all FP, blogs, packages,
 conferences, papers, standards, mailing lists, even stackoverflow,
 whatever's interesting in FP. We could use Gtalk or Mumble (both quite
 high quality audio) to conduct it and cut it up in audacity.

 I for one would be an interested listener

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functional programming podcast

2012-02-22 Thread Christopher Done
With permission I forward that Justin has offered to help cutting it
up and would also be on it.

 On 22 February 2012 04:39, serialhex serial...@gmail.com wrote:
  So I'm not a very good haskell (or fp) programmer, though I wouldn't mind
  doing the audio splicing (which I've done amore than a bit of) or even being
  on the podcast myself - though like I said, right now I'm better at theory
  than practice, and I'm still learning theory!  So as a good host or regular
  speaker I'm not sure id do so well, but I am willing to do what I can to get
  this off the ground!
  Justin

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] podcast?

2012-02-21 Thread Christopher Done
I recently thought it would be Pretty Cool to make an FP podcast, sort
of a spoken Haskell Weekly News but covering all FP, blogs, packages,
conferences, papers, standards, mailing lists, even stackoverflow,
whatever's interesting in FP. We could use Gtalk or Mumble (both quite
high quality audio) to conduct it and cut it up in audacity.

On 21 February 2012 15:00, Mats Rauhala mats.rauh...@gmail.com wrote:
 On 09:05 Wed 15 Feb     , serialhex wrote:
 Does anybody know of any good haskell/fp podcasts out there?  i dont know
 if my googling skillz are just failing me, but i can't seem to find
 anything.  thanks all!
 hex

 Out of my head I can think of ThinkRelevance podcast at
 http://thinkrelevance.com/blog/tags/podcast

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Munich Haskell Meeting Tonight

2011-09-29 Thread Christopher Done
Eh, I was in munich last month for a week. If you announce future
meetings here I might make it up there. It's a ~4 hour trip. Ciao!

2011/9/29 Dr. Heinrich Hördegen hoerde...@funktional.info:
  Sorry for the bad subject... Here comes my announcement again:

 Hi everybody,

 this evening (29th of September) there will be a meeting of people
 interested in Haskell or functional programming in general in Munich at
  Cafe Puck:

 http://www.cafepuck.de/

 The meeting will start at 19h30 (german time). Sorry for being late with
 this announcement. Nevertheless, please feel free to join us.

 Have a nice day,
 Heinrich


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: Webwire 0.1.0, netwire 1.2.5

2011-09-16 Thread Christopher Done
2011/9/16 Ertugrul Soeylemez e...@ertes.de:
 Hello fellow Haskellers,

 webwire is an experimental web framework based on the functional
 reactive programming library netwire.  It uses WAI under the hood and
 right now features only a subset of the very basics of what you need to
 write web sites

Are you going to provide any examples?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Records in Haskell

2011-09-15 Thread Christopher Done
I added my evaluation of the module-based approach to existing
records, but on second thoughts it's maybe inappropriate, so I'll post
it here. I saw that some people commented on the reddit discussion
that the solution is to put your types in separate modules but it
doesn't seem that anyone has tried to do this on a large scale. I
tried it (and some other record paradigms including Has), but I don't
think it scales. Here's why…

Suppose I have 112 hand-crafted data types in my
project (e.g. see attachment 51369.txt[1]), this creates a lot of
conflicts in field names and constructor names. For example:

{{{
data Comment = Comment {
  commentId   :: CommentId
, commentContent  :: Content
, commentReviewId :: ReviewId
, commentSubmissionId :: SubmissionId
, commentConferenceId :: ConferenceId
, commentDate :: ISODate
, commentReviewerNumber :: Int
  } deriving (Show)
}}}

This is a real type in my project. It has fields like “id”, “content”,
“reviewId”, “submissionId”, “date”. There are seven other data types
that have a field name “submissionId”. There are 15 with
“conferenceId”. There are 7 with “content”. And so on. This is just to
demonstrate that field clashes ''do'' occur ''a lot'' in a nontrivial
project.

It also demonstrates that if you propose to put each of these 112 types
into a separate module, you are having a laugh. I tried this around
the 20 type mark and it was, apart from being very slow at compiling,
''very'' tedious to work with. Creating and editing these modules was a
distracting and pointless chore.

It ''also'' demonstrated, to me, that qualified imports are horrible
when used on a large scale. It happened all the time, that'd I'd
import, say, 10 different data types all qualified.  Typing map
(Foo.id . BarMu.thisField) and foo Bar.Zot{x=1,y=2} becomes tedious
and distracting, especially having to add every type module when I
want to use a type. And when records use other types in other modules,
you have ''a lot'' of redundancy. With the prefixing paradigm I'd write
fooId and barMuThisField, which is about as tedious but there is at
least less . confusion and no need to make a load of modules and
import lines. Perhaps local modules would solve half of this
problem. Still have to write “Bar.mu bar” rather than “mu bar”, but
it'd be an improvement.

I also have 21 Enum types which often conflict. I end up having to
include the name of the type in the constructor, or rewording it
awkwardly. I guess I should put these all in separate modules and
import qualified,
too. Tedious, though. At least in this case languages like C# and
Java also require that you type EnumName.EnumValue, so c‘est la vie.

[1]: http://hackage.haskell.org/trac/ghc/attachment/wiki/Records/51369.txt

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Records in Haskell

2011-09-15 Thread Christopher Done
TRex is already mentioned on the wiki as coming at a too high
implementation cost.

2011/9/15 J. Garrett Morris jgmor...@cs.pdx.edu:
 On Thu, Sep 15, 2011 at 6:03 AM, Barney Hilken b.hil...@ntlworld.com wrote:
 The right way to deal with records is first to agree a mechanism for
 writing a context which means

        a is a datatype with a field named n of type b

 then give the selector n the type

        a is a datatype with a field named n of type b = n :: a - b

 There is no reason why this shouldn't be used with the current syntax
 (although it might clash with more advanced features like first-class
 labels).

 Trex is one existing approach in the Haskell design space
 http://web.cecs.pdx.edu/~mpj/pubs/polyrec.html
 http://web.cecs.pdx.edu/~mpj/pubs/lightrec.html

  /g

 --
 I’m surprised you haven’t got a little purple space dog, just to ram
 home what an intergalactic wag you are.

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Records in Haskell

2011-09-15 Thread Christopher Done
I personally really like the proposal here:
http://research.microsoft.com/en-us/um/people/simonpj/Haskell/records.html

The wiki doesn't show any opposition to this system. If Haskell had
that record system now I would be very happy and would be fine with
leaving other record systems as purely research until this whole
research area comes to some decisions.

 I believe the way forward is to implement several of the possible systems, 
 and release them for feedback. To get users to actually try out the 
 libraries, I think we need some concrete syntax for constant records, so I 
 suggest we put in a feature request.

It would also be nice if one saintly person could spend the time
documenting the available record systems in one document, trying out
examples of codebases and collecting surveys on the various systems or
something. It's a project in itself.

Personally my vote for what it's worth is Worse is Better in this
case, and to implement Simon's proposal (not that I think this
proposal is Worse, but possibly worse than
X-other-really-nice-but-tough-to-decide-on-system). If we still have
nothing by this time in six months I'll implement the bloody thing in
GHC myself.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Records in Haskell

2011-09-15 Thread Christopher Done
2011/9/15 Greg Weber g...@gregweber.info:
 Chris, Thank you for the real word experience report. I had assumed (because
 everyone else told me) that importing qualified would be much, much better
 than prefixing. I had thought that in your case since you are big on model
 separation that you would have liked having a separate file for each model
 to separate out all your model related code with. As a counter point, in all
 of my (MVC) web application projects, we do have a separate file for each
 model, and we like this approach. Each file usually contains a lot of
 business logic related to the model- the only relatively empty model files
 are ones that really represent embedded data. When I use MongoDB (which
 actually supports embedded data instead of forcing you to create a separate
 table), I will actually place the embedded models in the same file as the
 model which includes them.

Ah, this is because my approach to types is to put them in a
ProjectName.Types.X module. I /do/ have separate modules for all my
models, e.g.

$ ls Confy/Model/*.hs
Confy/Model/Actions.hs Confy/Model/Driver.hs
Confy/Model/Manuscript.hsConfy/Model/Proceedings.hs 
Confy/Model/SubmissionAuthor.hs  Confy/Model/Token.hs
Confy/Model/Activity.hsConfy/Model/Fields.hs
Confy/Model/Message.hs   Confy/Model/ReviewComment.hs   
Confy/Model/Submission.hsConfy/Model/Track.hs
Confy/Model/Author.hs  Confy/Model/FormField.hs
Confy/Model/Papertype.hs Confy/Model/ReviewerPreference.hs
Confy/Model/Tables.hsConfy/Model/User.hs
Confy/Model/Conference.hs  Confy/Model/Form.hs  
Confy/Model/Participant.hs  Confy/Model/Review.hs   
Confy/Model/Template.hs  Confy/Model/UserMeta.hs
Confy/Model/Deadline.hsConfy/Model/LogEntry.hs
Confy/Model/Period.hsConfy/Model/Role.hsConfy/Model/TH.hs   

 Confy/Model/Utils.hs

I have my HaskellDB types and then I have my normal Haskell types
which contain different fields to the database model.

But to put the /type/ in the model file itself causes cyclic import
problems when I have to start caring about what imports what and then
having modules that just contain types, etc. I find this to be quite
laborious, I did it at first but it became a hindrance to development
practice for me. Have you not found that you have this problem if you
put types in the same modules as code in a large project? Examples
welcome, too.

 After my blog post complaining about records, I had a few people telling me
 that I can just use existing polymorphism to avoid the name-spacing issue. I
 collected the approaches here: http://www.yesodweb.com/wiki/record-hacks
 I didn't think any of those telling me what i should do had actually tried
 to do this themselves, particularly at any kind of larger scale. I am
 interested to see if anyone has experience trying this approach, or if you
 have considered it.

I considered that approach but never tried it, one would probably
enlist the help of TemplateHaskell to do that approach properly. Maybe
it's not so bad? I suppose I could try making a few branches in my
project and try out this approach.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Records in Haskell

2011-09-15 Thread Christopher Done
2011/9/15 Greg Weber g...@gregweber.info:
 I should be clear that in my counter point I am using Ruby, not Haskell on
 those projects. In Ruby one can use a string for the name of a class (which
 will be evaluated later) and other general dynamic typing tricks to avoid
 cyclical dependencies.

Ah, okay. Sure, late binding (that's what it's called) makes it convenient.

 I have worked on one large Yesod project. I felt they were creating
 artificially shortened field names in some cases (that I found difficult to
 understand/remember) to try and ease the pain of large prefixed record
 selectors.

I can understand that. Accessors like reviewAssignSubmissionId for a
ReviewAssign record are pretty tedious but at least I don't have
trouble remembering them.

 However, Yesod does create all the records with prefixes in one
 module/file- so all the types are in there. They create a new model file for
 each model (conceptually, but not for a model representing simple embedded
 data). The model file can import all the record types.

Right, that's what I do. Types in one big types file, and then the
functions for the model in Project.Model.X which imports the types
file. This is an internal project, but it will be released as open
source in a few months so showing you the haddock output isn't a big
deal: http://chrisdone.com/confy-doc/ My militantness regarding adding
haddock docs is scant due to deadline pressures as you'd expect, but
it's not so bad.

E.g. checkout http://chrisdone.com/confy-doc/Confy-Model-Conference.html
and it's blatant I'm using a lot of other types.

All entities or entity-like things are in:
http://chrisdone.com/confy-doc/Confy-Types-Entities.html and enums in
http://chrisdone.com/confy-doc/Confy-Types-Enums.html

And do not look at
http://chrisdone.com/confy-doc/Confy-Model-Tables.html because it is
frightening and will make you go bald. If you're already bald, feel
free! HaskellDB and its HList-like record system.

 Personally I would prefer to define my type in the model file so I can
 quickly see my type with the related code if it were possible, but it seems
 that it isn't.

I guess it can be possible with a lot of discipline and patience.
Maybe others have done this in large projects and found it not so bad?

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell-cafe] Next European Hackathon

2011-09-07 Thread Christopher Done
‘Ello!

Any plans for the next European hackathon location that will
presumably be in 6~ months? I need time to reap potential
participants.

Wonder if we could arrange an Italian hackathon? Verohac? Hm. :-)
Maybe Utrecht? Hac6?

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHCI Feature Request: Last Successful Compilation State Saved

2011-08-30 Thread Christopher Done
On 30 August 2011 06:46, Albert Y. C. Lai tre...@vex.net wrote:
 In #haskell, we came up with the idea of running two instances of ghci. Try
 loading in one instance first; if good, commit to the other instance too; if
 bad, you still have the other instance in a functional state. Presumably,
 this should be automated by some middleware.

See my post from two days ago.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHCI Feature Request: Last Successful Compilation State Saved

2011-08-30 Thread Christopher Done
Oh, I didn't reply all. Whoops.

On 28 August 2011 13:40, Christopher Done chrisd...@googlemail.com wrote:
 On 27 August 2011 22:59, aditya siram aditya.si...@gmail.com wrote:
 I would like for the GHCI interpreter to save its environment before
 reloading a file and allowed the user to revert back to that state if the
 compilation was unsuccessful.

 Many times I've changed files, loaded them, hit a compilation error and
 needed, for example, the inferred type signature of some function. Even
 though that function hasn't been changed I have to either fix my code, undo
 a bunch of changes or comment out the last change I made and reload in order
 to do a :type on the function. This really breaks the flow of development.

 This has been bugging me for a long time and it's been on my TODO list
 for haskell-emacs: https://github.com/chrisdone/haskell-emacs

 I just implemented it. http://i.imgur.com/A71T5.png

 I just run two ghci processes, one for compiling, one for merely
 loading the code in when the former succeeds.

 It's not a very pleasant hack but in conjunction with :set
 -fobject-code it is fast and does not consume that much more memory.
 Considering tibbe's report is 4 years old, I think this solution is
 better than nothing.

 Set hs-config-preliminary-load-file to t in hs-config.el and it will
 do a preliminary load in a separate GHCi process.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHCI Feature Request: Last Successful Compilation State Saved

2011-08-30 Thread Christopher Done
On 30 August 2011 17:48, Daniel Patterson lists.hask...@dbp.mm.st wrote:
 Chris, this is amazing! One question - do you have support for tramping in 
 and running ghci remotely (or would that be easy to add)? I primarily develop 
 inside virtual-machines, so while the source code lives where emacs lives, 
 all the libraries are installed inside the virtual-machine (and the source 
 also lives there, of course).

So either

1) You put all your source files on the server, too and then run the
GHCi process under tramp and access the files via tramp.

2) Sounds like you'd prefer to keep your files local, which, I suppose
means you want to send code to the server when you trigger a compile?

Could be done, could be done. I'll ponder it.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Off-topic: Mathematics

2011-08-29 Thread Christopher Done
Possibly: http://math.stackexchange.com/

On 29 August 2011 10:34, Andrew Coppin andrewcop...@btinternet.com wrote:
 This is fairly wildly off-topic but... does anybody know of a good forum
 where I can ask questions about mathematics and get authoritative answers?
 (Apart from go visit the nearest university, that is.)

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Off-topic: Mathematics

2011-08-29 Thread Christopher Done
There's also #math on freenode, but it's a scary wilderness.

On 29 August 2011 13:34, Benedict Eastaugh ionf...@gmail.com wrote:
 On 29 August 2011 09:34, Andrew Coppin andrewcop...@btinternet.com wrote:
 This is fairly wildly off-topic but... does anybody know of a good forum
 where I can ask questions about mathematics and get authoritative answers?

 Apart from math.stackexchange.com and mathoverflow.net, which people
 have already mentioned, people often discuss mathematics on
 #haskell-blah on Freenode.

 Benedict

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Truly Really Off-topic: (Was: Mathematics)

2011-08-29 Thread Christopher Done
Wherever its origin, it is featured in SICP which was out in 1984:
http://www.youtube.com/watch?v=zQLUPjefuWA It's a sound analogy.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ambiguous module name `System.Directory'

2011-08-26 Thread Christopher Done
On 26 August 2011 18:00, informationen informatio...@gmx.de wrote:
 Hi,

 i am using ghc version 7.0.3 and a pretty recent version of the
 haskell-platform.

 Whenever i use the System.Directory module, i run into this
 conflict:

 Ambiguous module name `System.Directory':
        it was found in multiple packages:
            system-fileio-0.2.1 directory-1.1.0.0

 How can i resolve this conflict permamently (i know about :set -hide-package
 ... )? And shouldn't there be a rule in the
 haskell platform which forbids modules of the same name?

1) Use PackageImports:
http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/syntax-extns.html#package-imports

import network Network.Socket

2) Use cabal-dev ghci which will only have packages available that you
specify in your .cabal file.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] why the name lambda calculus?

2011-08-21 Thread Christopher Done
IIRC Church found it easy to write on paper.

On 21 August 2011 21:11, Jack Henahan jhena...@uvm.edu wrote:
 The short answer is because Church said so. But yes, it is basically 
 because λ is the abstraction operator in the calculus.

 Why not alpha or beta calculus? What would we call alpha and beta conversion, 
 then? :D

 On Aug 21, 2011, at 12:37 PM, C K Kashyap wrote:

 Hi,
 Can someone please tell me what is the root of the name lambda calculus? Is 
 it just because of the symbol lambda that is used?
 Why not alpha or beta calculus?
 Regards,
 Kashyap
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

 Jack Henahan
 jhena...@uvm.edu
 ==
 Computer science is no more about computers than astronomy is about 
 telescopes.
 -- Edsger Dijkstra
 ==



 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Diffs for hackage

2011-08-13 Thread Christopher Done
Wow, really nice stuff. Great work! I'll find this very useful.

On 13 August 2011 08:11, Luite Stegeman stege...@gmail.com wrote:
 hi all,
 often when a new version of a package is available on hackage, I want to see
 what has changed since the previous release. Unfortunately many packages
 don't have a changelog or a public source code repository. That's why I have
 made a simple website with git repositories that contain all versions of all
 hackage packages:

 http://hdiff.luite.com/
 The home page contains a bookmarklet that takes you directly from the index
 page of a package version (for
 example http://hackage.haskell.org/package/parsec-3.1.0 ) to the commit
 diff, showing the difference with the previous version
 ( http://hdiff.luite.com/cgit/parsec/commit?id=3.1.0 )
 I hope some people will find this useful,
 luite

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] xmonad on xkcd

2011-08-07 Thread Christopher Done
Y'all missing out:
http://www.reddit.com/r/haskell/comments/j9nef/that_seems_like_a_challenge_whatever_happened_to/

On 7 August 2011 20:31, Brandon Allbery allber...@gmail.com wrote:
 On Sun, Aug 7, 2011 at 08:07, Jon Fairbairn jon.fairba...@cl.cam.ac.uk
 wrote:

 http://xkcd.com/934/

 I am suddenly imagining an unexpected increase in development activity on
 YHC and the YHC Core to JavaScript translator
 --
 brandon s allbery                                      allber...@gmail.com
 wandering unix systems administrator (available)     (412) 475-9364 vm/sms


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Contract opportunity with Biosimilarity LLC

2011-07-29 Thread Christopher Done
On 29 July 2011 01:18, Greg Meredith lgreg.mered...@biosimilarity.com wrote:
 Biosimilarity LLC is looking for a the next Merlin! We need an artiste with
 a certain taste and technical instinct that have attracted them to next
 generation functional programming languages and other high magic. We need a
 technologist who can make the demons and dragons of web front ends do their
 bidding while making sound architectural and platform choices. Naturally,
 comfort with the Open Source ecosystem from git and GitHub to mvn and/or sbt
 to Jenkins is a given. For such a candidate we don't have to talk about
 familiarity with Scala or Haskell or ML or JavaScript or Clojure because
 they eat languages for breakfast and graphics libraries for lunch.

Ahh, so this is what people mean when they talk about rock star job ads. ;-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Fwd: C9 video in the Monadic Design Patterns for the Web series

2011-07-27 Thread Christopher Done
On 27 July 2011 10:31, Greg Meredith lgreg.mered...@biosimilarity.com wrote:
 Dear Haskellians,
 A new C9 video in the series!
 So, you folks already know most of this... except for maybe the
 generalization of the Conway construction!
 Best wishes,
 --greg

Thanks for the heads up! I love these videos.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ur tutorial, and a challenge

2011-07-27 Thread Christopher Done
On 19 July 2011 17:22, Adam Chlipala ad...@impredicative.com wrote:
    http://www.impredicative.com/ur/demo/crud1.html
 The example involves a library component encapsulating functionality like
 that of Ruby on Rails's scaffolding: automatic generation of a standard
 web-based admin interface to an SQL database table.  The Ur/Web version
 uses static typing to guarantee that any applications generated by this
 component are free of injection attacks and other generic problems.  The
 guarantees apply both to app communication with server-side pieces (e.g.,
 static type-checking of SQL) and client-side pieces (e.g., static
 type-checking of HTML).  This is not done by type-checking individual
 invocations of the admin-interface component.  Rather, the component is
 checked at a static type which guarantees correct operation for
 _any_specialization_parameters_.

 So, the challenge is, can this functionality be implemented in Haskell (GHC
 extensions fair game, any web framework allowed)?

Is TemplateHaskell fair game? Because if so these problems are not
hard. Yesod employs static typing for templates. HaskellDB achieves
injectionless static type checking even without TemplateHaskell, and
templatepg has type safe SQL queries based on parsing the SQL itself
and inspecting the types involved by asking the PostgreSQL server
directly at compile time. This doesn't protect you from runtime
changes to the DB schema of course. I think there's a lot of
interesting work to be done based on inspecting the data base schema
by querying the database server and analyzing queries at compile time.
Ferry, anyone?

Statically avoiding SQL and HTML injection/type problems are trivial
problems that have been solved since forever ago, I don't think those
are Ur's best secret weapon (dependent types goes without saying). Of
Ur I particularly like that you can write Ur that will be compiled to
JS. That is something that is hard to do in Haskell right now (ghcjs
is a great base, but it's alpha). I don't anyone will spend time to
answer the crud challenge.

   If so, how pretty is it?
 :)

Anything's gonna be prettier than what you've presented there. ;-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ur tutorial, and a challenge

2011-07-27 Thread Christopher Done
On 27 July 2011 13:58, Adam Chlipala ad...@impredicative.com wrote:
 Maybe, but I don't think you've outlined any solutions that meet my
 criteria.  The key property is what I've highlighted in my self-quote above:
 the challenge is to type-check _the_code_generator_, not just the individual
 programs it generates.  I want a static theorem that every program coming
 out of the code generator will play by the rules.

No, I didn't outline any solutions for that criteria. I'm not
competent to answer that.

 Yesod employs static typing for templates.

 Does this static type system support metaprogramming strong enough to
 implement my challenge problem with the level of static guarantee for all
 specialization parameters that I ask for?

Again I don't really know what you're talking about so I'll drop it.

Agda is still on my list of things to learn. As is Ur. But that order
seems appropriate.

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] partial inheritance

2011-07-17 Thread Christopher Done
On 17 July 2011 11:36, Patrick Browne patrick.bro...@dit.ie wrote:
 Hi,
 Is it possible to model partial inheritance using Haskell type classes?
 For example, if the class Bird has a flying method can we represent
 Penguins as a sub-class of Bird without a flying method?

Possibly with duck typing[1], but that's not vanilla Haskell type
classes. FWIW I think you'd have to have:

class (Flying a,Wings a,Feathers a,Beak a) = Bird a
class (Wings a,Feathers a,Beak a) = Penguin a

But I think that's nice anyway. Your functions, IMHO, should ask for
only the properties of the object it needs, so:

nomOnCorn :: Beak a = a - Corn - a
nomOnCorn = ...

Rather than

nomOnCorn :: Bird a = a - Corn - a
nomOnCorn = ...

As there's no need to restrict yourself by having a Bird class, IMHO.
I don't think the subclassing/hierarchy concept scales as well as a
graph.

[1]: http://chrisdone.com/posts/2010-11-22-duck-typing-in-haskell.html

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Paid work available in functional web programming

2011-07-13 Thread Christopher Done
On 13 July 2011 15:28, Adam Chlipala ad...@impredicative.com wrote:
 I write to mention briefly that I'm looking for people interested in writing
 Ur/Web programs for pay.  Ur/Web is a DSL for building modern web
 applications, and I believe it is truly a secret weapon for that domain, and
 one that should appeal to many Haskell fans.  I have one customer now for
 whom I'm leading a project to develop a particular web application, and I'd
 like to have more.  The current project would benefit from more programming
 help, and I would also like to develop a network of people interested in
 future projects.

 More information on Ur/Web can be found here:
    http://www.impredicative.com/ur/

I would like to see a real application in Ur/Web. There are many
simple examples. I don't and wouldn't want to develop like that,
writing raw HTML and SQL seems going backwards despite the incredible
advances in consistency and correctness that Ur/Web offers. I also
find it hard to understand the type system in a non-superficial level
because the related paper was very hard to grok. I tried to get it
running a while ago and could not get it to compile. I would also like
to see how it handles non-web stuff as inevitably IME web applications
involve more than merely reading and writing to a database.

I like the idea, please keep us posted about it.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Inconsistent trailing comma in export list and record syntax

2011-07-11 Thread Christopher Done
On 11 July 2011 10:49, L Corbijn aspergesoe...@gmail.com wrote:
 You could of course say that I'm using a bad style, but it remains that it
 seems to be inconsistent to allow a trailing comma in one place and not in
 the other. So is there an reason for this?

I've also noticed that I can write

data X = X deriving Show

But not

import Prelude hiding print

But we can write

x :: Foo x = …
x :: (Foo x) = …

Can write

class X

But not

module X

I wouldn't expect that there are particular argued reasons for these
inconsistencies. It's difficult to balance a consistent syntax in a
language while trying to be convenient. I don't think it matters too
much.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] video for linux two (v4l2) bindings

2011-07-05 Thread Christopher Done
On 3 July 2011 21:46, Daniel Fischer daniel.is.fisc...@googlemail.com wrote:
 On Sunday 03 July 2011, 21:34:17, Christopher Done wrote:
 I just had a quick try with cabal-install and got the below. I'm not
 sure where linux/posix_types is supposed to come from. Is this error
 obvious to you?

 glibc-devel or the equivalent package for your distro, I think.

It turned out that I needed the linux development files from
linux-libc-dev. FWIW to anyone, I'm on Ubuntu. The packages I
installed were:

sudo apt-get install linux-libc-dev
sudo apt-get install libv4l-dev

Then I got this problem:

/home/chris/Programs/bin/ghc --make -o
dist/build/v4l2-capture/v4l2-capture -hide-all-packages
-fbuilding-cabal-package -package-conf dist/package.conf.inplace -i
-idist/build/v4l2-capture/v4l2-capture-tmp -i. -idist/build/autogen
-Idist/build/autogen -Idist/build/v4l2-capture/v4l2-capture-tmp
-optP-include -optPdist/build/autogen/cabal_macros.h -odir
dist/build/v4l2-capture/v4l2-capture-tmp -hidir
dist/build/v4l2-capture/v4l2-capture-tmp -stubdir
dist/build/v4l2-capture/v4l2-capture-tmp -package-id
base-4.2.0.2-5fc3ebcb886ceae9a06b0bab7e8d4680 -package-id
bindings-libv4l2-0.1-8dde216a9ec82cb90bbe93e20783ff8c -package-id
bindings-linux-videodev2-0.1-7a032e0014085bf53e381d004d794b50
-package-id bindings-mmap-0.1-3144f93204d922458a3be21650b85f1f
-package-id bindings-posix-1.2.2-00b879b119996c2d3acc7989dde2ba63
-package-id c-io-0.1.0-dcc629f98d0e4b2e0d55acbaaa6262b6 -package-id
ioctl-0.0.1-60f1d8091a07bb23f1736fec7d2b4dd8 -O -Wall
./src/v4l2-capture.hs
[1 of 1] Compiling Main ( src/v4l2-capture.hs,
dist/build/v4l2-capture/v4l2-capture-tmp/Main.o )
Linking dist/build/v4l2-capture/v4l2-capture ...
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5dfb):
error: undefined reference to 'pthread_kill'
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5ee2):
error: undefined reference to 'pthread_kill'
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5f87):
error: undefined reference to 'pthread_sigmask'
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x6092):
error: undefined reference to 'pthread_sigmask'
collect2: ld returned 1 exit status
cabal: Error: some packages failed to install:
v4l2-examples-0.1 failed during the building phase. The exception was:
ExitFailure 1
chris@cn-done:~/v4l2-examples-0.1$

But I solved it by adding -lpthread:

chris@cn-done:~/v4l2-examples-0.1$ /home/chris/Programs/bin/ghc --make
-o dist/build/v4l2-capture/v4l2-capture -hide-all-packages
-fbuilding-cabal-package -package-conf dist/package.conf.inplace -i
-idist/build/v4l2-capture/v4l2-capture-tmp -i. -idist/build/autogen
-Idist/build/autogen -Idist/build/v4l2-capture/v4l2-capture-tmp
-optP-include -optPdist/build/autogen/cabal_macros.h -odir
dist/build/v4l2-capture/v4l2-capture-tmp -hidir
dist/build/v4l2-capture/v4l2-capture-tmp -stubdir
dist/build/v4l2-capture/v4l2-capture-tmp -package-id
base-4.2.0.2-5fc3ebcb886ceae9a06b0bab7e8d4680 -package-id
bindings-libv4l2-0.1-8dde216a9ec82cb90bbe93e20783ff8c -package-id
bindings-linux-videodev2-0.1-7a032e0014085bf53e381d004d794b50
-package-id bindings-mmap-0.1-3144f93204d922458a3be21650b85f1f
-package-id bindings-posix-1.2.2-00b879b119996c2d3acc7989dde2ba63
-package-id c-io-0.1.0-dcc629f98d0e4b2e0d55acbaaa6262b6 -package-id
ioctl-0.0.1-60f1d8091a07bb23f1736fec7d2b4dd8 -O -Wall
./src/v4l2-capture.hs -lpthread
Linking dist/build/v4l2-capture/v4l2-capture ...
chris@cn-done:~/v4l2-examples-0.1$

I guess on Claude's system it's linked to by default. So for guys
trying the examples with that error I'd recommend the following
commandline:

  cabal install v4l2-examples --ghc-option=-lpthread

Can't really play about with the webcam right now but I'd had a small
but cool project I've had in mind for a while that v4l is perfectly
suited for, so I'll get back to you with my experiences. Thanks for
releasing it, Claude. :-)

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


  1   2   3   4   >