Skip to content
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

Make Handle newtype abstract #4076

Merged
merged 5 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5-internal/make-handle-abstract
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make `Handle` type abstract to guarantee it always contains *valid* Handles.
2 changes: 1 addition & 1 deletion libs/types-common/src/Data/Handle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Data.Handle
( Handle (..),
( Handle (fromHandle),
parseHandle,
parseHandleEither,
isValidHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

module Test.Wire.API.Golden.Generated.BotUserView_provider where

import Data.Handle (Handle (Handle, fromHandle))
import Data.Handle (parseHandle)
import Data.Id (Id (Id))
import Data.UUID qualified as UUID (fromString)
import Imports (Maybe (Just, Nothing), fromJust)
Expand All @@ -34,7 +34,7 @@ testObject_BotUserView_provider_1 =
"\DC1\26122U5z$\CAN\GS t1\RS\\\STX\163323_4K\1108113\1030339\78439)\DC3\171456\FS\1039863\1089420n\7092\1008914\\4Nn;\171427)\182846y\SO\n|\DEL1#pK\51301b\t<v\US/>\132598+\SOH\5517\DELjJ\179985\191367Z `$"
},
botUserViewColour = ColourId {fromColourId = -8},
botUserViewHandle = Just (Handle {fromHandle = "fpa2vx"}),
botUserViewHandle = Just (fromJust (parseHandle "fpa2vx")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000000-0000-0002-0000-000200000002")))
}

Expand All @@ -48,7 +48,7 @@ testObject_BotUserView_provider_2 =
"v\1099438\1020222\SOM\989617\t\ETB\\\1068888\187702nE7?\SOH:\r\1050763m \1065605}Y\989133b_\DLEDVa\1054567uJJ|\1086658\US)\DC3C"
},
botUserViewColour = ColourId {fromColourId = -5},
botUserViewHandle = Just (Handle {fromHandle = "mz"}),
botUserViewHandle = Just (fromJust (parseHandle "mz")),
botUserViewTeam = Nothing
}

Expand All @@ -68,7 +68,7 @@ testObject_BotUserView_provider_4 =
{ botUserViewId = Id (fromJust (UUID.fromString "00000008-0000-0004-0000-000300000007")),
botUserViewName = Name {fromName = "\SUB\STX)gKj\FS\1076685\v6cg\f]N!t\\\1017810\&8\70320\&7I\ETXCS\DC4e\FS\FS"},
botUserViewColour = ColourId {fromColourId = -2},
botUserViewHandle = Just (Handle {fromHandle = "7.w"}),
botUserViewHandle = Just (fromJust (parseHandle "7.w")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000004-0000-0000-0000-000200000000")))
}

Expand All @@ -78,7 +78,7 @@ testObject_BotUserView_provider_5 =
{ botUserViewId = Id (fromJust (UUID.fromString "00000002-0000-0001-0000-000500000008")),
botUserViewName = Name {fromName = "w"},
botUserViewColour = ColourId {fromColourId = -1},
botUserViewHandle = Just (Handle {fromHandle = "tidlyhr"}),
botUserViewHandle = Just (fromJust (parseHandle "tidlyhr")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000002-0000-0004-0000-000800000005")))
}

Expand All @@ -93,7 +93,7 @@ testObject_BotUserView_provider_6 =
},
botUserViewColour = ColourId {fromColourId = -5},
botUserViewHandle =
Just (Handle {fromHandle = "uz3cgdxtkev-40624m0eh_y06g-c9isv-ob.r84rneq2vm.440nxc_n44_3d0-6u9l7"}),
Just (fromJust (parseHandle "uz3cgdxtkev-40624m0eh_y06g-c9isv-ob.r84rneq2vm.440nxc_n44_3d0-6u9l7")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000003-0000-0003-0000-000300000001")))
}

Expand All @@ -107,7 +107,7 @@ testObject_BotUserView_provider_7 =
"}$d}\RSY\1064459\1052613\96622np\1076823_\150435\1064267\&4<Ob\DC2\DLE\1086550\135013$Ph/`Q;7\1070615Z\985112\"`\SI\169008D#%"
},
botUserViewColour = ColourId {fromColourId = 3},
botUserViewHandle = Just (Handle {fromHandle = "-c7916.."}),
botUserViewHandle = Just (fromJust (parseHandle "-c7916..")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000001-0000-0005-0000-000200000001")))
}

Expand All @@ -118,12 +118,7 @@ testObject_BotUserView_provider_8 =
botUserViewName = Name {fromName = "s\1060675\46766`4Ps\990821z\SOHef"},
botUserViewColour = ColourId {fromColourId = -2},
botUserViewHandle =
Just
( Handle
{ fromHandle =
"p1brgaim3u1-2grwj1-ij_m1p0_t.vqk92o0nxg1t928_r-qj58xhcg-ai.zfj9q63h2nno5om5kt38oo58vx81b27f4f_kzra9r6.56-gfb2ymhl3c2na7_pmsio59vezrgq-09g8yd_4hv2pdj.5rm62cp39qb_v7-x3q2a2yom-so1t-cpi2x5x6o1hwabe3ruci82gfar.czdlwukqi8dhvdse3b5o4_diowoozf1p5mcget81fa_zv8eff"
}
),
Just (fromJust (parseHandle "p1brgaim3u1-2grwj1-ij_m1p0_t.vqk92o0nxg1t928_r-qj58xhcg-ai.zfj9q63h2nno5om5kt38oo58vx81b27f4f_kzra9r6.56-gfb2ymhl3c2na7_pmsio59vezrgq-09g8yd_4hv2pdj.5rm62cp39qb_v7-x3q2a2yom-so1t-cpi2x5x6o1hwabe3ruci82gfar.czdlwukqi8dhvdse3b5o4_diowoozf1p5mcget81fa_zv8eff")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000004-0000-0003-0000-000600000007")))
}

Expand All @@ -138,12 +133,7 @@ testObject_BotUserView_provider_9 =
},
botUserViewColour = ColourId {fromColourId = -7},
botUserViewHandle =
Just
( Handle
{ fromHandle =
"qsbule-m4sswyr84uqh0.nzlyuher98kp-fkxn7xydbazbdeg-j-8sco56tr4i928muztpmzc-6nlzi4ob.-4lyhr6ra.wsc7jn6wv.l1mno080ax890jgd7.u_-2.-4v3n8"
}
),
Just (fromJust (parseHandle "qsbule-m4sswyr84uqh0.nzlyuher98kp-fkxn7xydbazbdeg-j-8sco56tr4i928muztpmzc-6nlzi4ob.-4lyhr6ra.wsc7jn6wv.l1mno080ax890jgd7.u_-2.-4v3n8")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000002-0000-0003-0000-000700000002")))
}

Expand All @@ -154,7 +144,7 @@ testObject_BotUserView_provider_10 =
botUserViewName =
Name {fromName = "]\1060113<]\47337\1007468\152444\10283r\128813XH\57454\&8icz\164234|\b#\ETBW@T"},
botUserViewColour = ColourId {fromColourId = -6},
botUserViewHandle = Just (Handle {fromHandle = "oihf1d"}),
botUserViewHandle = Just (fromJust (parseHandle "oihf1d")),
botUserViewTeam = Nothing
}

Expand All @@ -168,7 +158,7 @@ testObject_BotUserView_provider_11 =
"VwU\1026161\1038025*n\1095455lxS\SYNj\1091607y\1027202\NAK_',[>\SO<\n\1072483\ETX\142043$\986707qq{\1017506\DLE\1028303j\28095\&2\RS\ETX\r\162025m\159299\r\1060110i\SYN\DLEB\30844A)}T\1057676Li:0\1091417\t{\US\1058882h#\"\SYNX\61987\50175\&2\DC3*-b\1065285\NAK\39549T\6155 \RS\173727w\178047.\n\149471X`\20164a"
},
botUserViewColour = ColourId {fromColourId = -8},
botUserViewHandle = Just (Handle {fromHandle = "pe1a"}),
botUserViewHandle = Just (fromJust (parseHandle "pe1a")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000003-0000-0001-0000-000000000001")))
}

