Skip to content

Commit 9f8c985

Browse files
committed
tweak readme
1 parent 43e27aa commit 9f8c985

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ simplicity, brevity and performance, albeit for some conversion overhead.
3737

3838
Let's formalize the above as a pair of types `S` and `W`.
3939

40-
* Given a `strong :: S`, we can always turn it into a `weak :: W`.
41-
* Given a `weak :: W`, we can only turn it into a `strong :: S` if it passes
40+
* given a `strong :: S`, we can always turn it into a `weak :: W`
41+
* given a `weak :: W`, we can only turn it into a `strong :: S` if it passes
4242
all the checks
4343

4444
We can write these as pure functions.
@@ -57,8 +57,8 @@ useful enough pattern. Let's think of some strongweak pairs:
5757
* `Word8` is a bounded natural number. `Natural` can represent any natural
5858
number. So `Natural` is a weak type, which can be strengthened into `Word8`
5959
(or `Word16`, `Word32`, ...) by asserting well-boundedness.
60-
* `[a]` doesn't have state any predicates. But we could weaken every `a` in
61-
the list. So `[a]` is a strong type, which can be weakened to `[Weak a]`.
60+
* `[a]` doesn't state any predicates. But we could weaken every `a` in the
61+
list. So `[a]` is a strong type, which can be weakened to `[Weak a]`.
6262
* `NonEmpty a` *does* have a predicate. For useability and other reasons, we
6363
only handle this predicate, and don't also weaken each `a` like above.
6464
`NonEmpty a` weakens to `[a]`.
@@ -77,13 +77,11 @@ behaviour. The primary definitions are below:
7777

7878
```haskell
7979
class Weaken a where
80-
type Weak a :: Type
80+
type Weakened a :: Type
8181
weaken :: a :: Weak a
8282

83-
type Result = Validation Fails
84-
type Fails = NeAcc Fail
8583
class Weaken a => Strengthen a where
86-
strengthen :: Weak a -> Result a
84+
strengthen :: Weakened a -> Either Failure a
8785
```
8886

8987
Note that a strong type may have only one associated weak type. The same weak
@@ -140,6 +138,10 @@ strengthening may fail while weakening cannot. For safe conversion enumeration
140138
via typeclasses, consider Taylor Fausak's
141139
[witch](https://hackage.haskell.org/package/witch) library.
142140

141+
### Not a generic `coerce`
142+
strongweak isn't intended for automatic `coerce`ing between pairs of types.
143+
For that, check out `gcoerce` at Lysxia's generic-data package.
144+
143145
### Not particularly speedy
144146
The emphasis is on safety, which may come at the detriment of performance:
145147

0 commit comments

Comments
 (0)