-
Notifications
You must be signed in to change notification settings - Fork 19
explore some parsing helpers that could act as the other side of the StreamId.gen coin #99
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
Conversation
…StreamId.gen coin
src/FsCodec/StreamName.fs
Outdated
@@ -128,3 +128,20 @@ module StreamName = | |||
/// Throws <c>InvalidArgumentException</c> if the stream name is not well-formed</summary> | |||
/// <remarks>Inverse of <c>create</c></remarks> | |||
let (|CategoryAndIds|) : StreamName -> struct (string * string[]) = splitCategoryAndIds | |||
|
|||
module Parse = | |||
let parse category f (name: StreamName) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line, inside module and at EOF
but module can be skipped - Internal
was to hide low usage stuff esp with names that sort all over the completion list
can you do a 4th one too - streamId ones have 4
also why no pattern match to pull the ids out of the array and validate len ? (can use CategoryAndIds
pattern)
| _ -> failwith "Unexpected match" | ||
|
||
|
||
let [<Fact>] ``It works with Guid's`` () = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's no ' in Guids (or id's!) ;)
/// Represents the second half of a canonical StreamName, i.e., the streamId in "{categoryName}-{streamId}" | ||
type StreamId = string<streamId> | ||
and [<Measure>] streamId | ||
/// Low-level helpers for composing and rendering StreamId values; prefer the ones in the Equinox namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these guys belong in a module Internal
(want real short completion list, only Equinox Stores should need these, and ideally they should inline most of them unless there is a reason to believe someone outside should be using them)
/// Render as a canonical "{categoryName}-{streamId}" StreamName. Throws if the categoryName embeds `-` chars. | ||
let renderStreamName categoryName (x: StreamId): StreamName = toString x |> StreamName.create categoryName | ||
|
||
/// Generate a StreamId from a single application-level id, given a rendering function that maps to a non empty fragment without embedded `_` chars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont forget to bring back the type
- these are ugly to all from C# (and there is a sample that uses it)
@@ -0,0 +1,37 @@ | |||
namespace FsCodec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module FsCodec.StreamId?
then ValueSome struct(f ids[0], g ids[1], h ids[2]) | ||
else ValueNone | ||
/// Extracts the application-level id of a StreamName | ||
let dec category f (name: StreamName) = function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should split the streamId and throw if >1 item
Superseded by #100 |
No description provided.