Expand All @@ -182,7 +172,7 @@ testObject_BotUserView_provider_12 =
"\NAK3|\178314{P\1040385Y[\SO\1071159\1040158\1010776\DELN\"\GSs=8d4:'\1030848o&~*\"\CANO[T9yt,9\STX7\nx\r"
},
botUserViewColour = ColourId {fromColourId = 8},
botUserViewHandle = Just (Handle {fromHandle = "9pbwmf1pu"}),
botUserViewHandle = Just (fromJust (parseHandle "9pbwmf1pu")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000001-0000-0002-0000-000300000004")))
}

Expand All @@ -192,7 +182,7 @@ testObject_BotUserView_provider_13 =
{ botUserViewId = Id (fromJust (UUID.fromString "00000000-0000-0008-0000-000300000005")),
botUserViewName = Name {fromName = "q"},
botUserViewColour = ColourId {fromColourId = -2},
botUserViewHandle = Just (Handle {fromHandle = "3b"}),
botUserViewHandle = Just (fromJust (parseHandle "3b")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000008-0000-0002-0000-000400000004")))
}

Expand All @@ -207,12 +197,7 @@ testObject_BotUserView_provider_14 =
},
botUserViewColour = ColourId {fromColourId = 3},
botUserViewHandle =
Just
( Handle
{ fromHandle =
"c96fkuf-n70btjq075dki054avcu250987uq348n5bali201abmhiil8n9aiocxhuzuaf1gd733hi-2f7.wtlbb8d30cxymsvmb5ehb_9cu1din7j-996_h1tsvigyg"
}
),
Just (fromJust (parseHandle "c96fkuf-n70btjq075dki054avcu250987uq348n5bali201abmhiil8n9aiocxhuzuaf1gd733hi-2f7.wtlbb8d30cxymsvmb5ehb_9cu1din7j-996_h1tsvigyg")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000002-0000-0001-0000-000300000000")))
}

Expand All @@ -226,7 +211,7 @@ testObject_BotUserView_provider_15 =
"~;Q\NULY<\152250H\46721\&7\EMQ\SYNz\"\NAK7\n\26201\15743\\a\153004\DC4Ip4\151032N\US1X6\DLERM\SUBC\1068323d\DC38Cs\NULO\1112182dF\\g~vj!J\DC1\a\1078997\&3\RSHf\STX\984173c\20151;z\33583\EM\SOH\DLE\EOT\1103829\153925_\1046171-\EM\1031631+\US/&>rNy,U\1047882\&7\1005658\NAK2"
},
botUserViewColour = ColourId {fromColourId = -1},
botUserViewHandle = Just (Handle {fromHandle = "j4z9ty7y-wt_ldl_tddmmrhdfp4myz9fjrqdg2dkh5r9vxcs5z"}),
botUserViewHandle = Just (fromJust (parseHandle "j4z9ty7y-wt_ldl_tddmmrhdfp4myz9fjrqdg2dkh5r9vxcs5z")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000006-0000-0004-0000-000300000004")))
}

Expand All @@ -240,7 +225,7 @@ testObject_BotUserView_provider_16 =
"W0\DC23\179352_\150603\&9\1081508\41244!\USNh\1010987\48629\1008710+\30291\147681S\23109\94906H[sp^\EOT(\r\184575\v>I{G\CAN\1090476\129048\FS\GS\181835K\1026670oOJ\USB]t\1042482L wY\1027509\11746\DC4l5Y\46221[,TcoF~_\ENQ\r\42008\136798\ETB"
},
botUserViewColour = ColourId {fromColourId = -4},
botUserViewHandle = Just (Handle {fromHandle = "_mvtpq.f"}),
botUserViewHandle = Just (fromJust (parseHandle "_mvtpq.f")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000005-0000-0001-0000-000700000005")))
}

Expand All @@ -254,7 +239,7 @@ testObject_BotUserView_provider_17 =
")o}s)\181243+0\EOT\154402C\1048068\1060448\SID[c c\r\1108938$'f6\1002325 ~|,A\f\32588\FSJ\1011697?\166257MJp\1738\DEL\DC2:}B'\DLEQ\54387\136046\1057923\DC2A\DC4\140654\SOH\r\1012989\DC1\188221\1007075?"
},
botUserViewColour = ColourId {fromColourId = 1},
botUserViewHandle = Just (Handle {fromHandle = "f.xl"}),
botUserViewHandle = Just (fromJust (parseHandle "f.xl")),
botUserViewTeam = Nothing
}

Expand All @@ -268,7 +253,7 @@ testObject_BotUserView_provider_18 =
"\988095\134570T^ff6\SOH6@\DEL\1025500%\1044243\FSvM_s\176\ETB$K\1095116.\NAKm[\US\128932\EOT\SOH)\178049f\134315\1041068\&0kTn!9\SIL\1024745\n\a\1029970\\K(\146913\150726\SUB\NUL\1000860^W?\SOn|-\nR<\1099109\1046581\1036758\157276\GSQu\NAK\46380\FS\50047\1049174\183149\1111902b4\USly\DEL`'X%$mW]k\1051138\98086"
},
botUserViewColour = ColourId {fromColourId = -7},
botUserViewHandle = Just (Handle {fromHandle = "b-p"}),
botUserViewHandle = Just (fromJust (parseHandle "b-p")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000002-0000-0003-0000-000700000006")))
}

Expand All @@ -279,12 +264,7 @@ testObject_BotUserView_provider_19 =
botUserViewName = Name {fromName = "\CAN0\STX\STX\SOH='\b\ETX\119524Y8\1048503 \EMa\72317\134511,q\SOH'"},
botUserViewColour = ColourId {fromColourId = -1},
botUserViewHandle =
Just
( Handle
{ fromHandle =
"g_ms.jaq23mkzzhouss60itfsrux5lapflg0xqotoz76f-ori4aglkqwj-raa_wr4ypirq9c9-w17nwre3414mvmm-vgetkk-07k1dgekjrzcvk-_w33giuc8wcak590c29h457nks5xzpn6tq0wtcorgq7210uaminql8ygrklj3vh11p.sg-nrbnmm2.dxmo0zzhr3xco"
}
),
Just (fromJust (parseHandle "g_ms.jaq23mkzzhouss60itfsrux5lapflg0xqotoz76f-ori4aglkqwj-raa_wr4ypirq9c9-w17nwre3414mvmm-vgetkk-07k1dgekjrzcvk-_w33giuc8wcak590c29h457nks5xzpn6tq0wtcorgq7210uaminql8ygrklj3vh11p.sg-nrbnmm2.dxmo0zzhr3xco")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000006-0000-0000-0000-000400000008")))
}

Expand All @@ -299,11 +279,6 @@ testObject_BotUserView_provider_20 =
},
botUserViewColour = ColourId {fromColourId = -8},
botUserViewHandle =
Just
( Handle
{ fromHandle =
"p35n6vhgb5sh71n.-har73f0tp1urvyml_5ni8n01ommlrlx5chb9z7bhp_rehr1geua0--yxs5x3m3dgmvhy8-a-07gbc0owxv2d9mj_pqzss9op.ovxyrid8l36nkw1b5f4sr2.li7bmtmcwe76.zxj9lwbqtqt8v77v6ncnmebtl3whz6790x34rcyqe.jxc6glk2-7d.janj7d1.c70bjkjpzqp0pi64hoiei854tefqdlz246bht"
}
),
Just (fromJust (parseHandle "p35n6vhgb5sh71n.-har73f0tp1urvyml_5ni8n01ommlrlx5chb9z7bhp_rehr1geua0--yxs5x3m3dgmvhy8-a-07gbc0owxv2d9mj_pqzss9op.ovxyrid8l36nkw1b5f4sr2.li7bmtmcwe76.zxj9lwbqtqt8v77v6ncnmebtl3whz6790x34rcyqe.jxc6glk2-7d.janj7d1.c70bjkjpzqp0pi64hoiei854tefqdlz246bht")),
botUserViewTeam = Just (Id (fromJust (UUID.fromString "00000006-0000-0004-0000-000700000004")))
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

