Arc Forumnew | comments | leaders | submitlogin

what does main.arc do and news.arc do?

You can change the images used by replacing them in the app-root/repo/static directory.

I'm not sure where the copyright message you're referring to is. To replace it, you'd have to figure out where in the anarki code it's being generated, and override it in main.arc.


btw,where an i change the logo and copyright?
2 points by rocketnia 4437 days ago | link | parent | on: MongoDB support in arc?

"Do we actually need the mzscheme dependency? Any reason we couldn't switch to a full racket base?"

There's always a reason, but these days Anarki has broke all my code enough times that that shouldn't be a concern. :)

I think this would be a positive change.

---

"...the reason you're using lists is so that 'nil is interpreted as no value, while '(nil) is interpreted as intentionally passing the value 'nil? How does the function know the difference?"

Arc doesn't support nil as an element of a table. Setting a table entry to nil removes it. Therefore '$kw-apply will only see non-nil values anyway.

As pg says: "In situations where the values you're storing might be nil, you just enclose all the values in lists." http://arclanguage.org/item?id=493

When I was using Arc heavily, I defined a utility (sobj ...) that was just like (obj ...) but it wrapped everything in a singleton list. That may have been the only extra utility I needed.

I could write (each (k (v)) tab ...) in place of (each (k v) tab ...). I could write tab!key.0 in place of tab!key. I could write (iflet (v) tab!key ...) in place of (iflet v tab!key ...).

It was surprisingly unintrusive, even pleasant.

---

"Normally, I would expect the purpose of the data interaction layer to be separating the implementation details from the code, so that if changes need to be made to what backend storage system you can just trade it out."

I like the sound of that, but I think it's always a bit leaky, unless the result is a full database design that lets people happily forget there's another database underneath.

3 points by shader 4437 days ago | link | parent | on: MongoDB support in arc?

Do we actually need the mzscheme dependency? Any reason we couldn't switch to a full racket base?

---

Interesting. I'll have to play around with that. And study it a bit more to figure out how it works. If I understand your description correctly, the reason you're using lists is so that 'nil is interpreted as no value, while '(nil) is interpreted as intentionally passing the value 'nil? How does the function know the difference?

---

Interesting opinion. Unless I misunderstood you, I would have felt the opposite way. Normally, I would expect the purpose of the data interaction layer to be separating the implementation details from the code, so that if changes need to be made to what backend storage system you can just trade it out.

Maybe that is what you mean though, and that's supposed to be a distinction between the "driver" and an additional abstraction layer. Though your comment about ORMs including sugar confuses that a bit. I don't really want sugar per se, just abstraction away from how I'm actually storing the data, within reason anyway.


done.thx ..u really rock!bro!can i know ur name or google+?
2 points by rocketnia 4437 days ago | link | parent | on: MongoDB support in arc?

Oops, I think you've been seeing something I wasn't seeing.

It turns out I'm getting much different results on a local setup than I was getting in tryarc.org. Since Arc 3.1 and Anarki use (require mzscheme), all sorts of things are replaced with doppelgangers that doesn't support keyword args, including the function application syntax #%app. In fact the lack of keyword arguments is one of the only things (require mzscheme) is good for. This is something tryarc.org changes, apparently.

MzScheme docs: http://docs.racket-lang.org/mzscheme/index.html

---

"So, what's the right way to hack on arc to support calling racket functions with keyword args?"

I wouldn't say it's "the right way," but we could put the functionality of Racket's 'keyword-apply in a function that takes an Arc table, and then we'd pretty much never need to worry about keywords other than that.

I have an implementation for this, which I should be able to commit with some unit tests now that I know what's going on with MzScheme.

...Actually it might take me a few days to get around to that, so here's the code if anyone wants to use it right away:

  (def $kw-apply (func kwargs . posargs)
    
    ; Convert the last element of posargs (the first-class list) into a
    ; Racket list. If posargs is completely empty, pretend the last
    ; element is an empty list just like Arc's 'apply already does.
    (zap [rev:aif rev._
           (cons (apply $.list car.it) cdr.it)
           (list:$.list)]
         posargs)
    
    (let (ks vs)
         (apply map list  ; Transpose.
           (sort (compare $.keyword<? !0)
             (map [list ($.string->keyword:+ "" (or _.0 "nil")) _.1.0]
               tablist.kwargs)))
      (apply $.keyword-apply func (apply $.list ks) (apply $.list vs)
        posargs)))
Use it like so:

  ($kw-apply my-func
    
    ; keyword args
    (obj a list.1 b list.2 message (list "hello"))
    
    ; positional args
    1 2 3 (list 4 5))
I'm using a table of singleton lists so that we can pass the symbol 'nil as an argument value.

---

"Or would it be better to make a more arc-idiomatic mongo driver, and how?"

I actually have some opinion about "the best way" for this. :)

I think Arc-idiomatic approaches serve no particular purpose, since Arc is a tool for general-purpose computation.[1] I would want a database driver to be idiomatic only for the database itself, so that it serves the more specific purpose of storing data. This can then be accompanied with sugary helper utilities, as long as they're optional.

It seems many ORMs want to bake the sugar into the interface, or they make sugar that has tiny escape hatches for poking at the underlying interface. If sugar is the only thing a programmer (usually) sees, I look at it as though it's a full-on database design of its own... which is rarely favorable since it usually inherits most of the complexity and obligations of the original.

[1] Well, while Arc is a general-purpose tool, it's specifically a language, so Arc-idiomatic approaches serve the particular purpose of making features more accessible to language users.


You should only have to restart it once. Calling 'load-userinfo from the repl is redundant, unless you want to check the value of the admins* table to see if it worked or not.

Which arc directory are you putting it in? There's the one that is the anarki installation under app-root/data, and the other which stores web app data in app-root/repo. You need to put the admins file in the app-root/repo/arc directory, or it won't be found by the app server.

That's probably not the right place to keep it, but I haven't bothered to redirect all of the arc server directories, so that's where it goes for now.


thx.but how to arc>? i stop the app ,cd arc, echo “admin” > arc/admins,,,arc> (load-userinfo) ,,,,and arc> (load "lib/news.arc"),,,rhc app-start news...what wrong?still cant find admins privilege in my page.

It looks like you have to restart the app server in order to get it to reload the user information. If you have repl access though, you can just run (load-userinfo)

I do think that we need a way to connect to the repl of the running service, as well as update the code without requiring a full restart, as that takes >20s most of the time.


i set it up http://xmeetu.tk welcome to visit!

but i try to echo “admin” > arc/admins ,and admin looks doesn't like admin...i cant delete other's post...


Did you perhaps get a 'Try again' message?

I tried on my site with the url "http://google.com, and that worked. However, doing just "google.com" does not, so it's apparently filtering for fully qualified urls.

As for your error message when run from the command line... I get the same "rm: cannot remove..." message, followed by "load items" and "ready to serve port..." all of which are correct. The only real error is after that part, but I'm not sure why you're getting it. That error looks like something that might happen on a timeout or broken connection with the client.

What were the results on the client side? Did you get a blank page?


