croq-app / elm-climb / Climb.Grades

Climbing grades representation and conversion

Reference

Conversions are based in two tables

Types


type System t

Collect methods for a GradeT pseudo-typeclass


type alias Boulder =
Climb.Systems.AnyBoulder.Grade

Generic Boulder grade. Sum type of all supported grades


type alias Route =
Climb.Systems.AnyRoute.Grade

Generic Route grade. Sum type of all supported grades


type alias VGrade =
Climb.Systems.Hueco.Grade

American V-grades system


type alias Font =
Climb.Systems.Font.Grade

Fontainebleau system


type alias Fr =
Climb.Systems.Fr.Grade

French system for grading routes


type alias Us =
Climb.Systems.Us.Grade

American Decimal system for grading routes


type alias Br =
Climb.Systems.Br.Grade

Brazilian system for grading routes

Grading systems

Required as the first argument of may functions in order to specify the desired grading system.

boulder : System Boulder

Generic bouldering grade.

route : System Route

Generic route grade.

vgrade : System VGrade

The Hueco/Vermin system used for bouldering in the USA, .i.e., the v-grades.

font : System Font

French Fontainbleau system for bouldering.

fr : System Fr

The French system.

us : System Us

The Yosemite Decimal System used in the USA.

br : System Br

The Brazillian system.

Converting to strings

showGrade : System a -> a -> String

Render grade as a string

toAnyGrade : System a -> System b -> Basics.Bool -> b -> String

Render Bouldering grade in destT format.

The boolean argument tells if the final grade should be simplified or not in the final rendering.

toFont : System a -> Basics.Bool -> a -> String

Alias to toGrade font

toVGrade : System a -> Basics.Bool -> a -> String

Alias to toGrade vv

Parsing and converting

parseGrade : System a -> String -> Maybe a

Parse string representing grade

parseGrade vv "V10/11" ==> Just (Grade 10 HalfwayNext)

parseGrade_ : System a -> String -> a

Parse string representing grade.

If parsing fails, return the default base/zero grade. This should never be used to handle user input.

parse_ vv "V10/11" ==> Grade 10 HalfwayNext

fromAnyGrade : System a -> System b -> String -> Maybe b

Try to read string in the src format.

fromVGrade : System a -> String -> Maybe a

Alias to fromGrade vv

fromFont : System a -> String -> Maybe a

Alias to fromGrade font

toLinearScale : System a -> a -> Basics.Float

Convert to the floating point universal scale

This is useful to convert to different grading systems or saving in a database.

font =
    grade
        |> Font.toLinearScale
        |> Hueco.fromLinearScale

fromLinearScale : System a -> Basics.Float -> a

Convert from the floating point universal scale

For bouldering, the floating point scale is based in the American Hueco/Vermin system. i.e. fromLinearScale 10.0 refers to V10, which is 7c+ in Fontainbleau scale.

Transforming grades

simplifyGrade : System a -> a -> a

Remove modifiers from grade

parseGrade_ vv "V10+"
    |> simplify vv
    ==> Grade 10 Base

nextGrade : System a -> a -> a

Next full grade ignoring modifiers

Special methods

zeroGrade : System a -> a

The lowest grade in the scale

Different scales may start from different levels

compareGrades : System a -> a -> a -> Basics.Order

Compare two grades

This can be used in sorting algorithms like List.sortWith