Skip to content

Commit 7cbb1d3

Browse files
committed
stdlib: mark functions as internal and improved docs
1 parent 2a98e0c commit 7cbb1d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+931
-380
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.dll
55
*.so
66
*.dylib
7+
__debug_bin
78

89
# Test binary, built with `go test -c`
910
*.test

CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
# Changelog
22

3+
## v0.0.15-next
4+
5+
- stdlib: removed `docs.moduleMemberDocsToMarkup`, `docs.dataFieldDocsToMarkup` and `docs.enumCaseDocsToMarkup` and marked them as internal
6+
- stdlib: renamed `markup.MarkupNode` to `markup.Markup`
7+
- stdlib: renamed `markup.Serializer` to `markup.Format`
8+
- stdlib: renamed `markup.SerializerWitness` to `markup.FormatWitness`
9+
- stdlib: renamed `markup.serialize` to `markup.convert`
10+
- stdlib: renamed `markdown.serializer` to `markup.format`
11+
- stdlib: renamed `markdown.serialize` to `markup.convert`
12+
- stdlib: removed `markdown.asMarkdown`
13+
- stdlib: removed `optionals.Optional`. Use `prelude.Optional` instead
14+
- stdlib: added `prelude.Maybe` as `prelude.Some`, `prelude.None` or `prelude.Any`
15+
- stdlib: improved `optionals` functions to also support `prelude.Maybe`
16+
- stdlib: removed `tests.testCases` and `tests.runTestCase` and marked them as internal
17+
- fix: `docs` of `docs.ExternFunctionDocs` has always been empty
18+
- docs: improved for all modules
19+
320
## v0.0.14
421

522
- lsp: fix jump to definition
623
- lsp: fix multiline block comments
724
- lsp: fix logging too many errors
825
- lsp: deleting files, deletes its diagnostics
926
- fix: extern docs generation
10-
- stdlib: new markup and markdown library
27+
- stdlib: new `markup` and `markdown` library
1128
- stdlib: better docs generation
1229

1330
## v0.0.13

info/globals.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package info
22

3-
var Version = "0.0.14"
3+
var Version = "0.0.15-next"

stdlib/cmp.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,33 @@ Defines comparision operations, ascending and descending of values.
1313

1414
## Ascending
1515

16-
_data_
16+
_data_ Indicates an ascending order of two values.
17+
For example 1 and 2.
1718

1819
## Comparable
1920

20-
_data_
21+
_data_ Instances compare values regarding the order.
22+
Witnesses are typically only defined for specific types.
2123

2224
### Properties
2325

24-
- `compare lhs, rhs`
26+
- `compare lhs, rhs` - Compares two values.
27+
@returns Order
2528

2629
## Descending
2730

28-
_data_
31+
_data_ Indicates an descending order of two values.
32+
For example 2 and 1.
2933

3034
## Equal
3135

32-
_data_
36+
_data_ Both values are ordered equally.
37+
In context of Order, it doesn't necessarily require equality.
3338

3439
## Order
3540

3641
_enum_
42+
Represents the order of two values.
3743

3844
### Cases
3945

@@ -45,9 +51,20 @@ _enum_
4551

4652
_func_ `equatableFrom comparableWitness`
4753

48-
Creates an `eq.Equatable`
54+
Creates an `eq.Equatable` from a `cmp.Comparable`.
55+
`cmp.Equal` will result in `True`,
56+
`cmp.Ascending` and `cmp.Descending` will be `False`.
57+
58+
@returns eq.Equatable
4959

5060
## pullback
5161

5262
_func_ `pullback f, witness`
5363

64+
Lifts an existing `cmp.Comparable` witness to a different type.
65+
Can be used to pick a specific property of complex data.
66+
67+
```lithia
68+
let compareUsersById = cmp.pullback { user => user.id }, cmp.numeric
69+
```
70+

stdlib/cmp/comparables.lithia

+11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
/// Defines comparision operations, ascending and descending of values.
22
module cmp
33

4+
/// Instances compare values regarding the order.
5+
/// Witnesses are typically only defined for specific types.
46
data Comparable {
7+
/// Compares two values.
8+
/// @returns Order
59
compare lhs, rhs
610
}
711

12+
/// Represents the order of two values.
813
enum Order {
14+
/// Indicates an ascending order of two values.
15+
/// For example 1 and 2.
916
data Ascending
17+
/// Both values are ordered equally.
18+
/// In context of Order, it doesn't necessarily require equality.
1019
data Equal
20+
/// Indicates an descending order of two values.
21+
/// For example 2 and 1.
1122
data Descending
1223
}
1324

stdlib/cmp/contravariant.lithia

+8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ module cmp
22

33
import controls { Contravariant }
44

