00:10:55 <stepcut> azathoth991: you can either create the forms by writing the html by hand, and then using the 'look' functions to look up the form names and extract the values, or you can use reform to create type-safe validating forms
00:11:29 <stepcut> documented here, http://happstack.com/docs/crashcourse/RqData.html#rqdata, and http://happstack.com/docs/crashcourse/Reform.html#reform
04:28:14 <kristofer> hello!
04:28:40 <mm_freak> hi there
04:32:18 <kristofer> I'm trying to figure out how to route a request by hostname
04:34:57 <kristofer> I'm trying this: host "example.com" $ dir "path" $ someHandler ..
04:35:14 <kristofer> happstack responds with my file is not found
04:36:33 <kristofer> I'm no haskeller so I apologize if this is really simple
04:57:53 <stepcut> what url are you visiting?
04:58:15 <kristofer> http://example.com/path
04:58:34 <kristofer> http://example.com:8000/path
04:58:53 <stepcut> i think that should match
04:59:01 <stepcut> i wonder if the port number is causing issues
04:59:05 <stepcut> let me look
05:01:09 <kristofer> looks like it does return the port as well
05:02:00 <stepcut> yeah
05:02:06 <stepcut> not sure if that should be considered a feature or a bug
05:02:22 <kristofer> so maybe: host ("example.com", 8000) $ dir "path" $ someHandler ..
05:02:33 <kristofer> I'll investigate
05:02:55 <stepcut> certainly the docs should be clear
05:03:41 <stepcut> it's basically matching on the host header
05:03:42 <stepcut> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
05:03:46 <stepcut> which does include the port number
05:04:31 <kristofer> aha success
05:04:43 <stepcut> I wonder what it returns with behind a reverse proxy
05:04:52 <stepcut> i think the proxy might rewrite the host header
05:05:00 <kristofer> so maybe: host "example.com:8000" $ dir "path" $ someHandler ..
05:05:02 <stepcut> anyway, I'll update the documentation
10:23:10 <HugoDaniel> hi
14:15:41 <mm_freak> recently i realized that about all other frameworks respond to the user either by shortcutting or by a side effect…  happstack is the only framework i know that is 'pure' in a sense
14:16:17 <mm_freak> i wonder why, say, simpleHTTP takes a ServerPartT IO Response (effectively) and not a (Monad m) => Request -> m Response
14:16:29 <mm_freak> and whether there are actually shortcuts
14:17:26 <mm_freak> stuff like decodeBody could still live in the IO monad
14:32:22 <HugoDaniel> can i run IO inside the acid-state Update monad ?
14:33:11 <donri> HugoDaniel: no. that would be bad :)
14:33:11 <mm_freak> HugoDaniel: no
14:33:35 <donri> events are replayed if not checkpointed
14:33:40 <HugoDaniel> oh
14:33:42 <HugoDaniel> :(
14:33:42 <HugoDaniel> ok
14:34:07 <donri> this is pretty much necessary to guarantee acid :)
14:34:28 <HugoDaniel> im updating my data types with IO since im using mutable Vector
14:34:36 <HugoDaniel> im going to change it
14:34:38 <mm_freak> you will also notice that unlike most RDBMSes acid-state actually takes the I very seriously =)
14:34:46 <HugoDaniel> ahah :D
14:35:10 <HugoDaniel> totally immutable yes
14:35:12 <donri> mutable wouldn't really play well with it either
14:35:20 <mm_freak> HugoDaniel: the I means Isolated
14:35:24 <HugoDaniel> oh okok
14:35:27 <HugoDaniel> :)
14:35:43 <HugoDaniel> so, im out of luck for my special indexable data type
14:35:48 <mm_freak> acid-state actually gives you full isolation, where RDBMSes can't even promise it
14:36:06 <HugoDaniel> ACTION checks wikipedia article for ACID
14:36:14 <donri> note that updates are logged, they don't replace the state
14:36:46 <HugoDaniel> oh ok
14:37:18 <donri> acid-state is kinda sorta pure/immutable even on disk ;)
14:37:48 <mm_freak> hehe
14:38:26 <mm_freak> acid-state is nowhere near pure/immutable…  you run update /actions/ and they act on the current acid-/state/ ;)
14:38:34 <mm_freak> but queries can indeed be entirely pure
14:38:56 <HugoDaniel> ok, ill replace my mutable vectors with sequence
14:39:05 <donri> well pure in the sense used do describe "functional" package managers
14:39:05 <HugoDaniel> im only using mutable because of insertion times
14:39:55 <donri> brb
14:40:47 <HugoDaniel> ok
14:41:10 <mm_freak> HugoDaniel: mutable data structures are usually slow at insertion with only one exception:  a hash table
14:41:16 <mm_freak> and you can't use hash tables with acid-state
14:41:24 <mm_freak> but you can use HashMap/HashSet from unordered-containers
14:42:13 <mm_freak> those make a compromise:  they are still tree structures, so you can do quick updates while staying in a pure setting
14:42:26 <mm_freak> in my last benchmark they were only twice as fast as Map/Set, though
14:42:27 <donri> some structures provide log n insert which isn't very slow, FSVO
14:44:23 <HugoDaniel> mm_freak: i also benchmarked them, HashMap was faster than IntMap for Int's
14:44:29 <donri> i mean constant time "feels" like it should be so much faster, and well it is, but logarithmic time still scales amazingly well
14:44:38 <HugoDaniel> ill run the benchmark again, this time with Sequence on the roll
14:47:51 <mm_freak> HugoDaniel: that doesn't surprise me…  IntMap isn't necessarily fast, it's just O(1)
14:48:12 <HugoDaniel> lol
14:48:17 <HugoDaniel> but O(1) is the fastest, right ?
14:48:24 <mm_freak> no
14:48:36 <mm_freak> it's the shortest in terms of steps
14:48:43 <HugoDaniel> ok, 1 step
14:49:03 <HugoDaniel> so, theoritically than O(log(n)), right ?
14:49:30 <mm_freak> but if one step of an O(1) algorithm takes a second, while one step of an O(2^n) algorithm takes a microsecond, you might consider using the "much worse" O(2^n) algorithm for small n =)
14:50:41 <mm_freak> for example hash tables have O(1) insert, but that "1" can be a large one…  see the recend hash collision attacks against about all languages except haskell =)
14:51:01 <mm_freak> the hash functions were too weak, so an attacker could make that "1" arbitrarily large =)
14:51:22 <mm_freak> Map does not suffer from that problem…  you know what you get
14:51:36 <HugoDaniel> mm_freak: yes, i saw the siphash in ccc
14:51:53 <HugoDaniel> i see ok
14:52:03 <HugoDaniel> ok, im running the benchmarks, let me show you after this is finished
14:57:03 <HugoDaniel> check it out: http://hpaste.org/80770
14:57:20 <HugoDaniel> code is at the bottom
14:57:59 <HugoDaniel> this is for indexation
15:21:15 <HugoDaniel> im doing for insertion
15:24:22 <HugoDaniel> insertion has crazy disparity between each structure
15:30:46 <HugoDaniel> here are the results for insertion (code at the bottom) http://hpaste.org/80772
15:31:43 <HugoDaniel> IntMap is faster than HashMap, Sequence is the fastest, and Vector is amazingly slow
15:33:20 <donri> insertion for immutable vector should be slow (O(n)?)
15:37:08 <donri> HugoDaniel: it might be possible to use mutable hash tables in the ST monad with acid-state, but i duno how useful that'd be
15:37:27 <donri> @hackage hashtables
15:37:28 <lambdabot> http://hackage.haskell.org/package/hashtables
15:40:52 <HugoDaniel> :)
15:40:59 <HugoDaniel> i think ill use sequence
15:41:03 <donri> i think the point is that you can do bulk operations mutably but every time you runST to make it pure it'll need to copy? or rather, you have to make a new table inside every ST computation
15:41:14 <HugoDaniel> hmm ok
15:41:23 <HugoDaniel> i have done a simple indexable data type
15:41:51 <HugoDaniel> but its using mutable vectors that get incremented from 1024 positions to 1024positions
15:41:57 <HugoDaniel> here, ill show you
15:46:15 <HugoDaniel> here: http://hpaste.org/80774
15:46:35 <HugoDaniel> its naive but i think it works
15:47:42 <HugoDaniel> too bad its IO based, but ill change it to have optional Sequence backend
15:52:03 <HugoDaniel> i also benchmarked memory usage against keeping a huge ByteString in memory (and using cereal to serialize/deserialize each time a write/read was done), but its roughly the same and performance was slightly worse
16:10:22 <donri> HugoDaniel: why are you making another data-store
16:13:20 <HugoDaniel> i dont know, i thought about this and started doing a simple approach
18:04:26 <donri> stepcut: http://www.haskellforall.com/2013/01/pipes-safe-10-resource-management-and.html
18:21:40 <stepkut> pipes-safe \o/
18:22:28 <donri> in deed!
18:23:05 <donri> iirc you're planning on not using the future pipes parser lib, why not?
18:46:52 <stepkut> donri: as you know, I want to create a verified parser
18:47:03 <stepkut> I am not sure that can be done using plain-old Haskell combinators
18:47:08 <stepkut> at least not in a readable way
18:48:13 <stepkut> in order to use something like 'anyChar :: Parser Char', you ultimately need a lambda abstraction (->), and that makes compile-time checking impossible
18:48:29 <stepkut> unless you use a data-type that encodes lambda abstractions internally
18:49:11 <stepkut> basically.. if you want to verify your parser at compile time.. then you need to be able to express it entirely as a data-type that does not contain any ->
18:50:21 <stepkut> that might be possible if your datatype includes an Expr type that has Lambda/Case/etc built in.. but that is going to make for a very ugly, unreadable parser most likely
18:50:52 <stepkut> I am going to see if it is possible to use the trick that reform does to ensure validity
18:51:20 <stepkut> but if that fails.. then I think the best approach is probably some non-Haskell parser generator
18:51:47 <stepkut> (similar in nature to alex, happy, etc)
18:52:04 <stepkut> though, probably implementation that allows you to use Qq
18:52:05 <stepkut> QQ
18:52:31 <stepkut> The basic issue is that we have an EBNF that already describes how to parse valid HTTP requests
18:53:33 <stepkut> using that spec alone, we can make an HTTP validator.. something that parses HTTP requests and returns a Bool indicating if they parsed successfully or not
18:53:58 <stepkut> but.. in order to do something more useful, we need to impose some structure onto the parsed data
18:55:46 <stepkut> So we have (1) a correct EBNF representation of what valid data looks like (2) a data-type that we want to store the structured data in
18:56:00 <stepkut> and now we nede to create (3) something that converts the ByteString into the data-type
18:57:03 <stepkut> if we free ourselves from the require of using Haskell to specify the transformation.. I think we get a much better solution
18:57:38 <stepkut> we can write a specification, and have it machine checked at compile time, and it can do extensive optimization as well
18:57:51 <stepkut> and we can allow hand-written optimizations that are verified as correct
19:00:44 <kxra> stepkut: how hard would it be to create a fairly simple survey app using happs for someone with little programming experience?
19:00:59 <kxra> i've taken a few intro to programming/web programming courses
19:08:50 <donri> that doesn't sound too hard... 1) define your surveys with algebraic data types, 2) define your forms with reform, 3) write some glue code between acid-state and reform in happstack handlers
19:09:05 <donri> happstack-foundation should minimize the necessary boilerplate
19:10:12 <donri> although if you need user account it's more work. duno how well happstack-{foundation,authenticate} integrate currently?
19:15:29 <donri> stepkut: isn't that what happy does, you take a bnf grammar, add some annotations to parse into data structures, it generates a parser?
19:17:30 <stepkut> kxra: harder than you might think. But it depends on how much over engineering you want
19:17:56 <kxra> stepkut: as simple as possible
19:18:01 <kxra> stepkut: at barely has to work
19:18:09 <stepkut> kxra: depends if you want to create new surveys through the web interface on the fly, or have static surveys that are built in at compile time
19:18:15 <kxra> it'll be for a class, and they won't be expecting much
19:18:18 <kxra> stepkut: static
19:18:34 <stepkut> there is a typed survey library on hackage now
19:18:44 <stepkut> one moment
19:19:02 <kxra> cool. well, i wanted to make a survey that two people take together, and then the results only show the answers they shared
19:19:45 <donri> and if a question only has two valid answers? ;)
19:20:31 <kxra> donri: it actually doesn't matter, because of the type of question
19:29:35 <stepkut> kxra: https://github.com/whatgoodisaroad/surveyor
19:29:44 <kxra> stepkut: cool, thanks
19:30:27 <stepkut> kxra: if the questions are pre-defined at compile time, then things are easy. Make a normal ADT for your survey and use reform to collect the data (and store it in acid-state)
19:31:08 <stepkut> things that are harder are conditional questions (if the user answered 'a' on question 2 then ask this, if the user answered 'b' on question 2, then ask this instead)
19:31:14 <stepkut> or defining surveys at runtime
19:31:31 <stepkut> surveyor could be complete overkill for your project as well
20:32:21 <kxra> stepcut: i don't think i need conditional questions
20:32:58 <kxra> stepcut: is there a good getting started guide that you would recommend other than just going straight to the documentation on the site?
22:27:01 <stepcut> kxra: i've never used it