Re: [Haskell-cafe] regex-applicative library needs your help! (algorithmic challenge)
On Sat, 2011-09-17 at 22:11 -0400, Anton Tayanovskyy wrote: > By the way, can Haskell have a type that admits regular expression and > only those? I mostly do ML these days, so trying to write up a regex > types in Haskell I was unpleasantly surprised to discover that there > are all sorts of exotic terms inhabiting it, which I did not have to > worry about in ML. Besides `undefined` you can have for terms that try > to define a grammar with nested parentheses. I'm not sure that I understand exactly what the question is... but if you want to recover the set of values in ML types, you need only add an '!' before each of the fields of each of your constructors, marking them as strict fields. Sadly (but unsurprisingly), this does require using a different version of lists and other fundamental types as well. You'll be left with bottom, of course, but in strict-language thinking, that's nothing but an acknowledgement that a function returning that type may diverge... something you can't exclude in Haskell *or* ML, it's just that ML has a different natural way of thinking about it. That way lies Agda and Coq. So you get the next-closest thing: a so-called flat type, whose values are bottom, and a single layer above it in the information ordering. If I've misunderstood the question, my apologies... I haven't actually been reading this thread. -- Chris Smith ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] regex-applicative library needs your help! (algorithmic challenge)
By the way, can Haskell have a type that admits regular expression and only those? I mostly do ML these days, so trying to write up a regex types in Haskell I was unpleasantly surprised to discover that there are all sorts of exotic terms inhabiting it, which I did not have to worry about in ML. Besides `undefined` you can have for terms that try to define a grammar with nested parentheses. Using regex-applicative syntax: expr = ... <|> pure (\ _ x _ -> x) <*> sym "(" <*> expr <*> sym ")" Is this the so-called 'paucity of types' [1]? What do you do, as a library designer? Return bottom or try to detect and error out for these kind of values? Thanks, A [1] http://existentialtype.wordpress.com/tag/recursion/ On Sat, Sep 17, 2011 at 9:46 PM, Anton Tayanovskyy wrote: > So you want to encode priorities efficiently as far as I understand > from [1]? Could bit-packing combined with prefix elimination do the > trick? Choice boils down to binary choice. Attach a number N to every > execution thread that sits in a given NFA state. When the thread moves > through a binary choice state, it splits into two threads with > N_{left} = 2 * N + 1 and N_{right} = 2 * N. When two threads arrive at > the same NFA state, the machine picks one with greater N and discards > the other, thus giving priority to early over late and left over > right. This makes these numbers grow quickly, but at any point in the > simulation one can identify the common binary prefix of all the thread > numbers and remove it, because it will not be relevant for comparison. > If this is too costly, amortize and do it every K steps instead of on > every step. > > Anton > > [1] https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help > > On Tue, Sep 13, 2011 at 1:40 AM, Roman Cheplyaka wrote: >> Please help make the regex-based parsing library efficient! >> >> https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help >> >> -- >> Roman I. Cheplyaka :: http://ro-che.info/ >> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Kind Regards, > Anton Tayanovskyy > > WebSharper™ - type-safe JavaScript in F# > http://intellifactory.com > -- Kind Regards, Anton Tayanovskyy WebSharper™ - type-safe JavaScript in F# http://intellifactory.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] regex-applicative library needs your help! (algorithmic challenge)
So you want to encode priorities efficiently as far as I understand from [1]? Could bit-packing combined with prefix elimination do the trick? Choice boils down to binary choice. Attach a number N to every execution thread that sits in a given NFA state. When the thread moves through a binary choice state, it splits into two threads with N_{left} = 2 * N + 1 and N_{right} = 2 * N. When two threads arrive at the same NFA state, the machine picks one with greater N and discards the other, thus giving priority to early over late and left over right. This makes these numbers grow quickly, but at any point in the simulation one can identify the common binary prefix of all the thread numbers and remove it, because it will not be relevant for comparison. If this is too costly, amortize and do it every K steps instead of on every step. Anton [1] https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help On Tue, Sep 13, 2011 at 1:40 AM, Roman Cheplyaka wrote: > Please help make the regex-based parsing library efficient! > > https://github.com/feuerbach/regex-applicative/wiki/Call-For-Help > > -- > Roman I. Cheplyaka :: http://ro-che.info/ > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Kind Regards, Anton Tayanovskyy WebSharper™ - type-safe JavaScript in F# http://intellifactory.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] [ANNOUNCE] Haskdogs-0.1
perfect! works like a charm. Thanks for the quick response! Have a nice weekend, Mathijs On Sat, Sep 17, 2011 at 3:58 PM, Sergey Mironov wrote: > 2011/9/16 Mathijs Kwik : >> Do I need any special .el file to use these? >> Or commandline arguments to use etags format? >> >> Emacs tells me 'visit-tags-table-buffer: File >> /home/mathijs/packages/snap/tags is not a valid tags table' >> > > Please try haskdogs-0.3. > haskdogs -e > should generate TAGS file. I didn't check, but probably it is what > emacs supports. > > Sergey > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] [ANNOUNCE] Haskdogs-0.1
2011/9/16 Mathijs Kwik : > Do I need any special .el file to use these? > Or commandline arguments to use etags format? > > Emacs tells me 'visit-tags-table-buffer: File > /home/mathijs/packages/snap/tags is not a valid tags table' > Please try haskdogs-0.3. haskdogs -e should generate TAGS file. I didn't check, but probably it is what emacs supports. Sergey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Error in Installing Data.deriveTH
On Saturday 17 September 2011, 12:41:17, mukesh tiwari wrote: > > > Does there exist an unversioned ghc? What does > > > > $ which ghc > > > > print? > > It prints nothing . Okay, since cabal defaults to looking for plain "ghc" when no compiler is explicitly passed, that explains why it didn't work without --with-compiler Normally, when ghc is installed, it creates versionless symlinks to the actual scripts/binaries, so there should be symbolic links ghc, ghci, ghc-pkg to the versioned things (and haddock->haddock-ghc-7.2.1, runhaskell->runghc), many programmes expect unversioned tools by default. It might be that your install is broken, but probably creating the symlinks yourself (read the ln man-page and be careful when you create them) will be enough. > > ntro@ntro-HP-dx2480-MT-NA121PA:/usr/local/bin$ ls ghc* > ghc-7.2.1 ghci-7.2.1 ghc-pkg-7.2.1 Those should be linked to. > > ntro@ntro-HP-dx2480-MT-NA121PA:/usr/local/bin$ ls > django-admin.py eggy eric4-compareeric4-doc > eric4-pluginrepository eric4-re eric4-trpreviewer > eric4-webbrowser ghc-pkg-7.2.1 hp2ps runghc spyder > Editra eric4 eric4-configure eric4-editor > eric4-pluginuninstall eric4-sqlbrowser eric4-uipreviewer > ghc-7.2.1 haddockhpc runhaskell UTscapy > Editra.pyw eric4-api eric4-diff eric4-plugininstall > eric4-qregexp eric4-trayeric4-unittest > ghci-7.2.1haddock-ghc-7.2.1 hsc2hs scapy > > So should i delete ghc-6.12.1 from /var/lib Optional. It shouldn't cause any problems (unless you need the space). > and move the ghc-7.2.1 from > /usr/local/lib to /var/lib to execute cabal install -v > --dry-run ? No, leave /usr/local/lib where it is, moving it would cause massive breakage. For example, /usr/bin/ghc-7.2.1 expects the libraries and binaries there. The only problem was that cabal looked for "ghc" which no longer exists on your path. That fact is somewhat dubious, as normally installing ghc creates the symlinks, but creating them is probably all that's needed if invoking ghc-7.2.1 works. > As /usr/local/bin is already in the path i don't need to > move any files from here. Am i correct ? Don't move anything. If your ghc-7.2.1 is broken, you will need to reinstall (that or another version), otherwise you can work with always using (and passing) the explicit version or, more conveniently, create the expected symlinks. Cheers, Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Error in Installing Data.deriveTH
Thanks Daniel . It works. $ cabal install --with-compiler=/usr/local/bin/ghc-7.2.1 -v keys --dry-run > > work? > > ntro@ntro-HP-dx2480-MT-NA121PA:~$ cabal install --with-compiler=/usr/local/bin/ghc-7.2.1 -v keys --dry-run Reading available packages... Resolving dependencies... In order, the following would be installed: contravariant-0.1.2.1 (new package) distributive-0.2.0.1 (new package) semigroups-0.8 (new package) comonad-1.1.1.1 (new package) semigroupoids-1.2.6 (new package) comonad-transformers-2.0.2 (new package) comonads-fd-2.0.2 (new package) data-lens-2.0.1 (new package) free-2.0.2 (new package) keys-2.1.1.1 (new package) > Does there exist an unversioned ghc? What does > $ which ghc > > print? It prints nothing . ntro@ntro-HP-dx2480-MT-NA121PA:~$ which ghc ntro@ntro-HP-dx2480-MT-NA121PA:~$ Looks bad. The only idea I have is that it could be a PATH issue, your global db for 6.12.3 was under /var/lib, and your 7.2.1 lives under /usr/local, but it doesn't seem likely. Precisely this was the issue . My /var/lib directory contains ghc-6.12.1 . ntro@ntro-HP-dx2480-MT-NA121PA:/var/lib$ ls gh* ghc-6.12.1: package.conf.d ghostscript: CMap fonts ntro@ntro-HP-dx2480-MT-NA121PA:/usr/local/lib$ ls ghc-7.2.1 python2.6 python2.7 python3.1 python3.2 site_ruby ntro@ntro-HP-dx2480-MT-NA121PA:/usr/local/lib$ ls ghc* array-0.3.0.3 directory-1.1.0.1 ghc-prim-0.2.0.0 hpc-0.5.1.0 libHSffi.a libHSrts_l.alibHSrts_thr_l.arunghc base-4.4.0.0extensible-exceptions-0.1.1.3 ghc-split hsc2hs libHSffi-ghc7.2.1.so libHSrtsmain.a libHSrts_thr_p.asettings binary-0.5.0.2 filepath-1.2.0.1 ghc-usage.txt HSffi.o libHSffi_p.a libHSrts_p.aold-locale-1.0.0.3 template-haskell-2.6.0.0 bin-package-db-0.0.0.0 ghchaddock html libHSrts.a libHSrts_thr.a old-time-1.0.0.7template-hsc.h bytestring-0.9.2.0 ghc-7.2.1 haskell2010-1.1.0.0 include libHSrts_debug.a libHSrts_thr_debug.apackage.conf.d time-1.2.0.5 Cabal-1.12.0ghci-usage.txt haskell98-2.0.0.0 integer-gmp-0.3.0.0 libHSrts_debug-ghc7.2.1.so libHSrts_thr_debug-ghc7.2.1.so pretty-1.1.0.0 unix-2.5.0.0 containers-0.4.1.0 ghc-pkghoopl-3.8.7.1 latexlibHSrts-ghc7.2.1.so libHSrts_thr-ghc7.2.1.so process-1.1.0.0 unlit . ntro@ntro-HP-dx2480-MT-NA121PA:/usr/local/bin$ ls ghc* ghc-7.2.1 ghci-7.2.1 ghc-pkg-7.2.1 ntro@ntro-HP-dx2480-MT-NA121PA:/usr/local/bin$ ls django-admin.py eggy eric4-compareeric4-doc eric4-pluginrepository eric4-re eric4-trpreviewer eric4-webbrowser ghc-pkg-7.2.1 hp2ps runghc spyder Editra eric4 eric4-configure eric4-editor eric4-pluginuninstall eric4-sqlbrowser eric4-uipreviewer ghc-7.2.1 haddockhpc runhaskell UTscapy Editra.pyw eric4-api eric4-diff eric4-plugininstall eric4-qregexp eric4-trayeric4-unittest ghci-7.2.1haddock-ghc-7.2.1 hsc2hs scapy So should i delete ghc-6.12.1 from /var/lib and move the ghc-7.2.1 from /usr/local/lib to /var/lib to execute cabal install -v --dry-run ? As /usr/local/bin is already in the path i don't need to move any files from here. Am i correct ? I am already on delay for my project so i don't want to take chances again if moving these files will again break something so i am asking you although i am pretty comfortable with $ cabal install --with-compiler=/usr/local/bin/ghc-7.2.1 -v keys --dry-run Regards Mukesh Tiwari ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The applicative instances for Either?
Ketil Malde writes: > I have a program that makes use of the applicative instance for Either > String. I used to define these instances locally, but at some point, > they became part of Control.Applicative. I have limited the > dependencies to 'base >= 4', but apparently, some version 4s of base > include this instance, some do not, and it causes problems for people > trying to compile the program. > Is there any information, or otherwise accessible source specifying > exactly when this was changed, so that I can have more precise > dependencies? base is released with GHC, so the info is in the release notes for a major GHC release (library interfaces aren't allowed to change in minor releases): http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html#id3037360 1.5.10.2. base * Version number 4.3.0.0 (was 4.2.0.2) [...] * There are now Applicative, Monad and MonadFix instances for Either. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The applicative instances for Either?
On Saturday 17 September 2011, 08:42:42, Ketil Malde wrote: > Hi, > > I have a program that makes use of the applicative instance for Either > String. I used to define these instances locally, but at some point, > they became part of Control.Applicative. I have limited the > dependencies to 'base >= 4', but apparently, some version 4s of base > include this instance, some do not, and it causes problems for people > trying to compile the program. > > Is there any information, or otherwise accessible source specifying > exactly when this was changed, Commited on 18th June 2010 to HEAD ;) Checking the sources, it wasn't in base-4.2.0.2 (ghc-6.12.3), but it was in base-4.3.1.0 (ghc-7.0.2), so it was introduced with base-4.3 > so that I can have more precise > dependencies? And is there a simple way to handle this conditionally, > either within cabal, or using CPP? Simplest way would be CPP, I think. Cabal provides a MIN_VERSION_foo macro, so -- The extra parentheses might be necessary, some Cabal version(s) -- had a buggy MIN_VERSION macro, I don't remember the details #if !(MIN_VERSION_base(4,3,0)) instance Applicative (Either e) where ... #endif You can have a flag based on which the version of the module with or without the instance is imported, but the above seems much simpler ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The applicative instances for Either?
A natural reference would be the darcs repository http://darcs.haskell.org/packages/base/ or its git mirror http://darcs.haskell.org/packages/base.git which I used because getting it is much faster. Using 'git blame Control/Applicative.hs' I figured out that the instance was added in this commit: commit 8abb469bd2210d78da74b334a0f4397be5ac37f6 Author: Ross Paterson Date: Thu Jun 17 22:51:10 2010 + add Applicative instance for Either (proposal #4095) This is not the only possible instance for Either, but this one is compatible with the usual Monad instance. Unfortunately, the git repository doesn't have proper tags that correspond to the package version (if it did, we'd use 'git describe'). So, just go to the hackage page and check which release was the first one after Jun 17 2010. It was 4.3.0.0, released on Nov 16 2010. And so your dependency might look like "base >= 4.3". OTOH, it would be very nice of library developers to have changelogs and/or proper version tags in the VCS. * Ketil Malde [2011-09-17 08:42:42+0200] > > Hi, > > I have a program that makes use of the applicative instance for Either > String. I used to define these instances locally, but at some point, > they became part of Control.Applicative. I have limited the > dependencies to 'base >= 4', but apparently, some version 4s of base > include this instance, some do not, and it causes problems for people > trying to compile the program. > > Is there any information, or otherwise accessible source specifying > exactly when this was changed, so that I can have more precise > dependencies? And is there a simple way to handle this conditionally, > either within cabal, or using CPP? -- Roman I. Cheplyaka :: http://ro-che.info/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe