Skip to content

Commit 2c8b58b

Browse files
committed
Remove 'Result<'a>'
1 parent 775e903 commit 2c8b58b

File tree

8 files changed

+17
-24
lines changed

8 files changed

+17
-24
lines changed

YukimiScript.Parser/Diagram.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ exception DiagramMacroErrorException of DebugInformation
2727
exception CannotFindSceneException of string
2828

2929

30-
let analyze (files: (string * Dom) list) : Result<Diagram> =
30+
let analyze (files: (string * Dom) list) : Result<Diagram, exn> =
3131
try
3232
let fileNodes, arrows =
3333
files

YukimiScript.Parser/Dom.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module Dom =
113113
exception CannotDefineSceneInLibException of string
114114

115115

116-
let analyze (fileName: string) (x: Parsed seq) : Result<Dom> =
116+
let analyze (fileName: string) (x: Parsed seq) : Result<Dom, exn> =
117117
let finalState =
118118
x
119119
|> Seq.indexed
@@ -198,7 +198,7 @@ module Dom =
198198
parse "- extern __text_end hasMore" ]
199199

200200

201-
let linkToExternCommands (x: Dom) : Result<Dom> =
201+
let linkToExternCommands (x: Dom) : Result<Dom, exn> =
202202
let externs = systemCommands @ List.map fst x.Externs
203203

204204
let linkSingleCommand (op, debugInfo) =

YukimiScript.Parser/EditorHelper.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ open YukimiScript.Parser
44
open YukimiScript.Parser.Elements
55

66

7-
type Runner<'State> = 'State -> CommandCall -> Result<'State>
7+
type Runner<'State> = 'State -> CommandCall -> Result<'State, exn>
88

99

10-
let rec run (state: 'State) (runner: Runner<'State>) (ops: Block) : Result<'State> =
10+
let rec run (state: 'State) (runner: Runner<'State>) (ops: Block) : Result<'State, exn> =
1111
match Seq.tryHead ops with
1212
| None -> Ok state
1313
| Some (EmptyLine, _) -> run state runner <| List.tail ops
@@ -30,6 +30,6 @@ let dispatch (dispatcher: CommandCall -> Runner<'State>) : Runner<'State> = fun
3030

3131

3232
type RunnerWrapper<'TState>(init: 'TState, mainRunner: Runner<'TState>) =
33-
member _.Run(state: 'TState, ops: Block) : Result<'TState> = run state mainRunner ops
33+
member _.Run(state: 'TState, ops: Block) : Result<'TState, exn> = run state mainRunner ops
3434

35-
member x.Run(ops: Block) : Result<'TState> = x.Run(init, ops)
35+
member x.Run(ops: Block) : Result<'TState, exn> = x.Run(init, ops)

YukimiScript.Parser/Elements.fs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
namespace YukimiScript.Parser.Elements
22

3-
open YukimiScript.Parser
4-
53

64
type Constant =
75
| String of string
@@ -76,12 +74,12 @@ module Operation =
7674
exception CanNotConvertToOperationException of Line
7775

7876

79-
let ofLine: Line -> Result<Operation> =
77+
let ofLine: Line -> Operation =
8078
function
81-
| Line.Text t -> Ok <| Text t
82-
| Line.CommandCall c -> Ok <| CommandCall c
83-
| Line.EmptyLine -> Ok <| EmptyLine
84-
| x -> Error <| CanNotConvertToOperationException x
79+
| Line.Text t -> Text t
80+
| Line.CommandCall c -> CommandCall c
81+
| Line.EmptyLine -> EmptyLine
82+
| x -> raise <| CanNotConvertToOperationException x
8583

8684

8785
type Block = (Operation * DebugInformation) list

YukimiScript.Parser/Macro.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ exception ArgumentRepeatException of DebugInformation * CommandCall * string
5858
exception ArgumentUnmatchedException of DebugInformation * CommandCall * parameter: string
5959

6060

61-
let matchArguments debugInfo (x: Parameter list) (c: CommandCall) : Result<(string * Constant) list> =
61+
let matchArguments debugInfo (x: Parameter list) (c: CommandCall) : Result<(string * Constant) list, exn> =
6262
let defaultArgs =
6363
x
6464
|> List.choose (fun { Parameter = name; Default = x } -> Option.map (fun x -> name, x) x)
@@ -76,7 +76,7 @@ let matchArguments debugInfo (x: Parameter list) (c: CommandCall) : Result<(stri
7676
| None -> Ok()
7777
| Some (p, _) -> Error <| ArgumentRepeatException(debugInfo, c, p)
7878

79-
let matchArg paramName : Result<string * Constant> =
79+
let matchArg paramName : Result<string * Constant, exn> =
8080
let find = List.tryFind (fst >> (=) paramName)
8181

8282
match find inputArgs with
@@ -122,7 +122,7 @@ let private replaceParamToArgs args macroBody =
122122
NamedArgs = List.map (fun (name, arg) -> name, replaceArg arg) macroBody.NamedArgs }
123123

124124

125-
let rec private expandSingleOperation macros operation : Result<Block> =
125+
let rec private expandSingleOperation macros operation : Result<Block, exn> =
126126
match operation with
127127
| CommandCall command, debug ->
128128
match matchMacro debug command macros with

YukimiScript.Parser/ParserMonad.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module YukimiScript.Parser.ParserMonad
22

33

44
type Parser<'a> =
5-
{ Run: char list -> Result<'a * char list> }
5+
{ Run: char list -> Result<'a * char list, exn> }
66

77

88
let bind (f: 'a -> Parser<'b>) (p: Parser<'a>) : Parser<'b> =
@@ -164,7 +164,7 @@ let rec literal (x: string) : Parser<unit> =
164164
exception ParseUnfinishedException of string
165165

166166

167-
let run (line: string) (parser: Parser<'a>) : Result<'a> =
167+
let run (line: string) (parser: Parser<'a>) : Result<'a, exn> =
168168
try
169169
parser.Run(Seq.toList line)
170170
|> Result.bind

YukimiScript.Parser/Types.fs

Lines changed: 0 additions & 4 deletions
This file was deleted.

YukimiScript.Parser/YukimiScript.Parser.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<WarnOn>3390;$(WarnOn)</WarnOn>
55
</PropertyGroup>
66
<ItemGroup>
7-
<Compile Include="Types.fs" />
87
<Compile Include="Elements.fs" />
98
<Compile Include="ParserMonad.fs" />
109
<Compile Include="Basics.fs" />

0 commit comments

Comments
 (0)