This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-19
Channels
- # admin-announcements (8)
- # beginners (90)
- # boot (69)
- # bristol-clojurians (3)
- # cider (32)
- # cljs-dev (2)
- # cljsrn (22)
- # clojure (45)
- # clojure-art (2)
- # clojure-poland (102)
- # clojure-russia (91)
- # clojurescript (38)
- # cursive (27)
- # datomic (45)
- # devcards (7)
- # emacs (45)
- # gorilla (25)
- # hoplon (3)
- # jobs (1)
- # ldnclj (7)
- # off-topic (4)
- # om (176)
- # onyx (3)
- # portland-or (7)
- # re-frame (12)
- # reagent (64)
- # yada (26)
Hi. Are there any workarounds for the fact that strings don't have metadata?
@andrewboltachev: There’s no general workaround. It’s pretty much find another way to do what you are trying to do. What are you trying to do?
@andrewboltachev: various objects don't have metadata (Strings, numbers, booleans, arbitrary Java objects etc.). So you should never assume you can attach metadata to an arbitrary value. If you really need metadata, you can wrap any of the above types in a defrecord. But most likely you should think of a different way to solve the problem.
@eraserhd: well, I'm reading a file and wanna keep line numbers for it's lines, in case I would need to report errors
@andrewboltachev The clojure reader just skips these, I think. For error reporting, symbols are the big win.
ok, thanks for answering!
I'm thinking to make it like {:line-no 10 :value "foo"}
this is maybe a beginners question but how can does the print not work here : http://lpaste.net/145556
@eraserhd Maybe the as-> threading macro could provide that extra bit you need to manipulate the return/result in calls to the next function?
@roelof sorry scratch that I didn't realize println worked on vectors too haha. You have an extra parens around final-body-parts that breaks your code
@jethroksy: I believe all pr*
functions (`prn`, pr-str
, println
, print
) all call pr
, for future reference.
Quick question - people use Schema for validation and coercion of data from, say, JSON to Clojure datastructures, turning data strings into joda time's data objects and so on. Did anyone try reverse?
By that I mean having a well formed, schema-matching data structure in Clojure and serialise it according to the schema, turning date objects into a desired string representation and so on?
I tried that once but couldn't get it work since coercion happens before validation and that blew up for me. Maybe there is a way to do it?
@jaen, i’m doing something similar with schema-tools - https://github.com/metosin/schema-tools , but i vent had any need for custom coercers yet - https://github.com/metosin/schema-tools
@jaen: Do you have any reasons to use anything but RFC-3339 datetime format on JSON?
@juhoteperi: doing university project that has to interact with an API which is deliberately weird. One such weirdness is that datetimes are represented in miliseconds since unix epoch in UTC+2.
Okay. Well, one option is to use Cheshire option to set the date format.
Hmm, right, I could do that when registering joda's objects with it. Though that implicitly assumes the date formats will be uniform. What if they won't be? Besides, I already have to coerce string enums like "BROKEN"
into keywords like :broken
so I figured I might as well do both of those with coercions.
@timgluz: looks interesting, let me take a look if I can understand how to use that from examples.
@timgluz: Hmm, I don't think it does exactly what I want. What I wanted is something like this
(let [schema {:date DateTime}
value {:date (time/now)}
coercion-matcher {DateTime (fn [date-time]
(let [unix-timestamp (time-coerce/to-long date-time)]
(* unix-timestamp DATE-TIME-CONVERSION-FACTOR)))}]
(some-magic-function value schema coercion-matcher))
to produce
{:date 1447887600000}
https://gist.github.com/jaen/d0fbc37c03933bc286c0 if anyone would be interested.
I need to be able to create XML files, specifically X3D format. Should be fairly easy. Any suggestions on a good library for this kind of thing? I was thinking something that generated XML as nicely as hiccup-style syntax is used to create HTML.
I don't need to be able to read an X3D file in, and I've got code for creating the content of the file, I just need something simple and easy for handling the XML specific bits and pieces.
I need it for making things like this: https://pbs.twimg.com/media/CUMIEssVEAEWDMM.png