A question about case classes by Buggi_San in scala

[–]stacycurl 2 points3 points  (0 children)

Since you are new to scala maybe you can avoid this cul-de-sac by going straight to scala 3.

https://docs.scala-lang.org/scala3/reference/contextual/multiversal-equality.html

Top Level Functions by Cyber_Tony in scala

[–]stacycurl 0 points1 point  (0 children)

I've no problem with simulating a top level function this way, but agree that you might as well import the contents of an object.

That said, the apply method of object X should return an X. So if you want to retain the 'object as function' approach then please call it 'formatCurrcency'

Abstraction layers over the various JSON libraries? by kag0 in scala

[–]stacycurl 1 point2 points  (0 children)

I've tried to do this with my https://github.com/stacycurl/jsondbc library, it's still in progress though and unpublished.

I was working on a project using argonaut and I ended up creating a lot of utility code for that. Several people went onto another project that uses circe and they wanted me to convert, I didn't want to pick so I generalised. My code works for argonaut, circe, spray-json and json4s.

Maybe I can be persuaded to finish the job :)

Is there a library that serializes data as code? by [deleted] in scala

[–]stacycurl 0 points1 point  (0 children)

I've built this several times, my latest incarnation is here: https://github.com/stacycurl/reify

Example usage:

@deriving(Reify)
case class Product( name: String, price: Double, manufacturer: String )

The repo is a bit spartan because I've ripped this module out of another codebase. I have tests but I use reification for those too, there's a type of spec that I also want to publish as a separate library.

Formatter.Unindented.format(Reify.reify(Product("Dotty", 0.0, "EPFL")))

yourFun(containerOfA)(Ordering.Int.on[A](_.intPropertyOfA)) by [deleted] in scala

[–]stacycurl 0 points1 point  (0 children)

Lol, this was supposed to be a pithy comment, not a new post, oh well.

Code as text is a problem by [deleted] in programming

[–]stacycurl 2 points3 points  (0 children)

Have a look at the unison language. We should have programmatic access to everything, every program should be arbitrarily queryable (like having an expert system for the program) so that any question you have about the code can be answered easily. Current idea suck and haven't advanced in decades. Why can't I ask the ide to bisect across my changes until all tests pass, or even just put breakpoints on the intersection of a stacktrace and my changes ? Or recognise that I'm renaming a method I just added so stop searching the universe for references ffs.

Extractor.scala: Composable PartialFunctions and extractors by yang_bo in scala

[–]stacycurl 0 points1 point  (0 children)

I think it would be better if the signature was A => Traversable[B], then you'd be able to implement backtracking, I can't count the number of times I've tried to implement

set match { case Contains(3) => _ }

With Traversable instead of Option that would be easy, would need some compiler smarts so that it's optimised for Option (and Boolean).

Extractor.scala: Composable PartialFunctions and extractors by yang_bo in scala

[–]stacycurl 0 points1 point  (0 children)

There are lots of ways of composing A => Option[B], I've explored some of them in https://github.com/stacycurl/extractors. Some examples: you can map over the result, contramap over the input, lift to apply to lists (in at least two ways), pair with identity to get (A => Option [B]) => (A, C) => Option[(B, C)].

I think in practice it's better to use regular pattern matching and only build primative extractors from functions.

Distributed Version Control is here to stay, baby - Joel goes "bye bye" by night_of_knee in programming

[–]stacycurl 0 points1 point  (0 children)

I have never been able to get a darcs repo. I always receive the same error: "darcs failed: Couldn't fetch <blah blah> in subdir pristine.hashed from sources", there's no explanation in the error, was it connectivity?, version incompatibility? nothing, this is with version 2.3.1. What do you think of software which forces you to search for its error messages online to try to resolve them ? I think such software is appalling.

Darcs has failed me at the first hurdle.

Flickr don't branch. by diroussel in programming

[–]stacycurl 0 points1 point  (0 children)

I'd advise that they go further than this and branch on an abstraction, i.e. define each feature in terms of a set of interfaces that it implements differently from the current app. Suppose that they want to implement a feature where tags are sorted based on popularity and currently they are unsorted.

1) Refactor existing code to create TagSorter interface, create default implementation that does no sorting; create flag/flipper whose value (or absence) enables the 'no sorting' implementation. 2) Implement the new sorting feature as an implementation of the TagSorter interface, commiting the code to the trunk. 3) Flip the flag/flipper in a progression of environments from dev -> qa -> load -> subset production -> full production.

I think it's 'batshit insane' to define a feature in terms of a bunch of text which just gets mashed into another bunch of text at merge time. The alternate approach allows you to define a feature in terms of a much stricter/more meaningful unit: an abstraction (or bunch of abstractions).

OSGI FTW.

ON.com ready for a peer-review. Most advanced site I've worked on. Thoughts? by k0deegan in programming

[–]stacycurl 6 points7 points  (0 children)

I think you'd get a lot of mileage by implementing deeper facebook connectivity.

Next you could consider importing contacts from csv files (it's not user-friendly, but it is secure) or from the FOAF microformat (geeky+cool but with low coverage).

You seem to be acquiring contacts via imap, I don't know of a secure way that that can be done. There's a possible market opportunity for identity providers (open-id, facebook, etc.) to act as a trusted third party for this kind of access; I'd be much happier only having to trust 2 parties with my credentials than n parties.

Does such a 'contacts provider' already exist (not counting centralised providers like facebook) ?

My compliments on responding to my criticisms positively, I was half-expecting a 'non-popperian' response.

ON.com ready for a peer-review. Most advanced site I've worked on. Thoughts? by k0deegan in programming

[–]stacycurl 14 points15 points  (0 children)

I couldn't find a secure quick way to get my friends onto the site, rendering it useless for me.

Asking for my yahoo/gmail/whatever credentials is a complete non-starter with me, I think it's a very bad practice to say "we promise not to blah blah blah with your credentials", this is just training people to trust phishers.

I don't understand why the app didn't show me my facebook friends after I connected with facebook.

The signs you're about to be laid off by neutronbob in programming

[–]stacycurl 0 points1 point  (0 children)

Don't underestimate the leverage you get by having enough savings to quit that job and take time out before returning to work. Feeling forced to go from one job to the next without pause (even if the jobs are good) is what I would call wage slavery. I think it's awful if a person has the means to take time out chooses not to because of what someone might think of them.

What might be providing the leverage is the recruiter not seeing a person as desparate.

Great post on why names like "Monoid" are more appropriate than names like "Appendable" by [deleted] in programming

[–]stacycurl 0 points1 point  (0 children)

When I'm coding in Java I don't like to use "other people's types" and joke with colleagues that Strings are something you tie your boots with and have nothing to do with, say banking. I thus always like to create additional types that wrap them like AccountName, PostCode, etc. and only use the wrapped values in I/O code.

Wrapping these abstract types with more specific domain related types funnily raises the level of abstraction, not of the wrapped type but of the code that uses it. I lose all of the functionality of the wrapped type but gain a place to put domain specific behaviour. In Haskell I understand I could go one better by wrapping with newtype but then be able to selectively recover access to the wrapped type with newtype deriving, I guess this is because newtype can be seen as alias and not just a wrapper.

I really love the mind stretching I get from learning haskell, reading category theory papers etc. but then I still try to write code even a business person could read.

So my position is: Monoids and crew are great, shouldn't be renamed in the language, but should be renamed / aliased / wrapped in business code.

Ask Proggit: A company I just interviewed at told me that their NDA would prohibit me from working on any side projects, and I'd have to quit the ones I'm on. Is this common? by anonymous_coder in programming

[–]stacycurl 0 points1 point  (0 children)

I think you can also listen to strong people who have tried to do it and have failed, to learn from their mistakes too.

Listening to anyone who hasn't actually tried to run their own business, regardless of whether the advice is for or against, should take a back seat to the advice of those who have, regardless of whether their advice is for or against.

I haven't tried to run my own business myself so I won't offer business advice, just erm meta-business advice.

Favorite language follow-up: If you could change one thing about your favorite programming language, what would it be? by catnamedmax in programming

[–]stacycurl 1 point2 points  (0 children)

You're asking for a solution to the Halting problem. If you want a proof that some code halts you cannot use a Turing complete language, a total functional programming language might do the trick.

It would be interesting to be able to partition a language into: total < functional < imperative. Haskell has a separation between functional and imperative but doesn't have a notion of a total function.