←2007-12-30 2007-12-31 2008-01-01→ ↑2007 ↑all
00:08:40 <ehird`_> foo<-{n->{i->n++i}}
00:08:55 <ehird`_> foo<-\n.\i.n++i
00:12:18 <oklopol> Main :: 0
00:12:18 <oklopol> = RNode 4 1 0
00:12:18 <oklopol> = RNode 4 2 0
00:12:18 <oklopol> RNode n t p = RNode 0 n t p
00:12:18 <oklopol> RNode m m t p :: p
00:12:19 <oklopol> RNode n m t p :: #node n t -> RNode n+1 m t p
00:12:23 <oklopol> eight!
00:12:37 <oklopol> ...close in complexity to the hypercube 8|
00:12:58 <oklopol> what a verbose lang, i need those shorthands...
00:15:23 <Slereah> What's ASCII 96? `?
00:15:30 <Slereah> Doesn't appear on my chart.
00:16:32 <ehird`_> oklopol! how would you like to help devise a language even more concise than oklotalk
00:16:46 <ehird`_> with only one goal: tiny code
00:16:53 <ehird`_> well, tiny code that can be written fast :-)
00:18:23 <oklopol> starting on what basis?
00:18:58 <ehird`_> oklopol: hm, insanity
00:19:06 <ehird`_> or: functions, mainly, i guess
00:19:10 <ehird`_> functions and mutations
00:19:33 <oklopol> typing makes things concise because it allows for massive overloading.
00:19:54 <ehird`_> ok then
00:19:56 <ehird`_> type inference?
00:20:02 <ehird`_> or dynamic typing
00:20:19 <oklopol> hmm
00:20:50 <oklopol> well, definately not explicit typing :)
00:21:11 <ehird`_> ofc
00:21:16 <ehird`_> type inference could be fun
00:21:16 <oklopol> yep
00:21:25 <ehird`_> you could build up a huge knowledge base of info about functions
00:21:35 <ehird`_> it could know more about how a function behaves than you do :P
00:21:41 <ehird`_> but then type inference can get complex
00:21:46 <ehird`_> also, less possibility for operator abuse
00:21:59 <oklopol> indeed, never tried implementing it though
00:22:09 <ehird`_> so... dynamic typing?
00:22:17 <oklopol> prolly
00:22:21 <ehird`_> ok
00:22:30 <ehird`_> let's get some sort of grammar
00:22:37 <ehird`_> we want prefix, binary, and postfix operators
00:22:42 <ehird`_> also N-ary binaries
00:22:44 <ehird`_> that is
00:22:46 <oklopol> hehe
00:22:48 <ehird`_> ARG op ARG ARG ...
00:22:58 <ehird`_> i don't think ARG ARG ... op ARG ARG ..., though
00:23:01 <ehird`_> that would be confusing
00:23:22 <oklopol> perhaps.
00:23:33 <ehird`_> what usage would that have
00:23:40 <oklopol> asdf i remember i came up with a language some time ago, but i forgot what it was....
00:23:46 <oklopol> how do you parse arg op arg arg?
00:25:21 <ehird`_> dunno
00:25:23 <ehird`_> K does it
00:26:50 <ehird`_> oklopol: instead of thinking about that
00:27:01 <ehird`_> oklopol: let's just say: prefix, postfix, binary
00:27:12 <ehird`_> arg op arg arg would be arg op (arg arg), i.e. second arg a list
00:27:16 <ehird`_> so
00:27:23 <ehird`_> what about the 'function' operator
00:27:35 <ehird`_> i think: []
00:28:05 <ehird`_> [_+1] or [x;x+1]
00:28:08 <ehird`_> oklopol: good so far?
00:28:36 <oklopol> seems to work.
00:28:50 <oklopol> but that's a given since there's no sidestep from K :P
00:28:57 <oklopol> K does it? huh
00:29:02 <oklopol> i don't think so...
00:29:05 <ehird`_> ok, now let's define two functions over lists
00:29:09 <ehird`_> specifically, map and fold
00:29:13 <ehird`_> \ is fold
00:29:21 <ehird`_> / is map
00:29:24 <ehird`_> Postfix operators
00:29:37 <ehird`_> func\ is a function f
00:29:42 <ehird`_> f called with a list does fold over that list with func
00:29:45 <ehird`_> same for / but with map
00:29:51 <ehird`_> +\1 2 3 -> 6
00:30:03 <ehird`_> +/(1 2) (3) -> (3) (3)
00:30:15 <oklopol> that works as long as you can't change the meaning of \ during the program
00:30:25 <ehird`_> yes, and?
00:30:26 <oklopol> well, as long as it always is a postfix oper.
00:30:31 <ehird`_> it is
00:30:36 <ehird`_> x/ and x\
00:30:42 <ehird`_> +\1 2 3 is really:
00:30:44 <oklopol> well, i mean if you want to make your own postfixors.
00:30:46 <ehird`_> (+\) 1 2 3
00:31:12 <oklopol> if you can't make them, then the separation into postfix operators is useless and the terminology of K can be used
00:31:19 <oklopol> verbs & proverbs
00:31:21 <ehird`_> [_+2]/1 2 3 -> 3 4 5
00:31:22 <ehird`_> oklopol: you can
00:31:28 <ehird`_> oklopol: you can define all kinds of ops
00:31:40 <ehird`_> [x;x+2]/1 2 3 -> 3 4 5
00:31:47 <oklopol> yes, well in that case, those need to be type checked at compile time.
00:31:59 <oklopol> which somewhat rules out dynamic typing
00:31:59 <ehird`_> nah
00:32:01 <ehird`_> dynamic typing
00:32:02 <oklopol> no?
00:32:16 <ehird`_> /, \ use their arg as a func
00:32:25 <ehird`_> if it's a number, the interpreter balks out
00:32:30 <oklopol> it will change parsing if you change a postfix operator into a prefix one.
00:32:52 <ehird`_> how does k handle this
00:33:11 <oklopol> i don't think proverbs are first class
00:33:19 <oklopol> although i don't *know*
00:33:50 <ehird`_> ok, well then parsing can be changed at runtime
00:33:50 <ehird`_> :D
00:33:53 <oklopol> *adverbs
00:33:55 <oklopol> not proverbs
00:34:02 <ehird`_> compiling will probably be possible with some tricks
00:34:21 <ehird`_> like no matter what an op is compiled as prefix,postfix,infix depending on how its used
00:34:26 <ehird`_> when multiple choices, both are tried
00:34:31 <ehird`_> and it is resolved at runtime
00:35:01 <ehird`_> oklopol: should we have pattern matching?
00:35:05 <ehird`_> and if so, what syntax
00:35:38 <oklopol> hmmm
00:35:49 <oklopol> uhhh K-tree <3
00:36:08 <oklopol> i *have* to get my hands on a K interp or make one myself...
00:36:10 <ehird`_> echo 'define k-tree' | ehirdtalk
00:36:19 <oklopol> heh
00:36:37 <ehird`_> upi can get a free K interpreter from Kx
00:36:39 <ehird`_> as in beer
00:36:51 <oklopol> what?
00:36:59 <oklopol> *-up, or what's upi?
00:37:08 <ehird`_> you
00:37:16 <oklopol> xD
00:37:23 <oklopol> oh, heh
00:38:28 <ehird`_> hm
00:38:31 <ehird`_> kx.com is confusing
00:38:32 <oklopol> pattern matching can make things more concise, definitely, the problem is the kind of iterative programming K does is much more comcise
00:38:32 <ehird`_> no info abotu K
00:38:33 <oklopol> *concise
00:39:17 <ehird`_> oh well
00:39:18 <ehird`_> http://www.nsl.com/misc/k/kwin.zip
00:39:20 <ehird`_> there's your interpreter
00:39:42 <oklopol> i'm actually on ubuntu.
00:40:46 <oklopol> lol thank you xchat, there's no way to copypaste that into my url without the kwin.zip part xD
00:40:51 <ehird`_> klin then
00:41:17 <ehird`_> now WHERE is my goddamn interpreter for os x
00:43:53 <ehird`_> http://www.kx.com/download/download.htm sdfhsdfoijsdfoihsdf no k interpreter
00:44:22 <ehird`_> anyway
00:44:25 <ehird`_> explain k-trees, oklopol
00:45:34 <ehird`_> anyway. fact:[*1|_]
00:45:40 <ehird`_> there's a factorial
00:46:12 <oklopol> whellll the k-tree is a tree
00:46:18 <oklopol> which holds the vars
00:46:31 <ehird`_> helpful
00:46:45 <oklopol> the point is you can do scopes explicitly in a fun fashion by executing something in a lower branch
00:47:59 <ehird`_> so how do i use a k-tree in place of pattern matching
00:48:15 <oklopol> umm... there's no "a k-tree"
00:48:19 <oklopol> there's only one k-tree
00:48:21 <ehird`_> ok
00:48:26 <ehird`_> how do i use it in place of pattern matching
00:48:34 <oklopol> depends what you mean.
00:48:42 <oklopol> ohhhhh
00:48:56 <oklopol> when i said "k-tree <3", it had nothing to do with pattern matching.
00:50:01 <oklopol> uhhh
00:50:03 <oklopol> k
00:50:03 <oklopol> +
00:50:05 <oklopol> erlang
00:50:06 <oklopol> =
00:50:08 <oklopol> sex.
00:50:31 <oklopol> kinda like pi calculus, but... less calculus'y :-)
00:50:57 <oklopol> something involving a linda-like global tuplespace
00:50:58 <ehird`_> so, oklopol...
00:51:04 <oklopol> what? :)
00:51:05 <ehird`_> how should we do conditionals/pattern matching/whatever
00:51:24 <oklopol> ah, well, *that* i don't know.
00:51:32 <oklopol> all i know is, k+erlang, maybe?
00:51:33 <oklopol> :))
00:51:52 <oklopol> i have no idea what that even means, i just know it's awesome.
00:52:22 <oklopol> actually, i should learn linda, since i just know it has the global tuplespace, and that's awesome :P
00:52:38 <ehird`_> :/
00:52:52 <oklopol> sorry for not being helpful, my brain isn't good at anything non-random ideas thinking at this hour.
00:53:09 <oklopol> i'd need longer vacations to get used to the fact i sleep during the day :)
00:53:27 <ehird`_> hm the evaluation model of our language is still pretty standard
00:53:38 <ehird`_> maybe there's a way to make code more consice, by completely changing it
00:55:14 <oklopol> well, you could make it point-free, and add lots of high-order functions :))
00:55:24 <oklopol> i'm going to sleep soon
00:55:27 <oklopol> too many smileys.
00:55:28 <ehird`_> heh
00:55:33 <ehird`_> point-free code isn't consicer though
00:55:46 <oklopol> not really, no
00:55:47 <ehird`_> certainly not quicker to write either
00:55:56 <oklopol> certainly not, no
00:55:58 <oklopol> :))
00:56:54 <oklopol> oklotalk isn't hard to win, since i've let a lot of stuff out i originally had, for lessening obscurity :<
00:57:31 <oklopol> so, the language
00:57:46 <oklopol> if the aim is for conciseness, i'd start with examples
00:58:04 <oklopol> i mean, examples of programs we want to be concise.
00:58:32 <oklopol> it's pretty simple to find a language that would be most concise for doing a certain kind of job
00:58:53 <oklopol> well, ofc not *the most concise one*
00:59:05 <oklopol> but, like, very.
01:00:21 <ehird`_> aim is for conciseness and speed to write
01:01:27 <oklopol> well, one way to be concise is to leave more stuff for the interp to figure out
01:01:40 <oklopol> make it a bit more declarative
01:01:53 <ehird`_> ok
01:01:57 <ehird`_> example?
01:02:10 <oklopol> one way to do this would indeed be the tuple space, i think... although that is only a feeling, since i haven't explored it that rigorously..
01:02:13 <oklopol> hmm
01:02:32 <oklopol> well, i can give you extreme examples, ones that are fully declarative...
01:03:23 <oklopol> like ![{a<b}\2\l]
01:03:27 <oklopol> for sorting
01:03:41 <oklopol> ![] means "do something that makes this return true"
01:03:52 <ehird`_> ooh
01:03:56 <ehird`_> let's devise an algorithm for sorting
01:03:57 <ehird`_> that is
01:03:58 <ehird`_> 1. fast
01:04:00 <oklopol> then \2\, here, was a reduce that took 2 at a time
01:04:06 <ehird`_> 2. extremely concise when expressed declaratively
01:04:09 <oklopol> and the rest is trivial
01:04:43 <ehird`_> also, that ![...] stuff
01:04:45 <ehird`_> for that
01:04:48 <ehird`_> will be uh...
01:04:50 <ehird`_> hard for the interp
01:04:53 <ehird`_> specifically, near-brute-force
01:05:31 <ehird`_> anyway, let's do what i said
01:05:33 <oklopol> indeed.
01:05:51 <oklopol> i said i can only concoct an extreme example in a short time.
01:06:10 <oklopol> you can so something in-between
01:06:23 <ehird`_> :-)
01:06:26 <oklopol> hmmmm
01:06:28 <ehird`_> hm
01:06:35 <ehird`_> what about improving mergesort, then making it declarative
01:06:44 <ehird`_> specifically, i'm thinking running the branches concurrently
01:07:13 <oklopol> indeed, a lot of support for cutting and splicing lists, and recursion!
01:08:21 <ehird`_> declarative recursion
01:08:24 <ehird`_> you figure that one out :-)
01:09:15 <oklopol> wait wait
01:09:19 <oklopol> i'm close to it.
01:11:03 <ehird`_> ooh
01:11:06 <ehird`_> :-)
01:11:16 <oklopol> i'm having a hard time coming up with a syntax.
01:11:22 <oklopol> did you find something?
01:12:28 <oklopol> rec l\2, zipx .<<
01:12:55 <oklopol> let's say that's a function, l\2 splits a list [1, 2, 3 ,]
01:12:57 <oklopol> eh...
01:13:22 <oklopol> let's say that's a function, l\2 splits a list [1, 2, 3, 4, 5] -> [[1, 3, 5], [2, 4]]
01:13:55 <oklopol> rec is a lower precedence high-order function that applies current function recursively for every item in a list
01:14:02 <oklopol> in this case the two halves of the list
01:15:01 <oklopol> , is a low precedence function that works as a data flow controller, it takes the output of the last thingie and gives it to the next. this could just be done using normal application, but i think the precedences may provide more conciseness with a comma oper.
01:15:48 <oklopol> zipx takes a function and a list of lists, and always zips the value the function gives from all the heads of the lists given to it as a list, and concatenates one at a time
01:16:15 <oklopol> these are all very basic functions, so i think that could be made 8 or 10 chars.
01:16:30 <ehird`_> this is not declarative
01:16:46 <oklopol> nope.
01:16:47 <oklopol> just an idea.
01:17:01 <oklopol> the declarative one i had was less concise :P
01:17:11 <oklopol> list splicing is sooooo mucho fun
01:17:27 <ehird`_> anyway: [$_\2,!]
01:17:31 <ehird`_> hmm
01:17:33 <ehird`_> anyway
01:17:36 <ehird`_> what is that
01:17:37 <ehird`_> is that a sorter
01:17:45 <oklopol> what is what
01:18:51 <ehird`_> anyway
01:18:58 <ehird`_> here's a quicksort idea:
01:20:02 <oklopol> '\_2,)#<<
01:20:35 <ehird`_> hm
01:20:36 <ehird`_> wait
01:20:43 <ehird`_> tell me the syntax for car and cdr
01:20:46 <ehird`_> one-char, prefix
01:21:14 <oklopol> i use . and : usually
01:22:12 <ehird`_> ok
01:24:47 <ehird`_> qs^naive:[l:r:(). :?_<2[_][p:#_ ?_/2. [:_<p[l:l~_][r:r~_]/_ (qs^naive l)~(qs^naive r)]]
01:24:57 <ehird`_> oklopol: imperative-style quicksort
01:25:10 <ehird`_> you can figure it out. it's not hard
01:25:29 <ehird`_> watch out for : being both a 3-arity prefix and a 2-arity infix
01:26:05 <ehird`_> qs^naive:[l:r:(). :?_<2[_][p:#_ ?_/2. [:_<p[l:l~_][r:r~_]/_. (qs^naive l)~(qs^naive r)]]
01:26:11 <ehird`_> missed a .
01:26:18 <ehird`_> qs^naive:[l:r:(). :?_<2[_][p:_#?_/2. [:_<p[l:l~_][r:r~_]/_. (qs^naive l)~(qs^naive r)]]
01:26:22 <ehird`_> made # infix
01:26:26 <oklopol> that's not very concise + i'm not sure i can read it.
01:26:26 <ehird`_> oklopol: take a look at that
01:26:35 <ehird`_> its not concise cause it's imperative
01:26:38 <ehird`_> i'll walk you through it
01:26:39 <ehird`_> qs^naive:[l:r:(). :?_<2[_][p:_#?_/2. [:_<p[l:l~_][r:r~_]/_. (qs^naive l)~(qs^naive r)]]
01:26:45 <ehird`_> x:y is assignment
01:26:48 <oklopol> ah
01:26:53 <ehird`_> l:r:() is like l = r = []
01:27:00 <ehird`_> () just being the null expression
01:27:12 <ehird`_> since scalars = list 1-order,
01:27:15 <ehird`_> null = list 0-order
01:27:17 <oklopol> mine was imperative and 9 characters :)
01:27:23 <ehird`_> then we have 3-arity :
01:27:28 <oklopol> but okay
01:27:32 <ehird`_> and yes but mine's not relying on bizzare things
01:27:36 <ehird`_> ?_<2
01:27:37 <oklopol> neither is mine.
01:27:38 <ehird`_> ? is length
01:27:42 <ehird`_> ?_ being length of the arg
01:27:45 <ehird`_> checking <2
01:27:50 <ehird`_> if so, we just return it - [_]
01:27:59 <ehird`_> otherwise, pick a pivot from the middle - ary#index
01:28:16 <ehird`_> then, run [:_<p[l:l~_][r:r~_]] over the list
01:28:23 <ehird`_> if _ is less than the pivot, append it to l
01:28:25 <ehird`_> ~ is concat
01:28:28 <ehird`_> otherwise, append it to r
01:28:34 <ehird`_> then, qs l and r and concat them together
01:28:47 <ehird`_> so what's your qs?
01:28:53 <oklopol> it's not fully imperative really
01:28:58 <ehird`_> thought so
01:29:14 <oklopol> qs is much harder in my lang stub.
01:29:31 <ehird`_> '\_2,)#<<
01:29:33 <ehird`_> walk me through
01:29:49 <oklopol> i already did, but i'll redo that
01:30:02 <ehird`_> wait, it's not qs
01:30:05 <ehird`_> it's brute-force sort
01:30:06 <ehird`_> :-)
01:30:10 <oklopol> it's mergesort
01:30:33 <oklopol> also, it's a parametrizable mergesort of any amount of splits
01:30:44 <ehird`_> it's also slow
01:30:50 <oklopol> turning \ into / will make another mergesort, which runs a bit faster
01:31:00 <oklopol> nope, yours copies the list too.
01:31:33 <ehird`_> ok walk me through it
01:31:35 <ehird`_> each char
01:31:54 <oklopol> okay, first split by ',' to get the statements
01:32:00 <ehird`_> ok
01:32:01 <ehird`_> '\_2
01:32:03 <ehird`_> and )#<<
01:32:24 <oklopol> "'" there is a special recursion tool that applies recursion to each sublist, unless an empty list, which is simply returned
01:32:28 <oklopol> this is a frequent need.
01:32:35 <oklopol> it's a deep mapping.
01:32:38 <oklopol> basically
01:32:40 <ehird`_> ok
01:32:44 <ehird`_> and \_2
01:33:13 <oklopol> \ is a prefix splice here, _ is the nameless arg given to the substatement, so it will basically be cut in two halves in the first statement
01:33:26 <oklopol> then, the recursion applies
01:33:26 <ehird`_> prefix splice? sounds pretty specific to me
01:33:35 <oklopol> err...
01:33:36 <ehird`_> ok, wht's )#<< and why does it have unmatched
01:33:44 <oklopol> cutting a list into pieces is what i based the idea on.
01:33:51 <ehird`_> ok
01:33:54 <ehird`_> )#<<
01:34:41 <oklopol> yeah, that will take the resulting list, )# is, kinda like ', a special prefix transformer, that takes a list, and concatenates using the function given to decide which one pick at each time.
01:35:05 <oklopol> that's pretty spesific, but there are enough 2-char tokens to have that kind of stuff, especially when you can overload.
01:35:11 <oklopol> << is just a min function
01:35:51 <oklopol> it would be just <, in case of type inference, where < can be min when a non-boolean is expected and normal ordering function int->int->bool when a bool is expected.
01:36:00 <ehird`_> how about we define a problem domain to work on
01:36:03 <ehird`_> then base the language on that
01:36:17 <ehird`_> let's think low-level: what essentially are most algorithmic programs?
01:36:24 <ehird`_> Let's take the factorial.
01:36:31 <ehird`_> Isn't it a map?
01:36:37 <oklopol> yeah
01:36:39 <ehird`_> An infinite map.
01:36:43 <oklopol> yarrrr
01:36:46 <ehird`_> So..
01:36:57 <ehird`_> If [] is a mapping,
01:37:03 <ehird`_> [x=y. x=y] etc
01:37:11 <oklopol> hmmm
01:37:14 <ehird`_> then
01:37:16 <oklopol> [] is a mapping?
01:37:20 <oklopol> errr
01:37:20 <ehird`_> we can algorithmically define how to look up a key
01:37:25 <oklopol> what kinda mapping, now?
01:38:03 <ehird`_> fact = [_<2 = 1; n = n * fact(n-1)]
01:38:07 <ehird`_> do you see?
01:38:13 <ehird`_> it's just a dictionary, mapping, hash table, thing
01:38:17 <ehird`_> but you can define keys algorithmically
01:38:24 <ehird`_> and they are lazily called upon
01:38:29 <ehird`_> fact(n-1) is just a table lookup
01:38:36 <ehird`_> a function is just a table
01:38:37 <oklopol> well yeah, that's how oklotalk would do it
01:38:41 <ehird`_> no
01:38:43 <ehird`_> because it's still a function
01:38:48 <ehird`_> it's still called and returned from, etc
01:38:54 <oklopol> ?
01:38:59 <ehird`_> let's put it this way
01:39:02 <ehird`_> there are no functions
01:39:06 <ehird`_> _<2 isn't a pattern match as such
01:39:06 <oklopol> oklotalk doesn't differentiate between lists and functions...
01:39:11 <ehird`_> it doesn't match on an 'argument'
01:39:24 <oklopol> i see, it's the same thing, essentially, though?
01:39:26 <ehird`_> it simply states that in the fact table, lookups < 2 = 1
01:39:30 <ehird`_> that is: it's a hash table
01:39:35 <oklopol> yes, a function
01:39:36 <ehird`_> you don't 'execute and match'
01:39:40 <ehird`_> you 'lookup'
01:39:49 <oklopol> that's exactly how functions do it, pattern match and return.
01:39:50 <ehird`_> please understand the philisophical difference
01:39:54 <ehird`_> no
01:40:04 <oklopol> how'
01:40:06 <ehird`_> please think about it
01:40:15 <ehird`_> it's a different way of thinking about it
01:40:19 <ehird`_> instead of factorial being an algorithm
01:40:23 <ehird`_> it's just a lookup table:
01:40:33 <oklopol> yes, exactly the idea behind pattern matching.
01:40:46 <ehird`_> [0 = 1; 1 = 1; 2 = 2; 3 = 6; 4 = 24; ...]
01:40:52 <ehird`_> don't think of it as matching
01:40:53 <oklopol> but, oklotalk does exactly what you're thinking there, makes function basically an infinite list.
01:40:57 <ehird`_> think of it as all keys are evaluated already
01:40:58 <oklopol> or a hashmap
01:41:05 <ehird`_> don't think of fact(n) matching
01:41:05 <oklopol> yes, the oklotalk way.
01:41:08 <oklopol> period.
01:41:11 <ehird`_> just think of it looking up an already infinite table
01:41:23 <oklopol> yes, the *exact* idea behind oklotalk's functions.
01:41:33 <ehird`_> no, because you don't reason about it like a function
01:41:41 <oklopol> k.
01:41:42 <ehird`_> you reason about it like a pre-computed table
01:41:48 <ehird`_> like everything is constant
01:41:49 <oklopol> ah, kinda like in oklotalk.
01:41:55 <ehird`_> kind of, but not exactly
01:42:05 <ehird`_> oklotalk still makes you think about calling and returning, etc
01:42:41 <oklopol> yes, it lets you do that if you want, i'm just saying that's nothing new, pattern matching is equivalent to that...
01:43:09 <oklopol> except for the possible built-in functions that might handle it differently, but you can do that for functions too
01:43:15 <ehird`_> yes, the method is equiv
01:43:17 <ehird`_> the reasoning isn't
01:43:21 <ehird`_> we're thinking about this abstractly
01:43:47 <ehird`_> if we think of just looking everything up in tables that have always been constant and calculated, with that stuff just as syntactic sugar, our primitives etc. will be different
01:43:50 <ehird`_> and perhaps fruitful
01:44:14 <oklopol> well yeah, that provides for interesting, infinite lazy lists
01:44:24 <ehird`_> tables
01:44:25 <ehird`_> not lists
01:44:27 <oklopol> but haskell already has those, and you can even use them exactly like lists
01:44:36 <ehird`_> fact = [hello = 4]
01:44:40 <ehird`_> fact(hello)
01:44:41 <ehird`_> 4
01:44:42 <ehird`_> well
01:44:44 <ehird`_> "hello"
01:44:44 <oklopol> with a look-up table like that, with random-access type indexing, it's very hard to be lazy.
01:44:46 <ehird`_> and fact("hello")
01:44:49 <oklopol> actually... no
01:45:04 <ehird`_> oklopol: the implementation wouldn't be lazy, it'd do it via pattern-matching if needed, but it's a method of thinking
01:45:06 <oklopol> well, tables, hashmaps.
01:45:21 <oklopol> functions
01:45:22 <oklopol> .
01:45:31 <Slereah> Success!
01:45:37 <oklopol> Slereah: good for ya :)
01:45:46 <Slereah> I have made an ASCII-ish code for that BF interpreter.
01:46:08 <oklopol> ehird`_: i'm just saying i'm afraid it's not really a new way of thinking.
01:46:08 <Slereah> Let's try those big BF programs now.
01:46:28 <ehird`_> oklopol: but as the only basis for a language
01:46:31 <ehird`_> oklopol: and it is slightly
01:46:43 <ehird`_> oklopol: but yeah, give me an example program in it... quicksort is a mapping of lists to lists, obviously
01:46:48 <oklopol> at least not to me... done lots of thinking on different ways to specify infinite lists
01:48:03 <oklopol> ehird`_: example program in what?
01:48:12 <ehird`_> qs = [[] = []; [x] = [x]; x:[...,p,...] = stuff]
01:48:14 <ehird`_> note the mapping thing
01:48:19 <ehird`_> have to go in 5 mins
01:48:56 -!- mtve has quit ("Terminated with extreme prejudice - dircproxy 1.0.5").
01:49:08 * oklopol notes
01:50:00 <ehird`_> the question is
01:50:02 <ehird`_> what is stuff
01:50:21 <oklopol> looked interesting how you specified the p there
01:53:11 <ehird`_> oh well, tomorrow i shall define a concise language :P
01:53:20 <ehird`_> specifically, a write-only but productive one
01:53:35 <ehird`_> i.e. you can hack on it easily, but you cannot actually take a definition and look at it properly :P
01:53:52 <oklopol> yeah
02:15:35 <oklopol> ehird`_: i think with my current semantics, quicksort would be /2;A B:C,AB,',JnB
02:16:30 <oklopol> it's not very concise, because i haven't yet made that much splitting facilities, but anyhow, just in case you feel like competing :)
02:17:29 <oklopol> now sleep ->
02:19:50 -!- ehird`_ has changed nick to ehiird|sleeep.
02:19:50 -!- ehiird|sleeep has changed nick to ehird|sleeep.
02:19:59 -!- ehird|sleeep has left (?).
02:20:33 -!- ehirdsleep has joined.
02:24:42 <Slereah> Apparently, the full interpreter works okay, but at turtle speed.
02:29:06 <Slereah> Wish I knew how to optimise code.
02:32:41 <bsmntbombdood> wish i was more stupid
02:35:41 <Slereah> Let's trade!
02:38:57 <oklopol> bsmntbombdood: why?
02:40:35 <bsmntbombdood> dunno
02:41:44 <Slereah> Ah. There's an error in the - instruction.
02:42:15 <Slereah> Let's see if the programs run better!
02:42:49 <oklopol> bsmntbombdood: why?
02:42:53 <oklopol> whoops-.
02:42:54 <oklopol> '/,)#<merge sort
02:42:55 <oklopol> a:B,',\#<A,JnAbubblesort
02:43:01 <Slereah> Yay, the BF quine prints!
02:43:14 <oklopol> /2;A b:C,',JnBquicksort
02:43:25 <oklopol> starting to look a bit like an esolang ;)
02:44:26 <oklopol> oh, actually, bubblesort is ";a:B,',\#<A,JnA" :\ the lang doesn't handle single elements that well
02:44:59 <oklopol> so... the sleeps ->
02:52:03 * Slereah tries the Mandelbrot program
02:52:17 <Slereah> Which is pretty stupid, since it's already slow on a normal BF interpreter.
02:52:42 <pikhq> Oooh! I know! Try it on dbfi!
02:53:32 <Slereah> What, an interpreter on an interpreter on an interpreter?
02:53:44 <Slereah> Are you a fan of recursion by any change?
02:53:58 <Slereah> *ce
02:56:06 <Slereah> I'll just leave the Mandelbrot running his night.
02:56:42 <Slereah> If it works, I think I can say that the interpreter works okay.
02:57:12 <Slereah> ... or!
02:57:42 <Slereah> Maybe I should try Lost Kingdom instead, which IIRC execute faster than Mandelbrot on a usual BF interpreter.
02:58:54 <pikhq> Lost Kingdom, for all it's size, is fairly quick usually.
02:59:59 <Slereah> I assume that it's because, unlike Mandelbrot, the text output without a bajillion other steps before.
03:01:12 <pikhq> Yeah.
03:01:55 <Slereah> See? I only had to wait 2 minutes before it asks me if I want to enable long room descriptions!
03:02:13 <oklopol> all factorials in a list: "1::Il,)&*"
03:02:30 <oklopol> to take one specifically is a bit harder ;)
03:02:54 <oklopol> i can't sleep, this language is hunting me :<
03:02:57 <oklopol> retry ->
03:04:19 <Slereah> In your dream?
03:04:35 <Slereah> Is it some sort of BrainFreddy?
03:09:51 <Slereah> Blah. Either the next step is taking forever, or the input has some problem.
03:21:02 <Slereah> Oh bloody hell.
03:21:09 <Slereah> The CH function prints CH now.
03:21:14 <Slereah> Forgot that exception
03:22:16 <Slereah> ROT13 works okay now!
03:33:57 -!- faxathisia has joined.
03:57:47 -!- Slereah has quit (Read error: 110 (Connection timed out)).
03:58:03 -!- Slereah has joined.
04:30:58 -!- slereah_ has joined.
04:36:31 -!- Slereah has quit (Read error: 110 (Connection timed out)).
04:45:46 -!- slereah_ has changed nick to Slereah.
05:15:00 * pikhq goes into a full-on panic
06:11:29 <bsmntbombdood> ?
06:11:39 <pikhq> No xkcd.
06:12:00 <bsmntbombdood> hrm
07:39:42 <puzzlet> what
07:39:43 -!- calamari has quit ("Leaving").
07:45:09 <bsmntbombdood> no xkcd
07:48:05 -!- Sgeo has joined.
07:48:20 <Sgeo> Hi all
07:48:30 <faxathisia> hi
07:48:46 <Sgeo> pikhq, heads up: The "domain installation check" function probably won't accept arguments
07:48:54 <Sgeo> I'm probably going to change it
07:49:04 <Sgeo> pikhq, how's work on the psox.pebble lib going?
07:50:36 <Sgeo> ok, so pikhq's away
07:59:59 -!- clog has quit (ended).
08:00:00 -!- clog has joined.
08:04:29 * Sgeo monologues
08:04:52 * faxathisia wonders if this is a good idea for language design
08:05:12 <faxathisia> pick a random algorithm and stick it in a while loop -- add syntax
08:16:19 <Sgeo> Hm, it's easy for BF to receive a LBYTES as a STRING and a STRING as an LBYTES, but difficult for the conversion to be performed on the tape..
08:55:52 <Sgeo> Which makes me wonder if I should add a function that just returns whatever was given to it..
08:55:59 <Sgeo> hm, maybe not
08:56:02 <Sgeo> G'night all
09:13:12 -!- oerjan has joined.
09:13:29 -!- Sgeo has quit (Read error: 110 (Connection timed out)).
09:32:49 -!- slereah_ has joined.
09:49:32 -!- Slereah has quit (Read error: 110 (Connection timed out)).
10:35:32 -!- johnl_ has joined.
10:37:08 -!- johnl has quit (Read error: 104 (Connection reset by peer)).
10:43:02 -!- johnl_ has quit (Remote closed the connection).
11:25:25 -!- sebbu has joined.
11:30:02 -!- oerjan has quit ("leaving").
11:37:03 <oklopol> faxathisia: i see you've found the recipe for making perfert esolangs without any effort, we can now bury this chan and go on with our lives :)
11:38:09 <oklopol> also, you weren't here when i did the graphica spec stub, so i'll paste it assuming you don't read the logs.
11:39:34 <oklopol> http://www.vjn.fi/pb/p123363511.txt
11:40:38 <oklopol> not sure if that helps at all, i've been told my bnf sucks ass
11:41:04 <faxathisia> In general BNF kind of stucks
11:41:14 <faxathisia> well actually i'm wrong
11:41:25 <faxathisia> I just personally don't like because it's not execyutable
11:41:36 <oklopol> not executable?
11:42:01 <faxathisia> A lot of times I've seen a languages syntax written in BNF.. then had to write a parser
11:42:08 <faxathisia> wishing I could just run the BNF instead :/
11:43:33 <oklopol> i don't think it'd be hard to automatically make a parser just based on a bnf
11:43:49 <oklopol> don't the parser creator do just that?
11:44:04 <oklopol> yacc or whaddyacallit...
11:44:59 -!- sebbu2 has quit (Read error: 110 (Connection timed out)).
11:45:09 <oklopol> would be interesting to have a language where a bnf would correspond to a logic program describing the parser.
11:45:25 <faxathisia> :o
11:45:27 <oklopol> but, where semantics might actually be more complicated
11:45:41 <faxathisia> maybe you could just define the ::= operator in prolog
11:45:48 <oklopol> :D
11:45:52 <oklopol> that would own
11:45:57 <oklopol> actually...
11:46:20 <oklopol> parsing via bnf is basically just trying a branch and backtracking...
11:46:29 <oklopol> it might actually be simple
11:46:48 <oklopol> i don't actually know prolog that well
11:47:01 <oklopol> now did you read the spec? :-)
11:47:11 <faxathisia> no :p
11:47:12 * faxathisia is now
11:51:04 <oklopol> gotta leave soon
11:51:15 <oklopol> in fact, need to shower in exactly 6 minutes.
11:51:41 * faxathisia thinks implicit nested lisp is very cool
11:52:00 <oklopol> (which always signifies a leave of course, since i rarely shower when i'm alone :P)
11:52:13 <oklopol> yeah, i think the expression syntax is great :o
11:53:16 <oklopol> it's not fully nested lisp, since you can still do stuff like 5+(+ 4-2 5*7)*3
11:53:55 <oklopol> i'm not actually sure whether you can just do infix alone with my current implementation... would be kinda sucky if you couldn't :P
11:54:19 <oklopol> although, the way you're supposed to use that, is by using infix for simple expressions, and sexps for the rest.
11:54:27 <oklopol> oh, right, it's not lisp, just sexp.
11:54:37 <oklopol> there's a term for it
12:03:47 <oklopol> okay, wtf... i have *not* written this code...
12:04:02 <faxathisia> hehe
12:04:14 <oklopol> i was splitting a list by the last occurrence of an element
12:04:20 <oklopol> so...
12:04:36 <oklopol> l.index(reversed(s)), where s was what was used as the pivot
12:04:39 <oklopol> wtf xD
12:05:03 <oklopol> and l was the list to split
12:05:37 <oklopol> it's kinda sad if you can't do that with the built-ins in python :\
12:05:51 <oklopol> i don't know of a way, but then again i don't know much built-ins
12:06:38 <oklopol> in general, i don't understand why there's always so little basic operations like this in the language
12:06:54 <oklopol> there's usually just map, reduce and filter, in some form
12:07:04 <oklopol> and a zip
12:08:32 <oklopol> plus, these are things that help you program, immensely in some cases, but they're very high-level, people will just use a less generic solution if something like that isn't supplied
12:08:58 <oklopol> i feel it's the language disegners duty to add more list support
12:09:05 <oklopol> i'm gonna mail the python people ->
12:09:38 * faxathisia doesn't really know python
12:09:49 <oklopol> "we already have that, in a module, idiot" "hey, no one in their right mind is gonna import a module." *no answer*
12:09:51 <faxathisia> I just feel that I won't learn anything from getting good at python
12:10:22 <oklopol> well, after doing c++, python was a great relief
12:10:33 <faxathisia> I can imagine :p
12:10:42 -!- sebbu has quit (Read error: 113 (No route to host)).
12:10:46 <oklopol> stuff that i actually carefully had to plan and write for days, is trivial in python
12:11:04 <oklopol> stuff that i actually *do* in python, i would never even imagine doing in c++.
12:11:50 <oklopol> you're a haskellor, then?
12:12:00 <oklopol> that might just be a guess
12:12:19 <faxathisia> last program I wrote is in haskell
12:12:38 <faxathisia> I wouldn't say that though, I still haven't found my language :)
12:12:38 <oklopol> what was that?
12:12:47 <faxathisia> implementation of the reversible langauge Janus
12:12:51 <oklopol> ah
12:13:52 <oklopol> haskell gets a bit verbose with side-effectful stuff in my experience
12:13:59 <oklopol> but most likely i just suck.
12:14:41 <oklopol> i should try making something less opengl'y and i might actually learn it
12:15:10 <faxathisia> first thing I did in haskell used OpenGL
12:15:40 <oklopol> or something where i actually have some experience with a language i know... i was doing a circuit drawing program
12:16:12 <oklopol> it gets quite complex if you make it good
12:16:16 <faxathisia> I'm probably totally wrong so I'll phase this differently,
12:16:32 <faxathisia> I just use haskell to write langauges
12:16:37 <faxathisia> since it's great for that
12:16:51 <faxathisia> (I was going to say that's what it's best for but I couldn't really know that)
12:17:27 <oklopol> i've actually found multiple favorite languages, erlang, K and haskell are probably the languages i'd most like to use daily
12:17:39 <oklopol> i've never even *tried* erlang/K though :P
12:17:43 <faxathisia> haha
12:17:58 <faxathisia> I think J is a bit like K.. I liked J a lot
12:18:03 <oklopol> yep
12:18:05 <faxathisia> never actually looked at K
12:19:01 <oklopol> the funny thing is, i don't even like python really...
12:19:08 <oklopol> K owns
12:19:11 -!- Sgeo has joined.
12:19:17 <faxathisia> Me neither ^_^
12:19:23 <oklopol> and i just love erlang
12:19:32 <Sgeo> Hi all
12:19:36 * Sgeo didn't get any sleep
12:19:38 <oklopol> yeah, but i program at least 100 lines of python every day :)
12:19:40 <Sgeo> :(
12:19:58 * Sgeo should update some stuff on the PSOX spec
12:20:00 <oklopol> yesterday some 250
12:20:05 <faxathisia> Have you read the doc about how erlang was conceived (via Prolog)?
12:20:13 <oklopol> nope
12:20:23 <faxathisia> ah.. I'll see if I can find it, this is a great paper
12:20:25 <oklopol> do link, although i'm leaving now ->
12:20:40 <Sgeo> Ok, WHY TF is MemoServ looking like it's replying in #haskell ?
12:21:29 <faxathisia> http://www.erlang.se/publications/prac_appl_prolog.ps
12:21:59 * Sgeo goes to write an example for reading in a STRING and turning it into an LBYTES
12:29:02 -!- Hiato has joined.
12:29:34 <Hiato> Just stopping by for two things: Firstly, everyone, have a great new year! :D
12:30:13 <Hiato> Secondly: Full0.8tt.org is down (for reasons unknown to me) so use http://full0.freehostia.com
12:30:28 <Hiato> anyway, cheers
12:30:39 <Hiato> and have a good new year (if you haven't already ;) )
12:30:45 -!- Hiato has quit (Client Quit).
12:35:03 <Sgeo> +>,[<.>.,].
12:35:16 -!- tejeez has joined.
12:35:22 <Sgeo> Hi tejeez
12:35:23 <Sgeo> +>,[<.>.,].
12:39:39 <Sgeo> And the reverse is: ,[,.,].
12:40:14 <faxathisia> ah I see
12:40:35 <faxathisia> +>,[<.>.,].,[,.,]. = ,[.,]. ?
12:40:46 <faxathisia> er sorry
12:40:50 <faxathisia> of course not..
12:41:01 <faxathisia> I'd need to take the output from one into the other
12:41:16 -!- RedDak has joined.
12:41:28 <oklopol> oh, right, faxathisia: also wanna comment the spec :D
12:41:40 <Sgeo> Note that the ",[,.,]." assumes there are no NULs in the body of the LBYTES. If there are, it can't exactly be turned into a STRING, because STRINGs are NUL-terminated
12:42:09 <oklopol> that was a question.
12:43:08 <faxathisia> oklopol: It seems fine
12:43:19 <oklopol> good.
12:43:43 <oklopol> i'll add lists and suchas in the spec and make it my first esowiki donation
12:44:18 <oklopol> although it's not *that* esoteric
12:49:01 -!- tesseracter has quit (calvino.freenode.net irc.freenode.net).
12:49:01 -!- faxathisia has quit (calvino.freenode.net irc.freenode.net).
12:49:04 -!- puzzlet has quit (calvino.freenode.net irc.freenode.net).
12:49:05 -!- sekhmet has quit (calvino.freenode.net irc.freenode.net).
12:49:05 -!- Possum has quit (calvino.freenode.net irc.freenode.net).
12:49:05 -!- Sgeo has quit (calvino.freenode.net irc.freenode.net).
12:49:06 -!- oklopol has quit (calvino.freenode.net irc.freenode.net).
12:49:06 -!- bsmntbombdood has quit (calvino.freenode.net irc.freenode.net).
12:49:06 -!- GregorR has quit (calvino.freenode.net irc.freenode.net).
12:49:06 -!- cherez has quit (calvino.freenode.net irc.freenode.net).
12:49:08 -!- Overand has quit (calvino.freenode.net irc.freenode.net).
12:49:09 -!- RedDak has quit (calvino.freenode.net irc.freenode.net).
12:49:11 -!- pikhq has quit (calvino.freenode.net irc.freenode.net).
12:49:13 -!- dbc has quit (calvino.freenode.net irc.freenode.net).
12:49:14 -!- cmeme has quit (calvino.freenode.net irc.freenode.net).
12:49:14 -!- slereah_ has quit (calvino.freenode.net irc.freenode.net).
12:49:16 -!- lifthrasiir has quit (calvino.freenode.net irc.freenode.net).
12:49:16 -!- lament has quit (calvino.freenode.net irc.freenode.net).
12:49:16 -!- weilawei has quit (calvino.freenode.net irc.freenode.net).
12:49:16 -!- SimonRC has quit (calvino.freenode.net irc.freenode.net).
12:50:32 -!- Sgeo has joined.
12:50:32 -!- slereah_ has joined.
12:50:32 -!- faxathisia has joined.
12:50:32 -!- oklopol has joined.
12:50:32 -!- puzzlet has joined.
12:50:32 -!- cherez has joined.
12:50:32 -!- bsmntbombdood has joined.
12:50:32 -!- GregorR has joined.
12:50:32 -!- dbc has joined.
12:50:32 -!- tesseracter has joined.
12:50:32 -!- SimonRC has joined.
12:50:32 -!- weilawei has joined.
12:50:32 -!- cmeme has joined.
12:50:32 -!- sekhmet has joined.
12:50:32 -!- lifthrasiir has joined.
12:50:32 -!- Possum has joined.
12:50:32 -!- Overand has joined.
12:50:32 -!- lament has joined.
12:51:09 -!- RedDak has joined.
12:51:09 -!- pikhq has joined.
12:53:46 <Sgeo> re
13:46:14 -!- jix has joined.
13:50:23 <Sgeo> Is (.*?)((?<=(?:[^\x00]|\A)(?:\x00\x00\x00)*)\x00)) an expensive regex?
13:50:24 <Sgeo> Hi jix
13:50:36 * Sgeo isn't even sure if that regex would work
13:50:42 <Sgeo> But it looks expensive :/
13:58:19 <Sgeo> "look-behind requires fixed-width pattern"
14:06:12 * Sgeo comes up with what looks like a much simpler regex
14:06:19 <Sgeo> ((?:[^\x00]|\x00{3})*)(\x00.*)
14:07:36 <Sgeo> ((?:[^\x00]|\x00{3})*)(\x00.*)?
14:07:59 <Sgeo> Nope
14:08:24 <Sgeo> ((?:[^\x00]|\x00{2}.)*)(\x00.*)?
14:09:23 <Sgeo> Close
14:11:42 <Sgeo> ((?:[^\x00]|\x00{2}.?)*)(\x00.*)?
14:11:53 <Sgeo> Since the ? after the . is greedy, that should work
14:11:57 * Sgeo hopes so
14:12:03 <Sgeo> Tests seem to show that it works
14:18:55 * Sgeo changes it to ((?:[^\x00]|\x00{2}(?:.|\Z))*)(\x00.*)?
14:29:44 <Sgeo> Bye all
14:46:23 -!- Slereah has joined.
14:46:51 -!- Sgeo has quit (Read error: 110 (Connection timed out)).
15:03:30 -!- slereah_ has quit (Read error: 110 (Connection timed out)).
15:19:03 -!- jix has quit (Nick collision from services.).
15:19:11 -!- jix has joined.
16:26:44 -!- oerjan has joined.
16:33:22 <Slereah> Oh hell.
16:33:40 <Slereah> One whole night, and the Mandelbrot has barely printed two lines.
16:35:36 <Slereah> Well, they're correct at least.
16:53:44 <faxathisia> What do you mean correct?
16:54:16 <Slereah> Well, the first two lines are the same than the one on any BF interpreter.
16:54:35 <faxathisia> ahh :D
16:54:55 <faxathisia> I thought you were about to have computed the mandelbrot set or something (apprently) impossible like that
16:55:35 <faxathisia> (I never read a proof of that which I understood though, so I can only assume the result is true)
16:56:06 <Slereah> Just the mandelbrot.b program.
17:09:32 -!- slereah_ has joined.
17:20:57 -!- RedDak has quit (Remote closed the connection).
17:27:20 -!- Slereah has quit (Read error: 110 (Connection timed out)).
17:50:53 -!- jix has quit ("Guten Rutsch!").
18:42:11 -!- calamari has joined.
18:49:13 <ehirdsleep> hello
18:49:16 -!- ehirdsleep has changed nick to ehird.
18:55:03 <ehird> bf question: >*N[<*N...code...>*N]<*N is a common idiom, right?
19:16:48 <ehird> oerjan: I think i'd be better off if i formally stated BF syntax then worked from that
19:16:53 <ehird> +-><,. are verbatim
19:17:14 <ehird> [ parses many, recursively, up to the first ] given to it
19:17:19 <ehird> everything else is ignored
19:17:33 <ehird> So.
19:17:44 <ehird> parse :: String -> [BF]
19:17:53 <ehird> parseLoop :: String -> [BF]
19:17:56 <ehird> oerjan: I believe that is correct.
19:18:04 <oerjan> the problem is you were doing the ignoring in the wrong function, basically
19:18:13 <ehird> oerjan: However, that involves the recursion stuff
19:18:26 <ehird> where as you are saying the haskelly way is to return (one, whatsleft) instead of [all]
19:19:16 <oerjan> subparsers need to return what's left for the bigger parser to know where to continue
19:20:07 <ehird> right
19:20:10 <ehird> so
19:20:18 <ehird> parse :: String -> [BF]
19:20:28 <ehird> parseOne :: String -> [(BF, String)]
19:20:33 <oerjan> um no
19:20:40 <ehird> returning only [] or [(one, rest)]
19:20:41 <oerjan> -> ([BF], String)
19:20:47 <ehird> no, parse >ONE<
19:20:48 <oerjan> oh wait
19:20:54 <ehird> and, parseOne "" = []
19:21:03 <ehird> so: parseOne :: String -> [(BF, String)]
19:21:13 <ehird> parseLoop :: String -> [BF]
19:21:15 <oerjan> what about parseOne (']':_) ? >:)
19:21:24 <ehird> no, wait
19:21:29 <ehird> wait. i'll write this down
19:21:56 <oerjan> there is an alternative. -> (Maybe BF, String)
19:22:19 <faxathisia> You could extract the haskell code from http://d.hatena.ne.jp/ku-ma-me/20070813
19:22:29 <ehird> oerjan: isn't Maybe for fails?
19:23:33 <oerjan> sure
19:23:56 <oerjan> and that parseOne "" would be a failure
19:24:09 <ehird> i guess so
19:24:17 <ehird> but it'd be a failure guaranteed to happen every parse :-)
19:24:24 <ehird> http://hpaste.org/4733 this is right
19:24:36 <ehird> hm, should i write it top-down like that?
19:24:40 <ehird> or should i do it down-up
19:24:41 <oerjan> but the subtle point is not _that_ case, but the case " ]..."
19:24:57 <ehird> hm yes
19:25:00 <ehird> since parseLoop will not see it
19:25:11 <ehird> instead parseOne will and signal an error
19:25:15 <ehird> that is puzzling, oerjan.
19:25:26 <faxathisia> something like let bf '<' = [BFBack] ; bf '>' = ... ; _ = bf _ = [] in concatMap bf
19:25:38 <oerjan> the Maybe version works better then
19:25:56 <oerjan> you can return (Nothing, rest) for failure
19:26:10 <ehird> i think my brain is being haskellstretched here
19:26:22 <ehird> BFBack?
19:26:24 <ehird> oh
19:26:25 <ehird> i see
19:26:30 <oerjan> and then parseLoop will know that no command was found, but it might still be that it has reached a ]
19:26:53 <ehird> [19:27:13] <lambdabot> concatMap f = foldr ((++) . f) []
19:26:57 <ehird> i don't think i get that
19:27:07 <ehird> concatMap f lst
19:27:08 <ehird> is
19:27:13 <ehird> map f lst
19:27:17 <ehird> joined together with ++
19:27:19 <ehird> am i right
19:27:22 <faxathisia> concatMap = concat . map
19:27:36 <oerjan> the Prelude definition is just concatMap f l = concat (map f l)
19:27:43 <ehird> wow, a whole 2 keystrokes saved, faxathisia
19:27:47 <oerjan> (report that is)
19:28:06 <oerjan> =<< saves more
19:28:25 <faxathisia> (That is how I'd do it http://rafb.net/p/DnYi0s42.txt )
19:28:42 <faxathisia> (Which is probably horrendously slow or something)
19:28:43 <oerjan> faxathisia: that won't work for loops
19:28:51 <faxathisia> I know
19:28:56 <faxathisia> I only did +-<>
19:29:59 <ehird> uhh i can handle non-loops just fine
19:30:27 <ehird> however, that definition does look quite elegant
19:30:29 <ehird> so i shall expand on it
19:30:29 <oerjan> ehird: that paste looks fine
19:30:49 <oerjan> and i usually do top-down too
19:30:51 <ehird> oerjan: Q: is faxathisia's even capable of handling loops?
19:31:05 <oerjan> a concatMap on single characters? no.
19:31:11 <faxathisia> ehird: No, I only did +-<>
19:31:30 <ehird> oerjan: yes good point :p
19:31:32 <faxathisia> add to data , BFWhile | BFEnd or something
19:31:39 <ehird> faxathisia: that's not parsing
19:31:40 <ehird> that's lexing
19:31:47 <faxathisia> if you want BFLoop [BFStmts]
19:31:50 <ehird> and seperate parsing/lexing is archaic
19:32:06 <faxathisia> then I (personally, though it may not be the best way), you would lex and parse seperately
19:32:14 <faxathisia> s/you //
19:32:28 <faxathisia> what do you mean archaic? I found it to simplify code a lot
19:32:45 <ehird> it's 70s-style
19:32:52 <faxathisia> hehe
19:32:56 <faxathisia> Is that bad?
19:33:04 <ehird> oerjan: http://hpaste.org/4733 parseMany is actually superflous isn't it?
19:33:23 <ehird> since it would not be useful to parseOne or parseLoop, and parse can replace 'outer' usages it might have
19:33:24 <oerjan> should be identical to parseLoop
19:33:28 <ehird> no
19:33:30 <ehird> parseLoop handles ]
19:33:36 <faxathisia> I mean you can always go parse = parseLoop . lex
19:33:49 <ehird> oerjan: parseLoop isn't about haskell loops
19:35:10 <oerjan> i had the idea you could pass a Bool that told if you were inside a loop or not
19:35:15 <oerjan> then you can unify them
19:35:29 <oerjan> and the caller no longer needs to check
19:36:03 <ehird> oh, passing a boolean
19:36:08 <ehird> that's what my scheme code does
19:36:09 <ehird> but..
19:36:13 <ehird> it's kind of unhaskelly.
19:36:16 <ehird> imo.
19:36:18 <ehird> it just looks ugly.
19:36:19 <ehird> parse :: String -> [BF] parse "" = [] parse s = p:(parse s') where (p, s') = parseOne s
19:36:24 <ehird> hmm, pretend that's 3 lines
19:36:43 <ehird> hm wait, i don't check for Maybe BF there
19:36:54 <ehird> wait, that's OK
19:36:59 <ehird> because it'll never occur
19:37:04 <ehird> so parseOne :: String -> (BF, String)
19:37:10 <oerjan> i think it is easier to have parseMany and parseLoop separate then
19:37:22 <oerjan> parseLoop would call parseMany
19:37:32 <ehird> wait, it might
19:37:34 <ehird> I do need Maybe
19:37:38 <oerjan> and itself just do the boundary [ ] checking
19:38:23 <oerjan> note that Maybe is almost the same as my suggestion to parse comment chars into NOPs
19:38:29 <ehird> oerjan: parseMany would see the ] and say 'HAY UNBALANCKD'
19:38:31 <ehird> parse :: String -> [BF] parse s = case parseOne s of (Just p, s') -> p:(parse s') _ -> []
19:38:37 <oerjan> it's just that the NOP is not included in the BF type itself
19:39:34 <oerjan> ehird: the problem with doing that is you duplicate code
19:39:43 <oerjan> instead, let parseMany do no checking
19:39:52 <ehird> oerjan: so how do i choke on unbalanced ]s
19:39:58 <oerjan> and let the caller check the boundaries
19:40:43 <oerjan> parseLoop calls parseMany and checks that the remainder starts with ]
19:40:55 <oerjan> parse calls parseMany and checks that the remainder is empty
19:41:33 <ehird> parseOne ( _ :s) = (Nothing, s)
19:41:35 <ehird> that is right?
19:41:50 <oerjan> um...
19:41:56 <ehird> just asking.
19:42:01 <ehird> otherwise comment handling could f up
19:42:17 <oerjan> you could let parseOne skip comments
19:42:27 <ehird> parseOne ( _ :s) = parseOne s
19:42:38 <ehird> so, the only time i use Nothing is:
19:42:39 <ehird> parseOne "" = (Nothing, "")
19:42:51 <oerjan> also for ]
19:42:59 <oerjan> but only those two
19:43:44 <ehird> ok
19:44:05 <ehird> parseOne ('[':s) =
19:44:22 <oerjan> btw it may be more efficient for parseMany to collect the commands in reverse, tail recursively. Parsec's many uses this trick to avoid stack blowup
19:45:15 <oerjan> ehird: = parseLoop s, essentially
19:45:50 <ehird> KRRR! Wrong!
19:45:55 <ehird> pparseLoop :: String -> ([BF], String)
19:46:00 <ehird> parseOne :: String -> (Maybe BF, String)
19:46:12 <oerjan> hm right a little wrapping needed
19:46:32 <ehird> i don't see how i can stuff [BF] into a Maybe BF
19:46:33 <ehird> :D
19:46:44 <ehird> ergo: my parser architechture is b0rketh! again!
19:46:58 * oerjan hopes you're joking
19:47:44 <oerjan> = let (bfs, s') = parseLoop s in (Just (Loop bfs), s')
19:49:27 <ehird> oh
19:49:28 <ehird> duh
19:49:28 <ehird> of course
19:49:28 <ehird> heh
19:50:04 <ehird> parseOne (']':s) = fail "KRRRRRRRRRRRRRRRRRR!"
19:50:19 <oerjan> er no
19:50:40 <ehird> s/fail/error
19:50:49 <oerjan> especially not that
19:50:55 <ehird> what then
19:51:07 <oerjan> = (Nothing, ']:s)
19:51:15 <oerjan> er, = (Nothing, ']':s)
19:51:46 <ehird> ok, that spirals my current parse into an inf loop
19:51:48 <ehird> :-)
19:51:50 <ehird> parse "]" -> .....
19:52:00 <ehird> (Nothing, s') -> parse s'
19:52:03 <ehird> that's why
19:52:13 <ehird> oerjan: This is where parseMany comes in?
19:52:23 <oerjan> could be
19:52:27 <ehird> :D
19:52:39 <ehird> ok, base case: parseMany "" = ([], "")
19:52:52 <oerjan> fine
19:53:19 <ehird> parseMany s = let (p, s') = parseOne s in p:(parseMany s')
19:53:23 <ehird> + extra checking
19:53:51 <ehird> parseMany s = case parseOne s of
19:54:00 <ehird> (Nothing, ']':_) -> error "KRRRRRRRRRRRRRRR!"
19:54:02 <ehird> right?
19:54:14 <oerjan> no!!!
19:54:18 <ehird> :(
19:54:20 <oerjan> parseMany should _never_ check
19:54:50 <oerjan> it is called both by parse and parseLoop. it does not _know_ whether a ] or end-of-file is allowed
19:54:57 <oerjan> only the caller does
19:55:30 <oerjan> -> ([], ']':_)
19:55:48 <oerjan> er, not quite
19:56:02 <oerjan> whatever actually remains
19:56:30 <ehird> parseMany :: String -> ([BF], String) parseMany "" = ([], "") parseMany s = case parseOne s of (Just p, s') -> let (p', s'') = parseMany s' in (p:p', s'') (Nothing, s') -> ([], s')
19:57:03 <oerjan> yay
19:57:23 <ehird> i remember when type declarations scared me! :-P
19:57:34 <ehird> it was the arg -> arg -> ... -> result, i got that when i got that everything was curried in haskell
19:57:44 -!- pikhq has quit (Read error: 110 (Connection timed out)).
19:58:49 <ehird> oerjan: guess i'd better rework 'parse' for parseMany now
19:58:53 <ehird> oerjan: confuzzling
20:01:48 <ehird> parse :: String -> [BF] parse s = case parseMany s of (p, "") -> p ([], ']':_) -> error "KRRRRRRRRRRRRRRRRRRNK!" ([], _) -> error "wtf"
20:01:54 <ehird> oerjan: i wonder when wtf occurs
20:02:20 <oerjan> hm indeed
20:03:15 <ehird> oh well, time to write parseLoop i guess
20:03:44 <ehird> *Main> parse "+]+<" *** Exception: /Users/ehird/Code/Frainbuck/Frainbuck.hs:(33,10)-(36,35): Non-exhaustive patterns in case
20:03:58 <ehird> that's parse s = case parseMany s of
20:04:14 <oerjan> oh right
20:04:15 <ehird> *Main> parse "+]+<" *** Exception: wtf ([Add 0 1],"]+<")
20:04:21 <ehird> ofc
20:04:25 <oerjan> that first [] should just be _
20:04:28 <ehird> yep
20:04:43 <ehird> now to figure out parseLoop
20:04:57 <ehird> it'll look / a lot/ like parse
20:05:40 -!- pikhq has joined.
20:05:42 <ehird> oerjan: then i'll use some kind of monad to do lines/columns
20:06:43 <oerjan> as you wish
20:10:13 <ehird> oerjan: note to future self. functional parsers are not happy fluffy.
20:11:03 <faxathisia> Parsec makes functional parsers good!
20:11:10 <ehird> yes! but i'm not usinkg parsec
20:12:50 <ehird> oerjan: http://hpaste.org/4734
20:14:04 <oerjan> hm... you don't need the parseMany "" case
20:14:12 <ehird> correct
20:14:39 <ehird> ok, now you teach me about the State monad! or whatveer i'm meant to use here
20:14:41 <ehird> :D
20:15:25 <oerjan> ouch
20:15:36 <ehird> tee hee
20:15:44 * oerjan wants to shout for Cale
20:16:04 <ehird> i have you trap'd
20:16:14 <faxathisia> There is a great doc a bout monad transformers you might use
20:16:18 <oerjan> although you _could_ still use the explicit Int passing from yesterday
20:16:30 <faxathisia> http://uebb.cs.tu-berlin.de/~magr/pub/Transformers.en.html
20:16:55 <ehird> faxathisia: Optimus isPrime
20:17:09 <faxathisia> lol
20:17:25 <ehird> <_<
20:17:33 <ehird> oerjan: not as pretty though
20:17:34 <ehird> :P
20:17:38 <faxathisia> you should consider using state transformer instead of state directly though I think
20:17:57 <faxathisia> cause then you can use IO or whatever inside the middle if you didn't think you needed to before
20:17:59 <ehird> StateTransformer Vehicle Robot
20:18:04 <ehird> ok,. i'll stop with the transformer puns
20:18:59 <oerjan> well as long as you use the overloaded functions changing the monad later is easy
20:19:40 <oerjan> the main work is monadizing the code in the first place...
20:20:32 <ehird> i'm scared
20:28:35 <ehird> oerjan: i must know! :P
20:28:36 <oerjan> ehird: http://hpaste.org/4734#a1
20:28:46 <oerjan> just one function
20:28:59 <ehird> without even looking more it's scary
20:28:59 <ehird> :P
20:29:11 <ehird> anyway, i dont' see how i can plug two ints into that
20:29:15 <ehird> :|
20:29:35 <oerjan> you start by changing to type MM = State (Int,Int)
20:30:13 <oerjan> then your monadic code can use the put/get commands to get the tuple
20:30:28 <oerjan> *to access
20:30:42 <ehird> what does MM stand for?
20:30:43 <ehird> and what would an example parseOne look like?
20:30:55 <oerjan> MyMonad :)
20:31:23 <ehird> groan
20:31:24 <ehird> :P
20:31:32 <oerjan> well without the line/col handling most of the lines would just add a return
20:31:39 <ehird> so what would parseOne look like?
20:31:39 <ehird> i'm betting: ugly
20:31:45 <ehird> with linecol
20:32:14 <oerjan> i think you would want to add a helper function
20:32:24 <ehird> oh dear
20:32:24 <ehird> :P
20:32:37 <oerjan> hm actually...
20:34:56 <oerjan> most of the lines would need to advance the column by 1, so make a helper function for doing that and returning the argument
20:35:27 <ehird> oerjan: do you think this is cleaner than shoving around l and c? :)
20:36:35 <oerjan> well the alternative is adding a lot of extra parameters
20:36:44 <ehird> just l and c
20:36:47 <ehird> that's 2
20:37:52 <ehird> hm
20:37:56 <ehird> addOneColAndSucceed
20:37:58 <ehird> that's an ugly name ;)
20:38:12 <oerjan> yeah a bit long
20:38:28 <oerjan> but anyhow here's how to define it:
20:38:47 <ehird> oh i meant for my parameter passing
20:38:48 <ehird> :|
20:38:53 <ehird> do you think i should use a monad?
20:39:08 <oerjan> addOneColAndSucceed result = do addOneCol; return result
20:39:28 <oerjan> addOneCol = do (l,c) <- get; put (l,c+1)
20:39:48 <ehird> ok fine! i'll go with monads :P
20:39:57 <ehird> hmm, LineColumnMonad?
20:40:01 <ehird> that's a crap name :P
20:40:14 <faxathisia> LineColumnMonad for BF?
20:40:25 <ehird> oerjan: parse is still String -> [BF] right?
20:40:27 <ehird> faxathisia: for error reporting
20:40:30 <oerjan> actually there's a simpler definition:
20:40:39 <oerjan> addOneCol = modify (second (+1))
20:40:40 <faxathisia> oo
20:40:54 <oerjan> though you need import Control.Arrow for second
20:40:55 <ehird> faxathisia: this is meant to be the #1 ideal every-optimization multiple-backend brainfuck compiler :-)
20:40:58 * faxathisia is now confused why you aren't using Parsec
20:40:59 <ehird> we need nice things!
20:41:10 <ehird> because it would report [abc at EOF not the position of the [
20:41:22 <oerjan> yeah i imagined parse would be outside the monads
20:41:24 <ehird> oerjan: how can i import that?
20:41:28 <ehird> should i just import second?
20:41:30 <ehird> or just all of it
20:41:39 <faxathisia> you can annotate your datatypes wityh the column positions
20:41:41 <faxathisia> (with parsec)
20:41:44 <oerjan> import Control.Arrow (second) if you want just that
20:42:29 <ehird> oerjan: got a better name fort aOCAS?
20:42:53 <ehird> also, how do i get the monad implicitly passed to addOneCol?
20:42:56 <ehird> that is, what is their types
20:43:06 <oerjan> addOneCol :: MM ()
20:43:20 <ehird> i see
20:43:21 <oerjan> addOneColAndSucceed :: a -> MM a
20:43:26 <ehird> so i implicitly grab the caller's monad?
20:43:32 <ehird> figuratively
20:43:48 <oerjan> well to be completely general:
20:44:43 <oerjan> addOneCol :: (Num b, MonadState (a,b) m) => m ()
20:44:45 <oerjan> i think
20:45:03 <ehird> i uh think i'll stick to my definition
20:45:04 <ehird> hehehe
20:45:08 <ehird> what's =>
20:45:15 <oerjan> that's the type that would be inferred
20:45:42 <oerjan> => separates class contexts from the type proper
20:45:57 <ehird> oh-kay
20:46:03 <ehird> i have learning to do
20:46:04 <ehird> :-)
20:46:11 <ehird> it's a good thing a bf compiler will be mostly functional
20:48:19 <ehird> oerjan: got a bettter addoM-/andsM-/ name?
20:48:48 <oerjan> hm...
20:48:59 <oerjan> shifting?
20:49:28 <ehird> shiftOneing
20:49:29 <ehird> :P
20:49:33 <ehird> don't think so
20:49:42 <oerjan> advancing?
20:50:10 <ehird> it only advances one though
20:51:47 <oerjan> hm... my idea was that it should be short since you need to add it to all those lines
20:52:09 <ehird> good point
20:52:14 <ehird> advancing it is
20:52:33 <ehird> LineColumnMonad is a bit verbose too
20:52:52 <ehird> (i wouldn't care but most haskell code i've seen has been very concise [but still readable])
20:52:58 <oerjan> and plain advance for the places you just pass a [ or so
20:53:13 <ehird> should you not put spaces in tuple seperators?
20:53:28 <oerjan> er very optional
20:53:38 <ehird> talking about style here
20:54:08 <oerjan> probably
20:54:20 <oerjan> a bit air never hurts
20:55:02 <ehird> probably put them in or probably not
20:55:09 <ehird> 'cause ghci prints them -- and lists -- without spaces
20:55:51 <oerjan> hm right the official show definitions don't use them
20:56:45 <oerjan> but neither does it use newlines...
20:56:54 <ehird> haha, that is a good point
20:57:16 <ehird> oerjan: i'm goign for LineColumnMonad since i cannot think of something smaller
20:57:31 <ehird> Plus I have M-/
20:57:32 <ehird> :-)
20:57:56 <oerjan> very well
20:58:02 <oerjan> hm...
20:58:04 <oerjan> Parser
20:58:23 <ehird> not really a parser monad though
20:58:26 <ehird> it doesn't hold parser stuff
20:58:29 <oerjan> indeed
20:58:48 <oerjan> PosMonad
20:59:59 <ehird> YAEY
21:00:24 <ehird> i'm suprised haskell is implementable, actually
21:00:28 <ehird> let alone compilable
21:00:35 <faxathisia> Why?
21:00:46 <ehird> it's got more 'oh-god-how-can-you-implement-that-sanely' stuff than oklotalk
21:00:49 <ehird> just really powerful stuff
21:01:10 <faxathisia> oh yeah
21:01:16 <faxathisia> lazyness keeps freaking me out
21:01:40 <faxathisia> isInfixOf needle haystack = any (isPrefixOf needle) (tails haystack)
21:01:41 <faxathisia> this is insane
21:02:05 <faxathisia> like in any strict language.. that would be ridiculous
21:02:25 <faxathisia> I think it's got the same complexity as any dynamic programming version you'd do in a strict language though
21:02:35 <ehird> laziness at first made me thought they had intelligent gnomes compiling it
21:02:41 <ehird> 'ah, we need to evaluate just this bit!'
21:02:58 <ehird> in a particle accellerator, which is why its' fast :-)
21:03:08 <oerjan> complete laziness isn't that hard
21:03:14 <ehird> yeah
21:03:23 <ehird> but it appears it, before you study it low-level
21:03:36 <ehird> i.e. continuations are 'WTF' until you just think: 'copy of the call stack'
21:05:52 <ehird> do advance; return x
21:05:56 <ehird> is there a nicer way of writing that?
21:05:59 <ehird> i.e. without the ; :-)
21:06:03 <ehird> well, without adding a new line
21:06:08 <ehird> because that just makes it very thin
21:06:17 <faxathisia> @undo do advance; return x
21:06:21 <oerjan> advance >> return x
21:06:30 <ehird> @help
21:06:36 <ehird> oerjan is a cyborg lambdabot!
21:06:41 <oerjan> I AM NOT LAMBDABOT
21:06:46 <oerjan> that was pure coincidence
21:06:50 <faxathisia> lol!
21:06:52 <ehird> suuuure
21:06:52 <ehird> CYBORG
21:09:19 <ehird> oerjan: i never need advance on its own
21:09:25 <ehird> so i'm refactoring it into advancing
21:09:36 <ehird> wait, did i just say refactoring when talking abotu haskell
21:09:40 <ehird> please forgive me
21:09:46 <oerjan> no need
21:09:53 <faxathisia> uh haskell is great when you refactor
21:09:56 <ehird> no need for what
21:10:01 <ehird> faxathisia: yes, but the terminology :-)
21:10:05 <oerjan> for forgiveness
21:10:15 <faxathisia> Haskell is in fact, 100% Enterprise Ready
21:10:19 <oerjan> i think Philippa used it just earlier today
21:10:26 * ehird tries and figures out where 'where' should go to satisfy the compiler's rules
21:10:34 <oerjan> well someone on #haskell did
21:10:38 <faxathisia> I usually use 2 spaces but I'm probably weird
21:10:45 <faxathisia> well I wrote a brainfuck parser anyway, would you like to see it?
21:10:50 <faxathisia> (It's kind of stupid)
21:10:54 <ehird> Forthers say 'factoring' because forth is so awesome they only ever have to do it once! ;)
21:11:00 <ehird> faxathisia: maybe.
21:12:13 <ehird> so, oerjan, how do i retrieve (line, col)?
21:12:18 <oerjan> get
21:12:22 <ehird> yaey
21:12:27 <oerjan> (line, col) <- get
21:13:39 * oerjan thinks ehird must have used monadic (probably IO) code before, things seem to go easier than he expected
21:14:03 <ehird> eh, i've used it for the toy read-line-then-print-one stuff in YAHT
21:14:08 <ehird> so i was familiar with the basic syntax
21:14:15 <ehird> but i didn't have trouble in the first place :-)_
21:14:42 <oerjan> i guess that syntax may somehow be the _most_ familiar part of haskell to some
21:14:42 <ehird> http://hpaste.org/4735 my error message generating code is fugly :)
21:14:57 <ehird> i should have a reportError function
21:15:00 <ehird> so i would do:
21:15:05 <ehird> reportError "Unmatched ["
21:15:08 <ehird> and it would add that stuff
21:15:48 <oerjan> indeed, so just take that do expression and refactor it :)
21:15:54 <ehird> say, oerjan, if parseMany returns monad stuff, how do I wrap it out of that in parse?
21:16:27 <oerjan> right. that is Monad specific
21:16:49 <oerjan> in this case, runState or evalState
21:16:58 <ehird> i'm, uh, excited
21:16:58 <ehird> which
21:16:58 <ehird> :P
21:17:17 <oerjan> depends on whether you need the line/col at the end
21:17:24 <oerjan> well you probably shouldn't
21:17:25 <ehird> nope, not right now
21:17:27 <oerjan> so evalState
21:17:42 <ehird> evalState (parseMany s) -> tuple?
21:17:53 <oerjan> drop the parens
21:18:05 <oerjan> oh wait no
21:18:14 <oerjan> i mean add the initial (line, col)
21:18:20 <ehird> hey, i'm using monads now - so i can use 'fail'
21:18:22 <ehird> right?
21:18:24 <ehird> in reportError
21:18:25 <oerjan> indeed
21:18:28 <ehird> although, parse uses fail
21:18:34 <faxathisia> Wouldn't use throwError?
21:18:39 <ehird> can i partly use monads in a function?
21:18:44 <ehird> and then return an unwrapped value
21:18:51 <oerjan> throwError doesn't take a String
21:18:52 <ehird> faxathisia: ? why
21:19:03 <faxathisia> oh I'm sorry
21:19:04 <ehird> i mean, it's failure if there are unmatched []s
21:19:08 <oerjan> fail = throwError . strMsg for most error monads
21:19:10 <ehird> not something you can recover from or anyting
21:20:13 <oerjan> sure some monads can be unwrapped
21:20:18 <oerjan> like State
21:20:22 <ehird> yaey
21:20:40 <ehird> so if i have some code with fail calls etc in and then want to unwrap the state and return that, what's my approximate skeleton?
21:21:10 <oerjan> um what do you mean, fail is monadic
21:21:13 <ehird> yes
21:21:19 <ehird> what i'm saying is
21:21:26 <ehird> 'parse' ,the top-level parsing function
21:21:33 <ehird> you said would just return [BF] probably, outside of the monads
21:21:41 <oerjan> if you want it to
21:21:42 <ehird> but it does the unmatched-] checking
21:21:52 <ehird> which will use my reportError
21:21:54 <ehird> which will use fail...
21:22:08 <oerjan> yep so do that checking still inside the monad i guess
21:22:28 <ehird> so what would my code skeleton look like?
21:22:32 <oerjan> hm...
21:23:14 <ehird> (to mirror fail, i have reportError :: PosMonad => String -> PosMonad a -- that is right?)
21:23:37 <oerjan> parse s = flip evalState (1,1) $ do (p,s) <- parseMany
21:24:09 <ehird> oerjan: now THAT is haskell
21:24:22 <ehird> but where's my 'case' to handle errors
21:24:22 <ehird> :-)
21:24:28 <oerjan> case s of (_, "") -> return p
21:24:46 <oerjan> argh
21:24:55 <oerjan> case s of "" -> return p
21:25:08 <ehird> right i get it now
21:25:36 <ehird> grr, i do hate 80-columns
21:25:40 <oerjan> i just used the flip to avoid putting the whole do in parentheses :)
21:26:07 <ehird> the worst part of being over 80 columns:
21:26:11 <ehird> i'm only 1 over
21:26:22 <oerjan> well you can shrink the width
21:26:23 <ehird> this is the problem with off-side languages :P
21:26:42 <ehird> ofc why i'm sticking to such an archaic limit nobody knows
21:26:53 <oerjan> the do doesn't need to be on the same line as $
21:27:09 <ehird> good point
21:27:17 * faxathisia usually sticks the $ directly under the =
21:27:22 <ehird> there, that's nice
21:27:26 <oerjan> (actually there are many ways of rearranging it)
21:27:58 <ehird> The last statement in a 'do' construct must be an expression
21:28:04 <ehird> blargifarg
21:28:15 <ehird> that's from
21:28:17 <ehird> oh
21:28:17 <faxathisia> How about, return $ case s of "" -> p
21:28:18 <ehird> my indentation
21:28:24 <ehird> off by ONE
21:28:32 <oerjan> faxathisia: he want fail inside the case
21:28:34 <ehird> faxathisia: can't, need that unwrapping stuff
21:28:36 <oerjan> *wants
21:28:42 <faxathisia> WHich fail?
21:28:48 <ehird> well, syntax
21:28:49 <oerjan> for the other option
21:28:49 <ehird> err
21:28:52 <ehird> parseError
21:28:53 <ehird> :-)
21:28:57 <faxathisia> oh I didn't know there wa snothe
21:28:58 <ehird> whcih uses fail
21:29:24 <oerjan> i didn't finish the function because ehird said he got the rest
21:29:24 <ehird> now to figure out parseOne ('\n':s) =
21:29:27 <ehird> oh, that's simple
21:29:44 <ehird> modify (first (+1)) :-)
21:29:53 <oerjan> er not quite
21:30:00 <oerjan> you also want to reset the column
21:30:10 <ehird> err, ok
21:30:11 <ehird> yes
21:30:12 <ehird> :-)
21:30:17 <oerjan> modify (\(l,_) -> (l+1,1))
21:30:32 <oerjan> or wait...
21:30:33 <ehird> wow, er, that's impressive.. i didn't know you could patternmatch lambdas
21:30:39 <ehird> oklopol: you'd like that!
21:30:49 <oerjan> modify ((+1) *** const 1)
21:30:57 <ehird> damn
21:30:59 <ehird> what's ***
21:31:00 <oerjan> if you like the arrow operators :)
21:31:16 <oerjan> another Control.Arrow thing
21:31:21 <ehird> qwiz:
21:31:28 <ehird> parseOne ('\n':s) = do modify ((+1) *** const 1); return (parseOne s)
21:31:31 <ehird> remove the ;
21:31:35 <ehird> let me try...
21:31:37 <oerjan> f *** g = first f >>> second g by default
21:31:55 <ehird> parseOne ('\n':s) = modify ((+1) *** const 1) >> parseOne s
21:32:12 <ehird> er, return (parseOne s)
21:32:13 <oerjan> JACKPOT
21:32:42 <ehird> Not in scope: type constructor or class `State'
21:32:44 <ehird> ono
21:32:49 <ehird> what do i need to import? :P
21:33:15 <ehird> hm, i wonder if ghc can tell me
21:33:29 <ehird> eh i'll guess
21:33:31 <ehird> Control.Monad.State
21:33:40 <oerjan> YOU WIN AGAIN
21:33:43 <ehird> :D
21:34:15 <oerjan> although lambdabot's @hoogle and @index would also work
21:34:16 <ehird> Type constructor `PosMonad' used as a class In the type `(PosMonad m) => String -> m a'
21:34:21 <ehird> i guess i need Monad m, right?
21:34:28 <oerjan> no
21:34:29 <ehird> (for parseError, i based it on fail's type)
21:34:38 <oerjan> ok maybe
21:34:58 <ehird> heh
21:35:08 <ehird> i was just trying to make it PosMonad only
21:35:11 <ehird> since it retrieves line,col
21:35:27 <oerjan> that would be just String -> PosMonad a
21:35:29 <ehird> ah
21:35:33 <ehird> thank you
21:35:33 <ehird> :P
21:36:11 <oerjan> you also should have the option of using :t to ask what ghc infers as its type
21:36:32 <oerjan> (remove any declaration first)
21:36:59 <ehird> hm:
21:37:01 <ehird> _ -> parseError "Unmatched ["
21:37:03 <ehird> gives me
21:37:04 <ehird> Parse error in pattern
21:37:12 <oerjan> heh
21:37:22 <ehird> previous 2 lines:
21:37:25 <ehird> parseLoop s = do (p, s') <- parseMany s
21:37:25 <ehird> case s' of ']':s'' -> return (p, s'')
21:37:32 <ehird> with correct indentation
21:37:32 <ehird> heh
21:38:09 <oerjan> and _ is directly under ']' ?
21:38:15 <oerjan> (the ' that is)
21:39:01 <ehird> bastard
21:39:03 <ehird> one character off
21:39:19 <ehird> there should be a haskell-blinkenlights-mode
21:39:24 <ehird> that blinks red things like that
21:40:12 <ehird> Couldn't match expected type `(Maybe BF, String)' against inferred type `PosMonad (Maybe BF, String)' In the first argument of `return', namely `(parseOne s)'
21:40:18 <ehird> talking about:
21:40:19 <ehird> parseOne ('\n':s) = modify ((+1) *** const 1) >> return (parseOne s)
21:40:29 <oerjan> oh. drop the return
21:40:57 <ehird> i did
21:40:59 <oerjan> parseOne is already monadic
21:41:07 <ehird> oh
21:41:09 <ehird> then it gives me
21:41:14 <ehird> another error ,tjat looks the same
21:41:14 <ehird> doh :-)
21:41:22 <ehird> parseOne (_:s) = advancing (parseOne s)
21:41:27 <ehird> obviously i need some kind of trick here
21:41:47 <oerjan> advancing () >> parseOne s
21:41:57 <oerjan> you needed advance anyhow :)
21:42:33 <ehird> oerjan: no use of advance there
21:42:42 <oerjan> advance = advancing ()
21:42:48 <oerjan> essentially
21:42:52 <ehird> ah, good point
21:42:53 <ehird> ok then
21:43:17 <ehird> Loading package mtl-1.0 ... linking ... done.
21:43:20 <ehird> WHAT DID IT DO THERE :O
21:43:35 <oerjan> monad transformer library
21:43:41 <ehird> :O
21:43:43 <oerjan> includes Control.Monad.State
21:43:45 <ehird> anyway, my parser works brilliantly
21:43:54 <oerjan> yay
21:44:20 <ehird> a clear, monadic-error-handling, 43 line brainfuck parser in nice-looking haskell
21:44:29 <ehird> it should be required reading
21:44:29 <ehird> :P
21:44:35 <faxathisia> ah well you've really beaten me
21:44:39 <ehird> well, this line looks a bit ugly:
21:44:41 <faxathisia> Let's see?
21:44:43 <ehird> fail (x ++ " at line " ++ (show line) ++ ", column " ++
21:44:44 <ehird> (show col) ++ ".")
21:44:49 <ehird> because of the (show col) ... line
21:44:52 <ehird> ok, faxathisia
21:45:00 <ehird> i'll jsut paste ll my current code
21:45:05 <oerjan> you don't need the parentheses around (show col)
21:45:26 <oerjan> and you can replace the ones after fail with $
21:45:50 <ehird> what about show line
21:45:52 <ehird> are its parens needed?
21:45:57 <oerjan> no
21:46:22 <ehird> ok then
21:46:26 <ehird> http://hpaste.org/4739
21:46:31 <ehird> note, i didn't count lines before "type PosMonad = ..."
21:46:35 <ehird> since that's the parser bit
21:49:09 <oerjan> oh wait
21:49:31 <faxathisia> it ends early?
21:49:32 <faxathisia> parseError "Unmatched ["
21:49:47 <ehird> nope
21:49:52 <ehird> that's the whole parser
21:50:14 <oerjan> there are still some errors in the line/col handling
21:50:20 <ehird> yes oerjan
21:50:25 <ehird> *Main> parse "]" *** Exception: Unmatched ] at line 1, column 2.
21:50:37 <faxathisia> shall I annotate mine?
21:50:37 <ehird> this is because i advance while still doing ']':s
21:50:42 <ehird> i just need to replace advancing with return
21:50:45 <ehird> faxathisia: sure
21:50:52 <oerjan> right that's the first error
21:51:00 <ehird> the other?
21:51:14 <faxathisia> http://hpaste.org/4739#a1
21:51:20 <oerjan> actually...
21:51:33 <oerjan> you are failing to advance on [ where you should
21:51:42 <ehird> __ = __ -- This entire file is sort of stupid
21:51:45 <ehird> what the HELL is that, faxathisia
21:51:48 <ehird> it scares me
21:51:51 <ehird> i think it's supposed to
21:51:52 <faxathisia> lol
21:51:57 <ehird> also jeez
21:52:05 <faxathisia> *Main> :t let __ = __ in __
21:52:06 <faxathisia> let __ = __ in __ :: t
21:52:11 <ehird> your code looks like what someone who saw yacc output tried to write in a cleaner form in haskell
21:52:26 <ehird> oh jeez you use parsec
21:52:57 <ehird> also mine has more optimization slots in the types
21:52:58 <ehird> :P
21:53:09 <faxathisia> Mine doesn't even optimize correctly
21:53:15 <faxathisia> It does a half assed job and gives up
21:53:28 <ehird> mine does no optimization... just is possible to
21:53:33 <ehird> i'm going to write a backend first, THEN optimize
21:54:07 <oerjan> ehird: in the loop code you don't advance on [ and ]. moreover i think the unmatched error will give the end-of-file position
21:54:08 <ehird> oerjan: for various section headers of my compiler, should i use {- Optimization -}?
21:54:11 <ehird> i.e. multiline comment
21:54:22 <oerjan> why not
21:54:30 <ehird> you are right about the unmatched EOF
21:54:31 <ehird> :(
21:54:46 <ehird> parseError needs to take params
21:55:02 <ehird> actually
21:55:07 <ehird> how do i remember the position in the first place
21:55:10 <ehird> :| shit
21:55:23 <oerjan> with get
21:55:34 <ehird> oh. yes.
21:55:39 <ehird> i need to do it in parseOne though
21:55:41 <ehird> otherwise i'd have to -1
21:55:47 <oerjan> hm?
21:55:53 <ehird> wait, no
21:55:54 <ehird> you are right
21:56:02 <ehird> blargh, parseLoop needs to call advance
21:56:21 <ehird> golly, 'do advance\nstuff' looks ugly :-)
21:56:42 <ehird> parseLoop s (PosMonad (l, c)) -- right?
21:56:50 <ehird> called as parseLoop s get
21:57:11 <oerjan> huh?
21:57:35 <oerjan> no
21:58:18 <oerjan> just do the get inside parseLoop i think
21:58:32 <ehird> oh, right
22:02:37 <ehird> oerjan: faxathisia: http://hpaste.org/4724#a1 all good
22:02:42 <ehird> apart from the 'advance' line on its own
22:02:47 <ehird> doesn't look very good
22:02:47 <ehird> :P
22:04:19 <oerjan> well you can sneak it before parseMany with >>
22:04:26 <oerjan> assuming you still don't like ;'s
22:04:52 <ehird> that's actually a good idea
22:05:01 <ehird> since i am getting the result of an advance-parse
22:05:02 <ehird> or something
22:05:06 <oerjan> i think you still have one advance too little
22:05:11 <oerjan> for the final ]
22:05:21 <ehird> yep
22:05:25 <ehird> *Main> parse "[][" *** Exception: Unmatched [ at line 1, column 2.
22:05:36 <ehird> fixed
22:06:12 <ehird> oerjan: http://hpaste.org/4724#a2 tada
22:06:20 <ehird> i really like that code
22:06:29 <ehird> it's the cleanest code i've ever written, methinks :P
22:06:33 <ehird> i like haskell, i think
22:07:55 <ehird> oerjan: for the backend stuff
22:08:07 <ehird> i'm going to make a: Target String, type
22:08:11 <ehird> and write things like
22:08:21 <ehird> compile (Target "C") p = ...
22:08:30 <ehird> compile (Target "i386") p = ...
22:08:33 <ehird> or is that yuck :P
22:09:00 <oerjan> oh not necessarily
22:09:16 <oerjan> some people would even define datatypes for Line and Col
22:09:39 <oerjan> prevents them being mixed up with other kinds of Ints
22:09:47 <oerjan> or each other
22:09:49 <ehird> yeah, i think that's not very important
22:09:57 <ehird> i was just thinking about Target only having a string
22:10:01 <ehird> instead of like
22:10:06 <ehird> data Target = C | I386
22:10:07 <ehird> or something
22:10:15 <ehird> maybe the latter would be preferable
22:10:16 <faxathisia> That seems better
22:10:27 <faxathisia> you don't have to go compile (Target _) = error
22:11:02 <oerjan> class Target a where ...; instance Target C where... :)
22:11:10 <ehird> haha, oerjan wins i think
22:11:46 <ehird> oerjan: is there a haskell command-line option parsing lib?
22:11:52 <oerjan> that allows the code for a given target to be kept together
22:12:00 <oerjan> yes
22:12:08 <oerjan> System.Console.GetOpt, iirc
22:12:23 <ehird> is it anything like gnu getopt? SAY NO :P
22:12:35 <faxathisia> based on..
22:12:41 <ehird> faxathisia: aieeeeee
22:12:50 <oerjan> "This library provides facilities for parsing the command-line options in a standalone program. It is essentially a Haskell port of the GNU getopt library."
22:12:51 <faxathisia> it seems to work ok though
22:12:58 <ehird> how cRUEL
22:13:16 <ehird> oh wow that example is ugly :|
22:13:30 <oerjan> you also have getArgs for doing it your own way :)
22:13:42 <ehird> oerjan: yes, but option parsing is non-trivial :P
22:13:45 <ehird> --longarg=x
22:13:47 <ehird> --longarg x
22:13:51 <ehird> -s x
22:13:53 <ehird> -sx
22:13:53 <ehird> etc
22:14:01 <ehird> -- --literal
22:14:06 <ehird> - --also-literal
22:14:40 <oerjan> that sounds like "option parsing is non-trivial if you want to be GNU-compatible, and I hate GNU, so I want that"
22:14:50 <ehird> haha
22:14:57 <ehird> well, gnu long options can be useful :|
22:15:03 <ehird> i just hate gnu getopt's C interface!
22:15:03 <ehird> it's horrid
22:15:13 <ehird> admittedly though if i use an option a lot i use its short form 100%
22:15:24 <ehird> really i'll only have two options
22:15:29 <ehird> --arch and --output
22:15:31 <ehird> aka -a and -o
22:15:43 <oerjan> oh well the haskell interface may be different
22:15:55 <ehird> looked a bit crazy
22:15:55 <ehird> but OK
22:16:09 <ehird> hm, damn: i will need to write a mapping of name->class
22:16:23 <ehird> oerjan: hashtable/map/whatever String->uh...ClassClass
22:16:26 <ehird> er
22:16:27 <ehird> InstanceClass
22:16:28 <ehird> :-)
22:16:30 <ehird> no wait
22:16:32 <ehird> String->Target
22:16:33 <ehird> i think.
22:16:42 <ehird> what's the shortest syntax to create one? i don't know of any
22:17:05 <faxathisia> deriving Read -- I guess
22:17:25 * oerjan points at Data.Map
22:17:37 <ehird> actually
22:17:40 <ehird> shouldn't i just do
22:17:46 <ehird> targetFor "c" = C
22:17:49 <faxathisia> Yes
22:17:50 <oerjan> hm oh that may be awkward for classes
22:17:53 <ehird> targetFor "i386" = I386
22:17:53 <faxathisia> but that's not the shortest :p
22:18:00 <ehird> faxathisia: i can do a case
22:18:07 <ehird> targetFor n = case n of
22:18:16 <faxathisia> what you just wrote is better than a case imo
22:18:44 <ehird> i guess, but it's not really pattern matching is it? so maybe it's not appropriate(oerjan?)
22:18:53 <faxathisia> it is pattern matching
22:18:53 <ehird> hmm, /me wonders how to downcase a string
22:19:00 <ehird> targetFor "C" == targetFor "c" :-)
22:19:07 <oerjan> map toLower
22:19:21 <oerjan> (Data.Char)
22:19:26 <ehird> oerjan: for that i do need a case don't i
22:19:30 <ehird> i can't do that in a pattern match
22:19:32 <ehird> without a guard
22:19:33 <faxathisia> It's a nested pattern match like Cons 'i' (Cons '3' (Cons '8' (Cons '6' Nil)))
22:20:13 <ehird> targetFor :: String -> Either String Target -- that's right if i want to return a "Unknown target", yes?
22:20:18 <oerjan> lookup (map toLower t) [("c",C),etc.]
22:20:28 <oerjan> using a list
22:20:30 <faxathisia> Unknown String
22:20:33 <ehird> hm
22:20:35 <faxathisia> in your data ?
22:20:36 <ehird> a case seems nicer to me
22:20:45 <ehird> faxathisia: huh?
22:21:32 <oerjan> Either is fine
22:21:45 <oerjan> indeed it's a monad, with fail = Left
22:21:57 <ehird> Hm you know I'll just use 'fail'
22:21:59 <ehird> much simpler
22:22:00 <ehird> :P
22:22:05 <ehird> Hmm
22:22:09 <ehird> But what monad would that be!
22:22:17 <ehird> ANd why is a function called targetFor being monadic!
22:22:24 <ehird> Much better:
22:22:27 <ehird> Maybe Target
22:22:33 <ehird> OK so maybe is a monad
22:22:36 <ehird> :< but hey
22:22:38 <oerjan> Maybe is a monad too, with fail = const Nothing :D
22:22:54 <faxathisia> data Target = C | I386 | Unknown String
22:23:02 <ehird> faxathisia: ew, no
22:23:02 <faxathisia> but I would just error .. I mean what else are you going to do ?
22:23:10 <ehird> targetFor :: String -> Maybe Target
22:23:14 <faxathisia> why is that ew but Maybe isn?T
22:23:14 <ehird> targetFor n = case map toLower n of
22:23:18 <ehird> "c" -> Just C
22:23:19 <ehird> _ -> Nothing
22:23:26 <ehird> faxathisia: eh, because it's not about the type
22:23:27 <faxathisia> I would make it targetFor :: String -> Target
22:23:28 <ehird> it's about the function
22:24:23 <oerjan> Maybe is fine
22:25:29 <ehird> oerjan: class Target a where
22:25:34 <ehird> do i put my type declarations in there?
22:29:45 <ehird> :|
22:29:54 <oerjan> um
22:30:23 <oerjan> no, method declarations
22:30:42 <ehird> ok, you lost me
22:30:53 <ehird> i know haskell's class/method/instance isn't real OOP, it just shares the names
22:30:55 <ehird> so: do explain
22:31:41 <oerjan> class Target a should declare the types of the functions that every instance of Target needs to define
22:31:53 <oerjan> oh, i may have misunderstood you
22:32:19 <oerjan> it's similar to Java interfaces
22:32:41 <ehird> java, don't say that in front of me
22:32:45 <ehird> however, i get your point
22:33:06 <ehird> i don't /quite/ see ow i'm going to distinguish between different target's functions thoiugh
22:33:09 <faxathisia> You don't like Java???
22:33:25 <oerjan> you may use data instead if you like
22:33:48 <oerjan> the difference is how the definitions for each target are grouped
22:33:55 <oerjan> (well, one difference)
22:34:20 <oerjan> with data, each function must be defined together, for all its targets
22:34:48 <oerjan> with class, each target must be defined together, with all its functions
22:35:03 <ehird> i think perhaps i need an example
22:35:04 <ehird> :-)
22:35:18 <oerjan> ouch
22:36:02 <ehird> haha
22:36:04 <ehird> i am evil
22:36:15 <oerjan> well, like that compile function you had
22:36:34 <oerjan> with data, you would define cases:
22:36:50 <oerjan> compile C prog = ...
22:37:13 <oerjan> compile I386 prog = ...
22:37:17 <oerjan> all together
22:37:32 <ehird> ys
22:37:33 <ehird> yes
22:37:39 <oerjan> hm wait
22:37:58 <ehird> oerjan: ooh, one thing..
22:38:06 <ehird> is Char a unicode char?
22:38:09 <oerjan> yes
22:38:29 <ehird> because the C backend could be outputting unicode C (which is a Good Thing)... but an i386 backend needs binary!
22:38:30 <oerjan> but most I/O functions truncate to 8 bits
22:38:33 <ehird> So how should I define that in Target?
22:39:09 <oerjan> an encoding method perhaps?
22:40:02 <ehird> confuzzled
22:40:36 <oerjan> i think maybe data is simpler for a start
22:41:09 <ehird> aww
22:41:14 <ehird> but class is nicer looking :P
22:41:32 <ehird> a backend will always be generating either a tring or a binary string
22:41:39 <ehird> i just need to encode that in compile's type
22:43:02 <oerjan> encoding :: a -> String -> String
22:43:12 <oerjan> where a is the class parameter
22:43:13 <ehird> hmm
22:43:14 <ehird> what does that do
22:43:29 <ehird> shouldn't it be "compile"
22:43:33 <ehird> wait, what DOES that do
22:43:35 <ehird> what is 'encoding'
22:43:59 <oerjan> a final pass that encodes the String if necessary
22:45:03 <oerjan> excuse me, i'll be going out to watch the fireworks
22:45:08 <ehird> is there a binary string type in haskell?
22:45:09 <oerjan> back in a while
22:45:14 <ehird> hmm, wait, it should just be [Byte]
22:45:18 <ehird> assuming haskell has [Byte]
22:45:45 <oerjan> actually Char is used for most simple I/O. for bigger things there is ByteString
22:46:02 <oerjan> which is not actually a list type, and extremely optimized
22:46:13 <oerjan> cu
22:47:38 <ehird> bye :-)
22:54:42 <SimonRC> so, where's this code that isbeing disgust
22:54:47 <SimonRC> *discussed
22:54:52 <SimonRC> *cussed
22:54:54 <SimonRC> ;-)
22:55:21 <ehird> in an emacs buffer
22:55:23 <ehird> pointing to a file
22:56:26 <SimonRC> right, so HTF are people looking at it?
22:57:17 <ehird> SimonRC: my various pastes in here and to hpaste
22:58:00 * oerjan decides fireworks are highly overrated anyhow, especially when you've neglected to eat in advance
22:58:42 <ehird> oerjan: write a haskell/libcaca (Are there bindings?) ascii-art-fireworks program
22:58:45 <ehird> :P
22:58:55 <ehird> generate the sounds algorithmically
22:59:12 <ehird> only thing is by the time you can run it it'll be too late for fireworks...
22:59:17 -!- pikhq_ has joined.
22:59:41 <SimonRC> ehird: I think that even foru your program it is worth using Parsec
22:59:56 <ehird> SimonRC: it's already working 100% perfectly
23:00:02 <ehird> and parsec would report unmatched [s at EOF
23:00:03 <SimonRC> for clarity etc
23:00:06 <ehird> not at the line/col of the [
23:00:16 <ehird> mine is perfectly ok looking :P
23:00:20 <SimonRC> actually, you can make it work either way
23:00:26 <ehird> meh, whatever
23:00:28 * oerjan still thinks you could fool parsec with try ... <|> ... somehow
23:00:28 <ehird> it's done now.
23:00:46 <ehird> Question: is there an unwords that instead does newlines?
23:00:59 <oerjan> unlines
23:01:06 <oerjan> strangely enough :D
23:01:16 <oerjan> HAPPY NEW YEAR!!!!!!!!!!!!!!!!!!!!!!!
23:01:34 -!- ehird has left (?).
23:01:42 -!- ehird has joined.
23:01:46 <SimonRC> I spy a Scandanavian
23:01:55 <oerjan> where?
23:01:56 -!- pikhq has quit (Nick collision from services.).
23:01:59 -!- pikhq_ has changed nick to pikhq.
23:02:00 <oerjan> you cannot prove it!
23:02:03 <SimonRC> oerjan: you, surely?
23:02:07 <oerjan> i could be - south african!
23:02:08 -!- ehird has changed nick to ehird`.
23:02:16 <ehird`> it is just that,
23:02:22 <ehird`> my c header etc
23:02:23 <SimonRC> only people from wierd places like Scandanavia use TZ+0100 at this time of year
23:02:28 <ehird`> is multiple lines, and having \ns in one long line
23:02:30 <ehird`> o using ++
23:02:32 <ehird`> would be ugly :-)
23:02:49 <oerjan> you mean SA is on daylight saving?
23:03:08 <oerjan> what?
23:03:19 <oerjan> we don't have daylight saving here
23:03:20 <SimonRC> everyone on the net that is not American is Britsh or Scandanavian
23:03:22 <oerjan> now
23:03:24 <SimonRC> there are no others!
23:03:40 <SimonRC> :roll:
23:03:50 <ehird`> question
23:03:58 <ehird`> is it possible to 'save myself' from sigsegv in a c program?
23:04:07 <ehird`> i'm considering expanding the tape on segfaults :-)
23:04:15 <ehird`> which should be more efficient than checking every move
23:05:04 -!- pikhq has quit ("leaving").
23:05:18 <ehird`> i know you can trap sigsegv
23:05:21 <oerjan> oh and btw it's scand-I-navian
23:05:23 <ehird`> but can you break back out of the handler to the program?
23:06:16 -!- pikhq has joined.
23:06:19 <SimonRC> hmm
23:07:03 <ehird`> (because if so, that would be FREAKIN' AWESOME)
23:07:08 <ehird`> and the C code should be /really damn fast/
23:07:17 <ehird`> whcih is the idea!
23:08:12 <SimonRC> I am told that gdb can do it
23:08:21 <ehird`> i'm not gdb
23:08:24 <ehird`> :P
23:08:26 <oerjan> hm actually are you guaranteed that the sigsegv happens exactly when you go beyond the array boundary? what if you instead scramble malloc data first?
23:08:30 <ehird`> anyway gdb does crazy asm stuff
23:08:31 <SimonRC> maybe grep the gdb sources for "SIGSEGV"
23:08:41 <ehird`> oerjan: hmm, i didn't quite understand
23:08:42 * oerjan has no actual idea
23:09:08 <ehird`> tape[345897345893] when tape is length 2 /should/ cause SIGSEGV
23:09:21 <SimonRC> I assume that he is arranging to have an invalid page at the end of the tape
23:09:33 <ehird`> hmm
23:09:33 <ehird`> The library offers a rather nice "free" dynamic memory allocation feature for running brainfuck code.
23:09:33 <ehird`> It works through page protection mechanism and catching of SIGSEGV signals.
23:09:37 <ehird`> http://savannah.nongnu.org/projects/libbf
23:09:39 <oerjan> oh well if you can carefully align things...
23:09:49 <ehird`> SimonRC: as soon as i figure out how to do that. yep!
23:09:53 <ehird`> should just be powers-of-two
23:09:53 * oerjan already mentioned he has no actual idea, right?
23:10:15 <ehird`> this technique reminds me of the Cheney-on-the-MTA Scheme->C compilation stuff
23:10:31 <ehird`> you just let the stack grow and grow, and if you go too high, trash loads of stuff and continue
23:10:49 <ehird`> here, you jsut let the pointer grow and grow, and if you go too high and signal an error, expand the tape and continue
23:10:53 <ehird`> "just in time"
23:12:10 <SimonRC> Actually a good way to cope would be to ask the OS to lazily mmap 16 EB of zeros
23:12:42 -!- pikhq has quit ("leaving").
23:12:50 <SimonRC> I think you can just ask linux to mmap /dev/zero for that effect
23:13:13 <SimonRC> linux mmaps lazily
23:14:30 <ehird`> i run on os x, which is a bsd variant
23:14:40 <ehird`> bsd is very conservative, so i doubt tricks like that will work
23:14:50 <ehird`> (this is a good thing: i want portable code, to as big as degree as possible)
23:15:07 -!- pikhq has joined.
23:15:44 -!- pikhq has quit (Client Quit).
23:17:18 <ehird`> SimonRC: i'm wondering how i could really assure to as much a degree as possible that i have an invalid page at the end
23:17:22 <ehird`> i'm not sure just one trick will work
23:17:29 -!- pikhq has joined.
23:18:31 <SimonRC> maybe you can ask something to be mmapped non-readable
23:18:35 <SimonRC> I don't know really
23:19:59 <ehird`> seems so
23:20:01 <ehird`> if you haev int prot = 0
23:20:03 <ehird`> third arg
23:20:24 <SimonRC> however, I don't know how to make it occur right at the end of the other thing
23:20:33 <SimonRC> unless you can ask for an address
23:20:36 <ehird`> yes
23:20:40 <SimonRC> oh dear...
23:20:41 * SimonRC goes
23:20:47 <ehird`> void *
23:20:48 <ehird`> mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
23:20:55 * SimonRC goes.
23:20:57 <ehird`> bye.
23:20:58 <ehird`> :)
23:21:10 <ehird`> wait, fuck, it's really almost 2008
23:21:18 <ehird`> 2008. the number looks weird.
23:21:29 <ehird`> i might not release anything in 2008, just so i don't get that horrible number tied to it
23:22:00 <ehird`> bsmntbombdood: you know you said no code for libbf?
23:22:07 <ehird`> http://cvs.savannah.nongnu.org/viewvc/libbf/?root=libbf code, bitch.
23:22:59 <ehird`> http://cvs.savannah.nongnu.org/viewvc/libbf/libbf_interpreter_dynalloc.c?root=libbf&view=markup yow, that's some heavy stuff
23:26:19 -!- pikhq has quit (Read error: 104 (Connection reset by peer)).
23:27:26 <bsmntbombdood> ?
23:27:30 <bsmntbombdood> libbf?
23:27:35 -!- pikhq has joined.
23:27:49 <ehird`> bsmntbombdood: you said about it's dynamic allocation stuff
23:27:53 <ehird`> bsmntbombdood: using sigsegv
23:27:58 <ehird`> and said 'damn no code'
23:28:01 <bsmntbombdood> oh
23:28:04 <bsmntbombdood> cool
23:28:08 <bsmntbombdood> like a year ago :P
23:28:33 * bsmntbombdood orgasmums
23:28:51 <bsmntbombdood> holy crap that's a lot of code
23:31:59 <bsmntbombdood> 1.6 megabytes?!
23:33:29 <ehird`> look at that one file i showed you...
23:33:34 <ehird`> that's the feature you were looking for
23:33:38 <ehird`> fukcing crazy code
23:33:40 <ehird`> i'll never understand it
23:33:46 <ehird`> it's like kernel code
23:33:49 <ehird`> well, more like libc code
23:33:52 <ehird`> like malloc or something
23:35:59 <bsmntbombdood> man
23:36:25 <ehird`> f addr is non-zero, it is used as a hint to the system. (As a conve-
23:36:25 <ehird`> nience to the system, the actual address of the region may differ from
23:36:25 <ehird`> the address supplied.)
23:36:29 <ehird`> fucking mmap
23:36:32 <ehird`> i don't want a 'hint'
23:36:35 <ehird`> that doesn't guarantee this will work
23:37:11 <bsmntbombdood> i might not be able to understand it
23:37:25 <ehird`> see what i mean :P
23:38:27 <ehird`> [ehird:~/Code/Frainbuck] % ./test
23:38:28 <ehird`> fuck: Operation not supported by device
23:38:33 <ehird`> that's what i get for doing perror("fuck")
23:39:39 <ehird`> bsmntbombdood: any other bright ideas for more speedy reallocation than just checkig all the time? :-)
23:40:13 <bsmntbombdood> catching sigv is the only way
23:40:20 <bsmntbombdood> *segv
23:41:13 <ehird`> bsmntbombdood: somehow i doubt it's possible to do the catching segv without that mass of crap :P
23:43:08 <ehird`> hm
23:43:11 <ehird`> gnu libc manual
23:43:11 <ehird`> size_t page_size = (size_t) sysconf (_SC_PAGESIZE);
23:43:13 <ehird`> is that portable?
23:43:59 <bsmntbombdood> fuck if i know
←2007-12-30 2007-12-31 2008-01-01→ ↑2007 ↑all