Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Gergely Risko
Hi Simon,

http://hackage.haskell.org/package/lens-datetime-0.2/docs/Data-Time-Lens.html

Read the top of the page.

aDay = fromGregorian 2013 08 22
aLocal = LocalTime aDay (TimeOfDay 13 45 28)
aUTC = UTCTime aDay 7458.9

 aLocal ^. years
2013
 aUTC ^. months
8
 aDay ^. days
22
 aLocal  time .~ midnight
2013-08-22 00:00:00
 aUTC  days .~ 1  months .~ 1
2013-01-01 02:04:18.9 UTC
 aLocal  hours +~ 1-- But see the note below!
2013-08-22 14:45:28
 aLocal  flexDT.months +~ 12
2014-08-22 13:45:28
 aUTC  flexDT.days +~ 100
2013-11-30 02:04:18.9 UTC
 aLocal  flexDT.minutes +~ 120
2013-08-22 15:45:28

Gergely

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


[Haskell-cafe] ANN: hi2 -- a better indentation mode for Emacs' haskell-mode

2013-08-09 Thread Gergely Risko
Hi,

In the last 2-3 weeks I've been working on Haskell indentation inside
Emacs.  I had some annoyances for a long time and fixed some of them.

The new mode is called hi2, it's heavily based on the current
haskell-indentation (part of haskell-mode).  The changes are mainly to
the UI, although, I plan to have a look on the parser too.

The code can be found on github: https://github.com/errge/hi2.  Feel
free to send me feedback, bug reports, pull requests, etc.

It's also hosted on MELPA.

The most notable changes so far are the following:

  - DEL and C-d is not mapped: if you want to indent backwards, you can
use S-TAB.  This means no random jumping on backspace anymore.

  - TAB steps to the right as before, but when the end is reached, it
starts going to the left instead of wrapping around.

  - TAB stays inside the code, instead of going to the beginning of the
line.  As in pyhton-mode and perl-mode.

  - Region indentation common case is supported: TAB and S-TAB is simply
moving the whole region to the left/right by 1-column.  Can be
pressed repeatedly.

  - The current indentations are shown as underscores in the current
line.  So you have some visual indication on what's gonna happen.
Also useful while hacking on the parser and want to see the results.
Can be turned off by setting hi2-show-indentations to nil in your
init file or calling hi2-disable-show-indentations from the buffer.
If there are collisions with other overlay hacking modes
(e.g. fill-column-indicator), try to turn off
hi2-show-indentations-after-eol.

  - The buffer is not changed when indentation is not changed (so there
are no undo points created and no dirty flag in the buffer if
pressing TAB had no effect).

  - The code for all this is somewhat commented and cleaned.

I'm not trying to fork haskell-mode, it's maintained very actively on
github and the maintainers were always friendly through code reviews.
But the current haskell-indentation-mode required so many fixes that it
became unpleasant to contribute patch-by-patch, I wanted to move fast.
When (and if) hi2 gets stable and better in every respect than
haskell-indentation-mode, I'm happy to merge and contribute it back.

Gergely


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


[Haskell-cafe] ANN: hflags-0.1, a command line flags library similar to Google's gflags

2012-04-30 Thread Gergely Risko
Hello,

I would like to announce the release of HFlags, a command line flags
library that makes it very easy to define and use flags.

The API is similar to Google's gflags, here is a very simple example
program:

-=-
#!/usr/bin/env runhaskell

{-# LANGUAGE TemplateHaskell #-}

import HFlags

defineFlag name Indiana Jones Who to greet.
defineFlag r:repeat (3 + 4 :: Int)
  Number of times to repeat the message.

main = do remainingArgs - $(initHFlags Simple program v0.1)
  sequence_ $ replicate flags_repeat greet
  where
greet = putStrLn $ Hello 
   ++ flags_name
   ++ , very nice to meet you!
-=-

As you can see, we have TemplateHaskell functions to help with the
definition (and initialization) of the flags, and the values themselves
are pure, no need for being in the IO monad to use the value of the
flags.

Also, the initHFlags function automagically gathers all the flags
defined anywhere in the whole program, so if a library defines flags,
you don't have to mention it in the main, but the user will still be
able to set those flags too.

More details behind this design and more example can be found in the
following post: http://blog.risko.hu/2012/04/ann-hflags-0.html

Comments and criticism is welcome.

Code: http://github.com/errge/hflags
Examples: https://github.com/errge/hflags/tree/master/examples
Hackage: http://hackage.haskell.org/package/hflags

Best regards,
Gergely Risko


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