From b52c37df64ab2a3e261c7f9daba9e7b812e55706 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 3 Feb 2017 15:42:21 -0400 Subject: response --- ...mment_5_6fbd29f568ec8b97be47874e2aac57a3._comment | 20 ++++++++++++++++++++ src/Propellor/Property.hs | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment diff --git a/doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment b/doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment new file mode 100644 index 00000000..16819bd6 --- /dev/null +++ b/doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment @@ -0,0 +1,20 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 5""" + date="2017-02-03T19:32:58Z" + content=""" +What you're looking for is not a regexp, but Haskell's [pattern +matching](https://www.haskell.org/tutorial/patterns.html). + +For example: + + myproperty :: Property Debian + myproperty = withOS "some desc here" $ \w o -> case o of + -- Pattern match on the OS, to get the Debian stable release + (Just (System (Debian _kernel (Stable release)) _arch)) -> + ensureProperty w $ Apt.setSourcesListD (sourcesLines release) "mysources" + _ -> unsupportedOS + + sourcesLines :: Release -> [Line] + sourcesLines release = undefined +"""]] diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 06145333..7860a3df 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -308,8 +308,8 @@ pickOS a b = c `addChildren` [toChildProperty a, toChildProperty b] -- -- > myproperty :: Property Debian -- > myproperty = withOS "foo installed" $ \w o -> case o of --- > (Just (System (Debian (Stable release)) arch)) -> ensureProperty w ... --- > (Just (System (Debian suite) arch)) -> ensureProperty w ... +-- > (Just (System (Debian kernel (Stable release)) arch)) -> ensureProperty w ... +-- > (Just (System (Debian kernel suite) arch)) -> ensureProperty w ... -- > _ -> unsupportedOS' -- -- Note that the operating system specifics may not be declared for all hosts, -- cgit v1.2.3