5+
/// Lifts an existing `cmp.Comparable` witness to a different type.
6+
/// Can be used to pick a specific property of complex data.
7+
///
8+
/// ```lithia
9+
/// let compareUsersById = cmp.pullback { user => user.id }, cmp.numeric
10+
/// ```
511
func pullback { f, witness =>
612
Comparable { lhs, rhs =>
713
witness.compare f lhs, f rhs
814
}
915
}
1016

17+
/// A `controls.Contravariant` witness for `cmp.Comparable`.
18+
/// Allows to lift comparision to different types.
1119
let contravariant = Contravariant pullback
1220

1321
import tests { test }

stdlib/cmp/equatableFrom.lithia

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ module cmp
22

33
import eq
44

5-
/// Creates an `eq.Equatable`
5+
/// Creates an `eq.Equatable` from a `cmp.Comparable`.
6+
/// `cmp.Equal` will result in `True`,
7+
/// `cmp.Ascending` and `cmp.Descending` will be `False`.
8+
///
9+
/// @returns eq.Equatable
610
func equatableFrom { comparableWitness =>
711
eq.Equatable { lhs, rhs =>
812
with (comparableWitness.compare lhs, rhs), type Order {

stdlib/cmp/numeric.lithia

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module cmp
22

3-
/// `Comparable` for numbers using < and >.
3+
/// `Comparable` witness for numbers using < and >.
44
/// Not safe for other types.
55
let numeric = Comparable { lhs, rhs =>
66
if lhs < rhs, Ascending, (

stdlib/controls.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,26 @@ flatMap repeat 2, lists.monad
138138

139139
_func_ `contravariantFrom moduleWitness`
140140

141+
Creates a Contravariant from a given ContravariantWitness.
142+
141143
## flatMap
142144

143145
_func_ `flatMap f, witness, instance`
144146

147+
Flat map for a yet unknown witness and instance.
148+
Can be used in generic contexts, where the witness will be curried.
149+
145150
## functorFrom
146151

147152
_func_ `functorFrom moduleWitness`
148153

154+
Creates a Functor from a given FunctorWitness.
155+
149156
## map
150157

151158
_func_ `map f, witness, value`
152159

153-
Transforms a wrapped value using a functor witness.
160+
Transforms a wrapped value using a yet unknown functor witness and value.
154161
Essentially just uses the map of the given witness,
155162
but allows to defer the decision regarding the witness itself.
156163

@@ -165,11 +172,18 @@ map incr, lists, [1, 2, 3]
165172

166173
_func_ `monadFrom monadWitness`
167174

175+
Creates a Monad from a given MonadWitness.
176+
168177
## pullback
169178

170179
_func_ `pullback f, witness`
171180

181+
pullback for a yet unknown witness.
182+
172183
## pure
173184

174185
_func_ `pure value, witness`
175186

187+
Creates a pure monad value from a yet unknown witness.
188+
Can be used in generic contexts, where the witness will be curried.
189+

stdlib/controls/_monad.lithia

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum MonadWitness {
2626
Module
2727
}
2828

29+
/// Creates a Monad from a given MonadWitness.
2930
func monadFrom { monadWitness =>
3031
with monadWitness, type MonadWitness {
3132
Monad: { witness => witness },
@@ -35,10 +36,14 @@ func monadFrom { monadWitness =>
3536
}
3637
}
3738

39+
/// Creates a pure monad value from a yet unknown witness.
40+
/// Can be used in generic contexts, where the witness will be curried.
3841
func pure { value, witness =>
3942
(monadFrom witness).pure value
4043
}
4144

45+
/// Flat map for a yet unknown witness and instance.
46+
/// Can be used in generic contexts, where the witness will be curried.
4247
func flatMap { f, witness, instance =>
4348
(monadFrom witness).flatMap f, instance
4449
}

stdlib/controls/contravariant.lithia

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum ContravariantWitness {
3636
Function
3737
}
3838

39+
/// Creates a Contravariant from a given ContravariantWitness.
3940
func contravariantFrom { moduleWitness =>
4041
with moduleWitness, type ContravariantWitness {
4142
Contravariant: { witness => witness },
@@ -48,6 +49,7 @@ func contravariantFrom { moduleWitness =>
4849
}
4950
}
5051

52+
/// pullback for a yet unknown witness.
5153
func pullback { f, witness =>
5254
(contravariantFrom witness).pullback f
5355
}

stdlib/controls/functor.lithia

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum FunctorWitness {
4040
Monad
4141
}
4242

43+
/// Creates a Functor from a given FunctorWitness.
4344
func functorFrom { moduleWitness =>
4445
with moduleWitness, type FunctorWitness {
4546
Functor: { witness => witness },
@@ -56,7 +57,7 @@ func functorFrom { moduleWitness =>
5657
}
5758

5859
/**
59-
* Transforms a wrapped value using a functor witness.
60+
* Transforms a wrapped value using a yet unknown functor witness and value.
6061
* Essentially just uses the map of the given witness,
6162
* but allows to defer the decision regarding the witness itself.
6263
*

0 commit comments

Comments
 (0)