Skip to content

Conversation

@jbgi
Copy link
Member

@jbgi jbgi commented May 15, 2015

Also simplify contructors of (monomorphic) Optional and Prism.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dumb question: Where does the naming convention for _1pLens come from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no real convention here, I'm happy to change the name. I originally wanted _1Lens to be named __1 but that method already exist.
_1pLens being the polymorphic version of _1Lens.
Or should we use ___1 and ___2 for the lenses? not sure what would be the name for polymorphic version then...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for reference, the Monocle library use first and second for the lenses on scala tuple:
https://github.com/julien-truffaut/Monocle/blob/master/core/src/main/scala/monocle/std/Tuple2.scala

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer lensTraversal to _traversal for this method. I don't like relying on using underscore to indicate the returned value is a lens. Take _head vs lensHead for example.

However, take note that I am a beginner user of lens.

This would mean the P2._1Lens would be renamed to lens_1. The polymorphic version could be lensp_1 or plens_1.

Your thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lens is one kind of optics, Traversal is another, so lensTraversal would be confusing. so for _traversal I see only List.listTraversal or simply List.traversal as alternative naming.
Maybe @tonymorris could suggest a good naming convention for optics instances in functionaljava... :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I was using lens as the package as a whole, like the Haskell lens package (e.g. Control.Lens.Iso).

For others learning about this information, there is lots of useful info on the Github lens library page, https://github.com/ekmett/lens.

@mperry
Copy link
Contributor

mperry commented Jun 4, 2015

@jbgi I don't think this is compiling on Travis using Java 1.8.0_31, see https://travis-ci.org/functionaljava/functionaljava/builds/65232022. Can you look into this? Other than my misgivings with naming, if we can fix this I will merge the PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about putting optic instances in the same classes. The reason is that it will cause cyclic references between packages/classes (e.g. PLens depends on List and List depends on PLens). In Monocle there is no such problem: optic instances are located in monocle.std package. What if we use the same strategy and create fj.data.optic.std package?

Also, what do you think about creating a new artifact functionaljava-lens with all fj.data.optic stuff in it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a valid concern. However there is already many cyclic packages references in fj (eg. Monoid<->Stream). Scalaz solve cyclic references by putting all in a single package. For those reasons I considered all of fj to be a single 'package'.
I can move optic instances into their own package/artifact, the downside I can see is that it will be harder to find them. pro is that it will address @mperry concern about having a clear distinction for optics 'factory methods'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monoid and Stream are central entities in functional programming, while lenses are not (IMO). Lenses are great, but I think optic methods in "standard" classes will confuse people that are new to functional programming.
Regarding Scalaz: putting everything into a single package led to a huge jar (10 MB) which is not good at all. I would like not to repeat this mistake in functionaljava.
Anyway, this is just my personal point view, so I would like to hear other opinions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lenses (optics) are way more important to functional programming, in a practical regard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see them in their own package, but don't see the need for a separate artifact.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another reason is that instances for List regarding things like Equal, Show, etc. are in those classes, rather than List.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mperry so... do you suggest to put optics instances in Prism, Lens, Ptraversal and the like...? I think this could be practical...
if they are isolated in their own package, those 'orphan' optics that will be harder to find which will lower their practicality.

@mperry
Copy link
Contributor

mperry commented Jun 5, 2015

@jbgi I don't understand what you mean by 'those orphan optics that will be harder to find...'.

It is a suggestion for discussion, just trying to figure out the best way forward for users and potential users.

@jbgi
Copy link
Member Author

jbgi commented Jun 5, 2015

What I mean is that a potential user looking for the Equal<List<A>> constructor should be able to find it either in List or in Equal. I'd like to keep this practical reasoning capability for optic constructors.

@orionll
Copy link
Contributor

orionll commented Jun 5, 2015

I would also like to hear what @runarorama thinks about it

@mperry
Copy link
Contributor

mperry commented Jun 5, 2015

@jbgi At present, the classes representing the Haskell typeclasses like Equal, Show, Ord, Hash, etc. have their typeclass instances on those classes rather than List, P1, etc.

@mperry
Copy link
Contributor

mperry commented Jun 13, 2015

Given my concerns are minor, I raised #154 to deal with naming conventions and package location and will merge this issue.

@mperry mperry merged commit a3407f6 into functionaljava:master Jun 13, 2015
@mperry mperry added this to the v4.4 milestone Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants