Skip to content

Instantly share code, notes, and snippets.

@Woody88
Created September 25, 2019 16:10
Show Gist options
  • Select an option

  • Save Woody88/51bbaf36c3ba48d1a6a05c969f379e07 to your computer and use it in GitHub Desktop.

Select an option

Save Woody88/51bbaf36c3ba48d1a6a05c969f379e07 to your computer and use it in GitHub Desktop.
How to return subset of a record
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