Created
September 25, 2019 16:10
-
-
Save Woody88/51bbaf36c3ba48d1a6a05c969f379e07 to your computer and use it in GitHub Desktop.
How to return subset of a record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Test where | |
| import Prim.Row | |
| import Record as Record | |
| type UpdateProps r | |
| = ( name :: String | |
| , purgeHistoryDays :: String | |
| , purgeImmediate :: String | |
| , forceRestartTime :: Int | |
| | r | |
| ) | |
| type UpdateResult r | |
| = ("@type" :: String | r) | |
| x :: forall r r3 r4 props rest t. | |
| Union props rest (UpdateProps r) | |
| => Union r3 t (UpdateResult props) | |
| => Nub (UpdateResult props) r3 | |
| => { | props } | |
| -> { | r3 } | |
| x rec = Record.merge {"@type": "hello"} rec | |
| y :: forall r r3 r4 props rest t. | |
| Union props rest (UpdateProps ()) | |
| => { | props } | |
| -> String | |
| y rec = "asdsa" | |
| -- How can I get the compiler to compile as long as the return value of this function returns a subset of UpdateProps?? | |
| z :: forall r r3 r4 props rest t. | |
| Union props rest (UpdateProps ()) | |
| => { | props } | |
| -> { | (UpdateResult props) } | |
| z rec = { "@type": "hello", name: "" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment