Skip to content

Commit 5f3cdb2

Browse files
committed
Upgrade projects to Gren 0.3.0
1 parent 8da1755 commit 5f3cdb2

File tree

18 files changed

+15133
-17644
lines changed

18 files changed

+15133
-17644
lines changed

cat/gren.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"source-directories": [
55
"src"
66
],
7-
"gren-version": "0.2.1",
7+
"gren-version": "0.3.0",
88
"dependencies": {
99
"direct": {
10-
"gren-lang/core": "3.0.2",
11-
"gren-lang/node": "1.2.0"
10+
"gren-lang/core": "4.0.0",
11+
"gren-lang/node": "2.0.0"
1212
},
1313
"indirect": {}
1414
}

cat/src/Main.gren

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Main exposing (main)
22

33
import Node
44
import Bytes exposing (Bytes)
5-
import Bytes.Encode as BE
65
import Stream exposing (Stream)
76
import Node.Program as Program exposing (Program)
87
import FileSystem
@@ -19,7 +18,9 @@ main =
1918

2019

2120
type alias Model =
22-
{ stdout : Stream }
21+
{ stdout : Stream
22+
, stderr : Stream
23+
}
2324

2425

2526
type Msg
@@ -34,6 +35,7 @@ init =
3435
Program.startProgram
3536
{ model =
3637
{ stdout = nodeConfig.stdout
38+
, stderr = nodeConfig.stderr
3739
}
3840
, command =
3941
case nodeConfig.args of
@@ -42,9 +44,8 @@ init =
4244
|> Task.attempt OpenResult
4345

4446
_ ->
45-
Stream.send nodeConfig.stderr <|
46-
BE.encode <|
47-
BE.string "Exactly one argument is required: the file name to read\n"
47+
Stream.sendLine nodeConfig.stderr <|
48+
"Exactly one argument is required: the file name to read"
4849
}
4950

5051

@@ -60,16 +61,21 @@ update msg model =
6061

6162
OpenResult (Err error) ->
6263
{ model = model
63-
, command = Cmd.none
64+
, command =
65+
Stream.sendLine model.stderr <|
66+
"Failed to open file"
6467
}
6568

6669
ReadResult (Ok bytes) ->
6770
{ model = model
68-
, command = Stream.send model.stdout bytes
71+
, command =
72+
Stream.send model.stdout bytes
6973
}
7074

7175
ReadResult (Err error) ->
7276
{ model = model
73-
, command = Cmd.none
77+
, command =
78+
Stream.sendLine model.stderr <|
79+
"Failed to read file"
7480
}
7581

0 commit comments

Comments
 (0)