Skip to content

Add coinclusionAssoc, wrenchAssoc, retrenchAssoc #36

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

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

At-sushi
Copy link
Contributor

Features

  • Add associated editions of coinclusion, wrench, retrench in Data.Extensible.Nullable.

Implemented for the convenience. These can be used to defaulting record values.

Example use-case

{-# LANGUAGE DataKinds, TypeOperators, FlexibleContexts, OverloadedLabels, OverloadedStrings, PolyKinds #-}

import Data.Extensible

type Parameters = Record '[
    "name" >: String
    , "width" >: Int
    , "height" >: Int
    , "id" >: Int
    ]

defaultPara :: Parameters
defaultPara =
    #name @= "untitled"
    <: #width @= 640
    <: #height @= 480
    <: #id @= -1
    <: nil

main :: IO ()
main = do
    let para = #id @= 0 <: #name @= "testApp" <: nil
        result = setDefaultValues defaultPara para
    print result -- name @= "testApp" <: width @= 640 <: height @= 480 <: id @= 0 <: nil

setDefaultValues :: (Generate ys, IncludeAssoc ys xs) => (ys :& h) -> (xs :& h) -> (ys :& h)
setDefaultValues ys = hzipWith fromNullable ys . wrenchAssoc

Copy link
Owner

@fumieval fumieval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@fumieval fumieval merged commit d99276c into fumieval:master Feb 21, 2024
@At-sushi At-sushi deleted the pull_features branch April 7, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants