Add Envelope function to extract settings values

2-transfer-tools
Bram 2023-12-18 01:30:15 +01:00
parent f910c0225b
commit 5293eb4003
1 changed files with 12 additions and 2 deletions

View File

@ -1,7 +1,7 @@
module Internal.Values.Envelope exposing
( Envelope, init
, map, mapMaybe
, Settings, mapSettings
, Settings, mapSettings, extractSettings
, getContent, extract
, encode, decoder
)
@ -22,7 +22,7 @@ settings that can be adjusted manually.
## Settings
@docs Settings, mapSettings
@docs Settings, mapSettings, extractSettings
## Extract
@ -149,6 +149,16 @@ extract f (Envelope data) =
f data.content
{-| Map a function on the settings, effectively getting data that way.
This can be helpful if you have a UI that displays custom settings to a user.
-}
extractSettings : (Settings -> b) -> Envelope a -> b
extractSettings f (Envelope data) =
f data.settings
{-| Get the original item that is stored inside an Envelope.
Make sure that you're only using this if you're interested in the actual value!