thank you very much.so i dicide to build a new site follow ur instructions. here's what i got...

  arc> (thread:load "../../repo/main.arc")
  #<thread>
  arc> rm: cannot remove"arc/news/story/*.tmp": No such file or directory load items;
  load items: 
  ranking stories.
  ready to serve port (127.10.233.1 8080)
  tcp-write: error writing
    system error: Broken pipe; errno=32
    context...:
     /var/lib/openshift/5375a15d5973ca41a30002b1/app-root/data/arc/ac.scm:945:0: printwith
      map1
      map1
      pr
      handle-request-thread
      handle-request-thread
  tcp-write: error writing
    system error: Broken pipe; errno=32
    context...:
     /var/lib/openshift/5375a15d5973ca41a30002b1/app-root/data/racket-6.0.1/collects/racket/private/map.rkt:26:19: loop
     /var/lib/openshift/5375a15d5973ca41a30002b1/app-root/data/arc/ac.scm:1479:0: ar-close
      handle-request-thread
  tcp-write: error writing
    system error: Broken pipe; errno=32
    context...:
     /var/lib/openshift/5375a15d5973ca41a30002b1/app-root/data/racket-6.0.1/collects/racket/private/map.rkt:26:19: loop
     /var/lib/openshift/5375a15d5973ca41a30002b1/app-root/data/arc/ac.scm:1479:0: ar-close
      th1
  tcp-write: error writing
    system error: Broken pipe; errno=32
    context...:
     /var/lib/openshift/5375a15d5973ca41a30002b1/app-root/data/arc/ac.scm:945:0: printwith
      map1
      map1
      pr
      handle-request-thread
      handle-request-thread
  tcp-write: error writing
    system error: Broken pipe; errno=32
    context...:
*----------------

that's what i got while i sign and submit.and when i closed the terminal the site shutdown too...503...

------that's what i do after followed by ur 8 step instructions in http://new-tvvocold.rhcloud.com/...and when i try my way in http://news-tvvocold.rhcloud.com,by use

  ##git remote add upstream -m master git://github.com/shader/arc-openshift.git
  ##git pull -s recursive -X theirs upstream master
i got it done....and i check ur and my site find that both of us cant submit a simple url like(www.google.com but http://google.com works) with a title ,but only can submit a textwith a title...that's a new problem...if u could tell me what is the right step after the 8step as ur instructions as well.that will be great!---best wishes!
2 points by shader 4438 days ago | link | parent | on: MongoDB support in arc?

It seems to, though much of that is the ODBC layer, which I'm not sure I like anyway. It generates some constructors and getters and setters that use keywords, and I don't think that fits particularly well with the arc style.

Unfortunately, some of the database options are also keyword based, but maybe wrappers could be made for the few cases that matter? Sadly, I am also a beginner with mongo, so I don't really know what I need or how to do it.

2 points by shader 4438 days ago | link | parent | on: MongoDB support in arc?

My original goal was not to shave characters off of '#:key. I apparently misunderstood how they were supposed to work, and thought that arc wasn't compatible with them. I ended up doing the cosmetic change as part of my process of figuring out how to hack it onto arc.

If what you're saying about '#:key vs #:key is true though, then my test cases were incorrect and I was trying to make something work that shouldn't have.

So, what's the right way to hack on arc to support calling racket functions with keyword args? Or would it be better to make a more arc-idiomatic mongo driver, and how?


I'm not sure why you can't submit. I tested it on mine, and submission worked for me once I fixed the login issue.

For the git issues, I found a mistake in the instructions. The 'add remote' line should be:

  git remote add arc-openshift git://github.com/shader/arc-openshift.git
Since I copied it from RayRacine's rackos, it had accidentally said to add the remote as 'rackos', which makes the following lines incorrect. Maybe that wasn't your issue though. Any more details?

As for your repl test, you are directly calling '(nsv), which defaults to binding on port 8080 for all ips, which is against the OpenShift policy. What you want instead is:

  (nsv '("127.8.109.xxx" 8080))
Where 127... is your OPENSHIFT_DIY_IP. You can see how it works if you look in main.arc. You may need to correct your current directory as well.

Another alternative would be to just load main.arc from the terminal, which would automatically start the server exactly as the post-deploy script does, but in a way that lets you see all of the errors:

  (thread:load "../repo/main.arc")
Of course, you'll have to change the path depending on where you're running the arc interpreter from.
1 point by akkartik 4438 days ago | link | parent | on: MongoDB support in arc?

Oh, is the mongodb library using keyword args? I'm used to lisp where keyword syms can exist outside lambda lists.
3 points by rocketnia 4438 days ago | link | parent | on: MongoDB support in arc?

"After hacking on this for a bit, I determined that adding ((keyword? s) s) to the primary ac cond was necessary either way."

That's not necessary either. If you want an Arc expression that evaluates to a keyword, you can already just do this:

  arc> '#:foo
  #:foo
Even so, getting first-class keywords probably won't help as much as you might like:

(Example output from http://tryarc.org/.)

  arc> (= k-idfn ($:lambda (#:k v) v))
  #<procedure:zz>
  arc> (k-idfn '#:k "hello")
  Error: "struct procedure:zz: expects 0 arguments plus an argument with keyword #:k, given 2: #:k "hello""
This function expects 0 positional arguments and a #:k keyword argument. However, we've passed it 2 positional arguments, one of which is #:k and one of which is "hello". We haven't passed it any keyword arguments at all, let alone one with the keyword #:k.

We pretty much have two ways to call this function successfully.[1] First, we can write the function call itself as Racket code, taking advantage of Racket's function call syntax compiler to parse the keywords:

  arc> (let call-k ($:lambda (f v) (f #:k v)) (call-k k-idfn "hello"))
  "hello"
Second, we can build the keyword mapping in a first-class way and use Racket's 'keyword-apply:

  arc> ($.keyword-apply k-idfn ($.list '#:k) ($.list "hello") ($.list))
  "hello"
(Here I've used ($.list ...) as a way to construct ()-terminated instead of nil-terminated lists.)

Note that keyword-apply requires the keywords to be given in a specific order based on their UTF-8 bytes.

If we do a lot of this in the code, I'm thinking we could benefit from one of three things:

- An Arc function that takes an Arc table like (obj k (list "hello")) and calls Racket's 'keyword-apply it to the sorted keywords it expects.

- An Arc macro that looks like a function call, e.g. ($kw-call k-ifn #:k "hello"), but finds any occurrences of keywords and generates the appropriate Racket function call.

- A patch to Arc's own function call syntax so that it parses Racket-style keyword arguments.

I think these solutions would be more effective than shaving one or two heiroglyphics off of '#:k.

---

Not even Racket allows #:k as an expression by itself. It has to be written '#:k. After all, even if #:k evaluated to itself, (list #:k "hello") would not give you a list containing #:k and "hello", since it would try to pass a keyword argument instead.

You might wonder why Racket chose a design with such hoops to jump through. Well, I can't speak for them, but personally I'd give several shallow and hand-wavy reasons:

- It aligns with a certain mental model where positional args are an ordered list and keyword args are an orderless map. (This is the mental model I learned a long time ago in Groovy, so I like it.)

- It lets Racket treat (foo #:a 1 #:b #:c 3) as a compile-time error.

- It lets Racket treat missing/extra keyword args and missing/extra positional args as the same kind of error.

- It means keyword args don't have to be described in terms of positional args. It would be possible to design a lisp that only has Racket-style keyword args, with no positional args whatsoever.

- It means when a programmer wants to get a procedure's arity information dynamically, the result can include information about the keyword args it supports, rather than just the positional args it supports.

---

[1] Hmm, maybe there's a third way to call it successfully:

  arc> (= successfully ($:lambda (#:k v) v))

thx,bro,u really rock...so i rebuild a new site http://news-tvvocold.rhcloud.com and i can sign up and login in...but i can't submit still...why that? follew ur instructions i cant push (stuck at 5th step)so i use this

  ##git remote add upstream -m master git://github.com/shader/arc-openshift.git
  ##git pull -s recursive -X theirs upstream master
Am i doing it wrong or miss something?

when i try

  arc> (nsv)
  rm: cannot remove"arc/news/story/*.tmp": No such file or directory
  load items: 
  ranking stories.
  tcp-listen: listen failed
    port number: 8080
    system error: Permission denied; errno=13
    context...:
     zz
     /var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1227:4
and i repeat again :arc> (nsv) rm: cannot remove"arc/news/story/.tmp": No such file or directory load items: ranking stories. user break context...: /var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1084:20 recur recur user break context...: /var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1084:20 recur recur tcp-listen: listen failed port number: 8080 system error: Permission denied; errno=13 context...: zz /var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1227:4

if u update the full instructions that will be great and grateful,,,thx very much! (add this will be helpful

  ##export PATH=$PATH:/var/lib/openshift//app-root/data/racket-6.0.1/bin:$PATH
)
1 point by akkartik 4438 days ago | link | parent | on: MongoDB support in arc?

Maybe just expose it at the racket level using xdef?
1 point by akkartik 4438 days ago | link | parent | on: MongoDB support in arc?

Thanks! Looks great. I made one tweak: https://github.com/arclanguage/anarki/commit/c416f3a36f. And I've migrated 'else to :else. I can live with printing keywords in racket syntax. No need to add complexity for something so cosmetic. (Analogous to my thinking on nil: http://www.arclanguage.org/item?id=11864; http://arclanguage.org/item?id=12661; http://arclanguage.org/item?id=12814)
2 points by shader 4438 days ago | link | parent | on: MongoDB support in arc?

Interesting. Well, I can push what I currently have, and if necessary remove it later.

Also, one issue is that after adding ssyntax support, :symbol is printed as #:symbol, since they're the same. Should I be adding a special case for that?

2 points by shader 4438 days ago | link | parent | on: MongoDB support in arc?

After hacking on this for a bit, I determined that adding ((keyword? s) s) to the primary ac cond was necessary either way. So, after adding that the #:symbol syntax works as well, since we're mostly just using the racket reader.

Still, I think that the :symbol syntax is a little cleaner and also matches common lisp. Any reason I shouldn't add it?

1 point by akkartik 4438 days ago | link | parent | on: MongoDB support in arc?

On tryarc (so not anarki):

  arc> ':abc
  :abc
But yeah, feel free. I've often wanted :foo to eval to itself just like in common lisp. Currently I use 'else where I would use :else in wart.
2 points by shader 4438 days ago | link | parent | on: MongoDB support in arc?

So, I had one idea for supporting #:symbols

Would anyone mind if I changed ssyntax so that ':symbol expanded into the same thing as #:symbol? ":" currently doesn't mean very much as the first character of a symbol. In fact, I think that currently ':symbol == 'symbol.


Ok, I finished the fix. You need to do a few things in order to get it working:

1) Update the anarki installation on openshift:

  rhc ssh <app>
  cd ${OPENSHIFT_DATA_DIR}arc
  git pull
2) Merge in the latest changes to my arc-openshift repo, which contains the tmpdir* fix.

3) Push to openshift, and wait ~20 seconds for it to reload.

You should now be able to register and create new posts.


As for the bash issue, running arc.sh directly fails for two reasons:

1) rlwrap is not installed

2) racket has not been added to your path

If you want to run the arc script, you can do it manually by moving to the app-root/data folder and executing:

  racket*/bin/racket -f arc/as.scm

That's a bug I'm currently fixing. It happens because arc uses the pattern of creating a temporary file and then moving it, instead of directly writing to an existing file. The only problem is that the /tmp directory on the rhcloud gears is not on the same file system. So it fails to move the file.

I'll push the fix as soon as I finish it.


just fix it by set the env....so i run the bash,,,and now i still cant sign up or login...why?miss something like sql?

thx,bro

as ur step.i successed.my site is :http://diy-tvvocold.rhcloud.com/news

but i cant sign up..why?

i try bash :

  ./arc.sh
  ./arc.sh: line 17: type: rlwrap: not found
  ./arc.sh: line 21: racket: command not found
what is wrong,and how to fix?

best wishes!

More