Questions tagged [refined]

A refinement type is a type endowed with a predicate which is assumed to hold for any element of the refined type. "Refined" are libraries in Scala and Haskell for refining types.

In type theory, a refinement type is a type endowed with a predicate which is assumed to hold for any element of the refined type. Connected with dependent types.

In Scala refined types are types like type A { type T = ... }. Connected with compound types and structural types.

refined is a Scala library for refining types with type-level predicates which constrain the set of values described by the refined type. It started as a port of the refined Haskell library.

23 questions
1
vote
1 answer

Pattern matching on scala Refined size

I want to provide a json schema (at compile time) of a case class, based on the differents types (Scala refined included) object JsonSchema { def jsonSchema[T]: String = macro impl[T] def impl[T: c.WeakTypeTag](c:…
Damien GOUYETTE
  • 467
  • 1
  • 3
  • 11
1
vote
1 answer

How to write a refined type regex in scala for a string with values 1-9

I have a string literal which is being sent to a method. The method has a type-safe parameter which takes a string. The type-safe parameter is supposed to contain a as first letter Then any number except zero. I have written a matcher in refined…
user9920500
  • 606
  • 7
  • 21
1
vote
0 answers

Custom Types using pureconfig?

I am using PureConfig with Refined. I have the following case class: case class Config(port: ServerPort, interface: String) ServerPort is a custom type that I have defined using Refined. I am using pureconfig to load a conf file into the Config…
Nespony
  • 1,253
  • 4
  • 24
  • 42
1
vote
0 answers

Scala 2.11 refined with scalatest MustMatchers and Await causes compiler error "trying to do lub/glb of typevar ?F[?T, ?B]"

I have been trying to use the refined with scalatest and am getting compiler errors at the "typer" phase: trying to do lub/glb of typevar ?F[?T, ?B] This is my best attempt at a minimalist reproduction of the issue using a self-contained ammonite…
rmin
  • 1,018
  • 1
  • 9
  • 18
1
vote
1 answer

Using Refined for Retry?

Using refined, I attempted to define f: import eu.timepit.refined._ import eu.timepit.refined.api.Refined import eu.timepit.refined.auto._ import eu.timepit.refined.numeric._ // if action 'succeeds', return 'good'; otherwise re-try, subtracting…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
1 answer

Int Refined Positive doesn't compile

The followfing code doesn't compile: import eu.timepit.refined._ import eu.timepit.refined.api.Refined import eu.timepit.refined.auto._ import eu.timepit.refined.numeric._ val i1: Int Refined Positive = 5 The error is: [error] Found: (5 :…
Bondarenko
  • 225
  • 1
  • 7
0
votes
1 answer

Getting predicate from Refined

Is it possible to extract the bounds from the predicate/witness of a Refined variable at runtime? Something like the following. // Should return L as a Double def getLowerBound[L, H](v: Refined[Double, Interval.Closed[L, H]]): Double = ??? val v:…
dalle
  • 18,057
  • 5
  • 57
  • 81
0
votes
1 answer

Singleton type as a type member

I'm trying to define a type member to be a singleton type. Here is my attempt: import shapeless.syntax.singleton._ trait Test{ type Blocked <: Boolean } def f(t: Test{ type Blocked = false.narrow }) = ??? // does not compile def f(t: Test{…
Some Name
  • 8,555
  • 5
  • 27
  • 77
1
2