module Test.Wire.API.Golden.Generated.LoginId_user where

import Data.Handle (Handle (Handle, fromHandle))
import Data.Handle (parseHandle)
import Data.Maybe
import Wire.API.User (Email (Email, emailDomain, emailLocal), Phone (Phone, fromPhone))
import Wire.API.User.Auth (LoginId (..))

Expand All @@ -39,7 +40,7 @@ testObject_LoginId_user_3 =
)

testObject_LoginId_user_4 :: LoginId
testObject_LoginId_user_4 = LoginByHandle (Handle {fromHandle = "7a8gg3v98"})
testObject_LoginId_user_4 = LoginByHandle (fromJust (parseHandle "7a8gg3v98"))

testObject_LoginId_user_5 :: LoginId
testObject_LoginId_user_5 = LoginByPhone (Phone {fromPhone = "+041157889572"})
Expand All @@ -48,7 +49,7 @@ testObject_LoginId_user_6 :: LoginId
testObject_LoginId_user_6 = LoginByPhone (Phone {fromPhone = "+2351341820189"})

testObject_LoginId_user_7 :: LoginId
testObject_LoginId_user_7 = LoginByHandle (Handle {fromHandle = "lb"})
testObject_LoginId_user_7 = LoginByHandle (fromJust (parseHandle "lb"))

testObject_LoginId_user_8 :: LoginId
testObject_LoginId_user_8 = LoginByPhone (Phone {fromPhone = "+2831673805093"})
Expand All @@ -58,12 +59,7 @@ testObject_LoginId_user_9 = LoginByPhone (Phone {fromPhone = "+1091378734554"})

testObject_LoginId_user_10 :: LoginId
testObject_LoginId_user_10 =
LoginByHandle
( Handle
{ fromHandle =
"z58-6fbjhtx11d8t6oplyijpkc2.fp_lf3kpk3_.qle4iecjun2xd0tpcordlg2bwv636v3cthpgwah3undqmuofgzp8ry6gc6g-n-kxnj7sl6771hxou7-t_ps_lu_t3.4ukz6dh6fkjq2i3aggtkbpzbd1162.qv.rbtb6e.90-xpayg65z9t9lk2aur452zcs9a"
}
)
LoginByHandle (fromJust (parseHandle "z58-6fbjhtx11d8t6oplyijpkc2.fp_lf3kpk3_.qle4iecjun2xd0tpcordlg2bwv636v3cthpgwah3undqmuofgzp8ry6gc6g-n-kxnj7sl6771hxou7-t_ps_lu_t3.4ukz6dh6fkjq2i3aggtkbpzbd1162.qv.rbtb6e.90-xpayg65z9t9lk2aur452zcs9a"))

testObject_LoginId_user_11 :: LoginId
testObject_LoginId_user_11 =
Expand Down Expand Up @@ -110,14 +106,14 @@ testObject_LoginId_user_16 =
)

testObject_LoginId_user_17 :: LoginId
testObject_LoginId_user_17 = LoginByHandle (Handle {fromHandle = "e3iusdy"})
testObject_LoginId_user_17 = LoginByHandle (fromJust (parseHandle "e3iusdy"))

testObject_LoginId_user_18 :: LoginId
testObject_LoginId_user_18 =
LoginByHandle (Handle {fromHandle = "8vpices3usz1dfs4u2lf_e3jendod_szl1z111_eoj4b7k7ajj-xo.qzbw4espf3smnz_"})
LoginByHandle (fromJust (parseHandle "8vpices3usz1dfs4u2lf_e3jendod_szl1z111_eoj4b7k7ajj-xo.qzbw4espf3smnz_"))

testObject_LoginId_user_19 :: LoginId
testObject_LoginId_user_19 = LoginByHandle (Handle {fromHandle = "3jzpp2bo8"})
testObject_LoginId_user_19 = LoginByHandle (fromJust (parseHandle "3jzpp2bo8"))

testObject_LoginId_user_20 :: LoginId
testObject_LoginId_user_20 = LoginByEmail (Email {emailLocal = "", emailDomain = "\155899"})
Loading
Loading