aboutsummaryrefslogtreecommitdiff
path: root/src/client/static
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-09-13 21:36:32 +0200
committerNoah Loomans <noahloomans@gmail.com>2017-09-13 21:36:32 +0200
commit83034116b02497576d97bffc9e91a5476cc60d41 (patch)
treef0a89cf605e6613101cb31b7d9ae211ad37a8f70 /src/client/static
parente87bf34e06f8bec3c6622102528c2d685b3cbb5b (diff)
decode union type
Diffstat (limited to 'src/client/static')
-rw-r--r--src/client/static/elm.js44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/client/static/elm.js b/src/client/static/elm.js
index 1ac0ee4..cbab2b5 100644
--- a/src/client/static/elm.js
+++ b/src/client/static/elm.js
@@ -7893,6 +7893,32 @@ var _user$project$Main$User = F2(
function (a, b) {
return {type_: a, value: b};
});
+var _user$project$Main$Student = {ctor: 'Student'};
+var _user$project$Main$Room = {ctor: 'Room'};
+var _user$project$Main$Teacher = {ctor: 'Teacher'};
+var _user$project$Main$Class = {ctor: 'Class'};
+var _user$project$Main$decodeUserType = A2(
+ _elm_lang$core$Json_Decode$andThen,
+ function (s) {
+ var _p0 = s;
+ switch (_p0) {
+ case 's':
+ return _elm_lang$core$Json_Decode$succeed(_user$project$Main$Student);
+ case 'c':
+ return _elm_lang$core$Json_Decode$succeed(_user$project$Main$Class);
+ case 't':
+ return _elm_lang$core$Json_Decode$succeed(_user$project$Main$Teacher);
+ case 'r':
+ return _elm_lang$core$Json_Decode$succeed(_user$project$Main$Room);
+ default:
+ return _elm_lang$core$Json_Decode$fail(
+ A2(
+ _elm_lang$core$Basics_ops['++'],
+ 'What the f*ck is ',
+ A2(_elm_lang$core$Basics_ops['++'], s, '?')));
+ }
+ },
+ _elm_lang$core$Json_Decode$string);
var _user$project$Main$decodeUser = A3(
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
'value',
@@ -7900,33 +7926,29 @@ var _user$project$Main$decodeUser = A3(
A3(
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
'type',
- _elm_lang$core$Json_Decode$string,
+ _user$project$Main$decodeUserType,
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$decode(_user$project$Main$User)));
var _user$project$Main$decodeUsers = _elm_lang$core$Json_Decode$list(_user$project$Main$decodeUser);
var _user$project$Main$init = function (flags) {
- var _p0 = A2(_elm_lang$core$Json_Decode$decodeValue, _user$project$Main$decodeUsers, flags);
- if (_p0.ctor === 'Ok') {
+ var _p1 = A2(_elm_lang$core$Json_Decode$decodeValue, _user$project$Main$decodeUsers, flags);
+ if (_p1.ctor === 'Ok') {
return {
ctor: '_Tuple2',
- _0: _user$project$Main$Model(_p0._0),
+ _0: _user$project$Main$Model(_p1._0),
_1: _elm_lang$core$Platform_Cmd$none
};
} else {
return _elm_lang$core$Native_Utils.crashCase(
'Main',
{
- start: {line: 40, column: 5},
- end: {line: 45, column: 28}
+ start: {line: 44, column: 5},
+ end: {line: 49, column: 28}
},
- _p0)(_p0._0);
+ _p1)(_p1._0);
}
};
var _user$project$Main$main = _elm_lang$html$Html$programWithFlags(
{init: _user$project$Main$init, update: _user$project$Main$update, view: _user$project$Main$view, subscriptions: _user$project$Main$subscriptions})(_elm_lang$core$Json_Decode$value);
-var _user$project$Main$Student = {ctor: 'Student'};
-var _user$project$Main$Room = {ctor: 'Room'};
-var _user$project$Main$Teacher = {ctor: 'Teacher'};
-var _user$project$Main$Class = {ctor: 'Class'};
var Elm = {};
Elm['Main'] = Elm['Main'] || {};