Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose refinements #445

Open
NeQuissimus opened this issue Feb 22, 2018 · 1 comment
Open

Compose refinements #445

NeQuissimus opened this issue Feb 22, 2018 · 1 comment

Comments

@NeQuissimus
Copy link
Contributor

I have a (seemingly) unusual use-case with refined:

I would like to define a combination of refinements.

Here is a simple example:

import eu.timepit.refined.predicates.all._

type Hostname = NonEmptyString
type Port = PortNumber

type HostAddress = ??? // I would like this to be (NonEmptyString + ":" + PortNumber)

I don't think there is a way to do this in refined.
Any thoughts?

@fthomas
Copy link
Owner

fthomas commented May 3, 2018

@NeQuissimus I'd probably combine hostname and port in a case class:

case class HostAddress(name: NonEmptyString, port: PortNumber)

But I guess your HostAddress would be more like a String Refined P where P is a combination of NonEmpty, Equal[:], and Interval.Closed[0, 65535]. I don't see a way how this could work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants