[ANN] system 0.4.0

2017-02-01 Thread Daniel Szmulewicz
A new release of system is now available!

https://github.com/danielsz/system

[org.danielsz/system "0.4.0"] 

This release represents a milestone, hence the major version bump. It
is breaking only with regards to the Duct-style components. This is
also where most of the innovation took place.

The Duct components, an idea that originated with James Reeves,
revolves around a handler, endpoints and middleware. Compojure gave us
means to route http requests, Duct builds on that work and allows us
to group routes by purpose, exposing them to the dependencies they
need.

The endpoints are in fact closures on top of routes with the
dependencies available in lexical scope. So are middleware components 
(at this point, this is true only for system’s implementation of
Duct).

The original Duct mini-framework boasts a data-driven configuration. At
system, we provide a code-driven configuration that maps nicely with
the way classical (Stuart Sierra) components are configured.

A minimal system would look like that:

(component/system-map
 :db (new-database)
 :endpoint (component/using (new-endpoint ring-handler) [:db])
 :middleware (new-middleware {:middleware [[[wrap-not-found]]]})
 :handler (component/using (new-handler) [:endpoint :middleware])

Middleware can be applied globally and/or on a per endpoint
basis. This addresses real-world scenarios where some endpoints may
need different middleware than other endpoints. An example of this is
the Sente routes that don’t tolerate data format middleware as it does
its own serialization.
 
Duct components allow web developers to write specialized endpoints in
isolation and (re)use them in application code with ease. For example,
a social sign-in library that has endpoints for the Facebook login
workflow, can be (re)used like so:

(component/system-map
 :db (new-database)
 :app-endpoint (component/using (new-endpoint ring-handler) [:db])
 :facebook-endpoint (new-endpoint facebook)
 :middleware (new-middleware {:middleware [[[wrap-not-found]]]})
 :handler (component/using (new-handler) [:app-endpoint :facebook-endpoint 
:middleware])

And voilà, your web app now does Facebook sign in.

If you haven’t looked at system yet, here are a couple of reasons why
you should. 

- system brings very little semantics of its own (a good thing in my
  book!), it embraces the coding discipline and philosophy of its
  constituent parts: Component, Boot, Duct, etc.

- system is stable and battle-tested (running in production for
  several years already).

- system has excellent live coding facilities. It even offers a Lisp
  mode where the REPL behaves the same way it does in all Lisp
  systems: redefine away until it breaks.

On the other hand, documentation is sparse. Efforts are under way to
remedy the situation. Docstrings adorn the Duct namespaces thanks to a
recent PR by Arne Brasseur. I have plans to build a project homepage
with educational material. Blog posts and/or screencasts will be very
much appreciated.

The complete changelog:
https://github.com/danielsz/system/blob/master/CHANGELOG.org#040

This release was made possible with the contributions of: 

Arne Brasseur
Wei Hsu
Alex Miller
Andreas Rottmann
John Swanson

Thank you so much!


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(System/console) is nil?

2017-02-01 Thread Mark Reed
Trying to write a CLI that will prompt for a password, and it's failing 
because (System/console) always returns nil (whether in a compiled app or 
inside the REPL).

Is this expected behavior? Is there any other portable way to read a line 
without echo in Cojure?

I've confirmed that System.console() is not null when I compile a Java test 
app in the same environment.

This is Lein 2.7.1 in Java 1.8.0 on macOS Sierra 10.12.2.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (System/console) is nil?

2017-02-01 Thread John Szakmeister
On Wed, Feb 1, 2017 at 5:35 PM, Mark Reed  wrote:
> Trying to write a CLI that will prompt for a password, and it's failing
> because (System/console) always returns nil (whether in a compiled app or
> inside the REPL).

It works for me in a compiled app (it's non-nil), but not at the REPL
(probably because things are being redirected for the REPL).

-John

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Documentation for namespace aliased keywords (particularly relevant for clojure.spec use)

2017-02-01 Thread Dave Tenny
Looking at the documentation for keywords 
under https://clojure.org/reference/reader#_literals
there is no mention for the syntax for namespace aliased keywords, and this 
is very important it you want to manage your keywords for clojure.spec.

I only know about it because google turned up some clojure.spec notes on 
it, but it seems it should be in the mainline clojure docs too.
I certainly didn't know about it until today.

Say we have this namespace:

(ns foo 
  (:require [clojure.spec :as s]))
(s/def ::specific-even-number #(= 1000 %))




And then in the user namespace:

(ns user)
(require '[clojure.spec :as s])
(require '[foo :as f])


(s/valid? :f/specific-even-number 1000) 
;; Exception Unable to resolve spec: :f/specific-even-number  clojure.spec/
reg-resolve! (spec.clj:70)

What is needed is the extra colon, as if we're saying use the current 
namespace, only that isn't what happens.
(s/valid? ::f/specific-even-number 1000)
;; true

Perhaps the clojure docs are correctly stating the use of this kind of 
keyword my interpretation is just flawed, but it certainly wasn't obvious 
to me, and nobody in my team knew that we could do this either.  The result 
was some namespace unfriendly code to avoid typing in long namespaces on 
clojure spec keywords.  Now that we know ::ns-alias/keyword we can do 
better on our clojure.spec use.

(The above tested in clojure 1.8.0).

While I'm here, I want to say that I am _deeply_ disappointed that 
clojure.spec def/fdef forms don't support documentation strings.  I upvoted 
the issue in the bug tracker, but there were only 27 votes including mine 
when I checked on this half-year-plus old issue.
http://dev.clojure.org/jira/browse/CLJ-1965


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.