úÎ!PLÐ:      !"#$%&'()*+,-./0123456789(c) Zoltan Kelemen 2017  BSD-style kelemzol@elte.hu None %,-=?@AEHUVX(#htssetsPHelper heterogeneous list for comfortable HtsSet building (with append and fill) þlet hs = fill ("a" :+ 'c' :+ True :+ ()) lookup (hs :: HtsCSet Show) == Just 'c' use () to close the list lookup (hs :: HtsCSet Show) == Just () -- is False! let hs' = fill ("a" :+ 'c' :+ True :+ () :+ ()) lookup (hs' :: HtsCSet Show) == Just () -- is OkhtssetsThe empty HtsCSethtssetsThe empty HtsCSet with proxy htssetsA HtsCSet with an element htssets$A HtsCSet with an element with proxy htssetsIs the HtsCSet is empty? 0null empty == True null (singleton "a") == False htssets$The number of elements in the HtsSet )size empty == 0 size (singleton "a") == 1 htssets!The HtsSet is contain an element? dmember (Proxy :: Proxy String) empty == False member (Proxy :: Proxy String) (singleton "a") == Truehtssets%The HtsSet is not contain an element?htssets.The HtsCSet is contain a same type of element? \let hs = insert "a" $ insert (2 :: Int) $ insert 'c' $ empty existTypeOf "string" hs == Truehtssets9The HtsCSet is contain a same type of element? (by proxy)htssets?The HtsCSet is contain a same type of element? (by fixed proxy)htssets3Apply a function to an element with a default value `appl "no ABC" (:"BC") $ singleton 'A' == "ABC" appl "no ABC" (:"BC") $ singleton "s" == "no ABC"htssetsappl specializationhtssets–Insert a new value in the HtsCSet. If the a elem is already present in the HtsCSet with type, the associated value is replaced with the supplied value 3insert "a" $ insert (2 :: Int) $ insert 'c' $ emptyhtssets"Lookup a value from in the HtsCSet Àlet hs = insert "a" $ insert (2 :: Int) $ insert 'c' $ empty lookup hs == Just "a" lookup hs == Just (2 :: Int) but lookup hs == Just 2 -- is False! Because the type of 2 is Num t => t not Inthtssets7Lookup a value from in the HtsCSet with a default valuehtssetsUpdate a value in HtsCSet plet hs = insert "a" $ insert (2 :: Int) $ insert 'c' $ empty let hs' = update (++"b") hs lookup hs' == Just "ab"htssetsDelete an element by type 8(member 'c' $ deleteByType 'b' $ singleton 'c') == Falsehtssets$Delete an element by type (by proxy) K(member 'c' $ deleteByTypeP (Proxy :: Proxy Char) $ singleton 'c') == Falsehtssets*Delete an element by type (by fixed proxy)htssetsDelete an element by condition  55(c) Zoltan Kelemen 2017  BSD-style kelemzol@elte.hu Safe%EUVXKÎ!htssetsPHelper heterogeneous list for comfortable HtsSet building (with append and fill) Èlet hs = fill ("a" :+ 'c' :+ True :+ ()) lookup hs == Just 'c' use () to close the list lookup hs == Just () -- is False! let hs' = fill ("a" :+ 'c' :+ True :+ () :+ ()) lookup hs' == Just () -- is Ok$htssetsThe empty HtsSet%htssetsA HtsSet with an element&htssetsIs the HtsSet is empty? 0null empty == True null (singleton "a") == False'htssets$The number of elements in the HtsSet )size empty == 0 size (singleton "a") == 1(htssets!The HtsSet is contain an element? dmember (Proxy :: Proxy String) empty == False member (Proxy :: Proxy String) (singleton "a") == True)htssets%The HtsSet is not contain an element?*htssets-The HtsSet is contain a same type of element? \let hs = insert "a" $ insert (2 :: Int) $ insert 'c' $ empty existTypeOf "string" hs == True+htssets8The HtsSet is contain a same type of element? (by proxy),htssets>The HtsSet is contain a same type of element? (by fixed proxy)-htssets3Apply a function to an element with a default value `appl "no ABC" (:"BC") $ singleton 'A' == "ABC" appl "no ABC" (:"BC") $ singleton "s" == "no ABC".htssetsappl specialization/htssets”Insert a new value in the HtsSet. If the a elem is already present in the HtsSet with type, the associated value is replaced with the supplied value 3insert "a" $ insert (2 :: Int) $ insert 'c' $ empty0htssets!Lookup a value from in the HtsSet Àlet hs = insert "a" $ insert (2 :: Int) $ insert 'c' $ empty lookup hs == Just "a" lookup hs == Just (2 :: Int) but lookup hs == Just 2 -- is False! Because the type of 2 is Num t => t not Int1htssets6Lookup a value from in the HtsSet with a default value2htssetsUpdate a value in HtsSet plet hs = insert "a" $ insert (2 :: Int) $ insert 'c' $ empty let hs' = update (++"b") hs lookup hs' == Just "ab"3htssetsDelete an element by type 8(member 'c' $ deleteByType 'b' $ singleton 'c') == False4htssets$Delete an element by type (by proxy) K(member 'c' $ deleteByTypeP (Proxy :: Proxy Char) $ singleton 'c') == False5htssets*Delete an element by type (by fixed proxy)6htssetsDelete an element by condition !"#$%&'()*+,-./01234567#$%&'()*+,-./0123456!" 7!5"5:      !"  #$%&htssets-0.2.0.0-Gkla5XvzIY2JN4NKMIlLJj Data.HtsCSet Data.HtsSetbase Data.ProxyProxyAppendappend:+HtsCSetemptyemptyP singleton singletonPnullsizemember notMember existTypeOf existTypeOfP existTypeOfP'appl complianceinsertlookuplookupWithDefaultupdate deleteByType deleteByTypePdeleteByTypeP' deleteWhenfill $fAppendc() $fAppendc:+HtsSet $fAppend() $fAppend:+