Logs: freenode/#haskell
| 2021-05-18 14:24:35 | <dminuoso> | % import qualified Data.Set as Set |
| 2021-05-18 14:24:35 | <yahb> | dminuoso: |
| 2021-05-18 14:24:37 | <dminuoso> | % isUnique xs = go Set.empty where go _ [] = False; go buf (x:xs) = x `Set.elem` s || go (Set.insert x s) xs |
| 2021-05-18 14:24:37 | <yahb> | dminuoso: ; <interactive>:4:69: error:; Not in scope: `Set.elem'; Perhaps you meant one of these: `Set.elems' (imported from Data.Set), `Set.elemAt' (imported from Data.Set) |
| 2021-05-18 14:24:42 | ← | rix_ parts (~rix@117.222.67.232) () |
| 2021-05-18 14:24:57 | <dminuoso> | Guess its member |
| 2021-05-18 14:25:05 | <int-e> | it is |
| 2021-05-18 14:25:15 | → | qwerty2o joins (~qwerty2o@46.19.86.170) |
| 2021-05-18 14:25:52 | <dminuoso> | % isUnique xs = go Set.empty where go _ [] = False; go buf (x:xs) = x `Set.member` buf || go (Set.insert x buf) xs |
| 2021-05-18 14:25:52 | <yahb> | dminuoso: |
| 2021-05-18 14:25:57 | <dminuoso> | % isUnique [1,2,3] |
| 2021-05-18 14:25:57 | <yahb> | dminuoso: ; <interactive>:9:1: error:; * No instance for (Show ([()] -> Bool)) arising from a use of `print'; (maybe you haven't applied a function to enough arguments?); * In a stmt of an interactive GHCi command: print it |
| 2021-05-18 14:26:43 | <int-e> | % :t isUnique |
| 2021-05-18 14:26:43 | <yahb> | int-e: Ord a => [a] -> Bool |
| 2021-05-18 14:27:01 | <dminuoso> | (im fixing it in query) |
| 2021-05-18 14:27:37 | <int-e> | oh, precendence of `Set.member` I guess |
| 2021-05-18 14:28:22 | <int-e> | Ah, no. |
| 2021-05-18 14:28:29 | <dminuoso> | % isUnique xs = not (go Set.empty xs) where go _ [] = False; go buf (x:xs) = x `Set.member` buf || go (Set.insert x buf) xs |
| 2021-05-18 14:28:29 | <yahb> | dminuoso: |
| 2021-05-18 14:28:31 | <dminuoso> | Here we go. |
| 2021-05-18 14:28:49 | <int-e> | Haha, can't read code, didn't see the xs going unused. |
| 2021-05-18 14:29:00 | <mniip> | you can inline `not` into `go` |
| 2021-05-18 14:29:03 | <merijn> | dminuoso: Just use notMember and &&? :p |
| 2021-05-18 14:29:10 | <mniip> | exactly |
| 2021-05-18 14:29:11 | → | obiiwahn joins (~obiwahn@pdpc/supporter/student/obiwahn) |
| 2021-05-18 14:29:17 | <dminuoso> | Ah, didnt realize notMember was a thing |
| 2021-05-18 14:29:21 | <dminuoso> | yeah, then thats easier |
| 2021-05-18 14:29:51 | <dminuoso> | % isUnique xs = go Set.empty xs where go _ [] = True; go buf (x:xs) = x `Set.notMember` buf && go (Set.insert x buf) xs |
| 2021-05-18 14:29:51 | <yahb> | dminuoso: |
| 2021-05-18 14:30:17 | <dminuoso> | And, perhaps put the `go _ []` as last pattern match |
| 2021-05-18 14:30:47 | <mniip> | hmm, there's some duality between folding with a Maybe, and short circuiting continuations |
| 2021-05-18 14:31:14 | <int-e> | > let isUnique xs = and (zipWith S.notMember xs (scanl (flip S.insert) S.empty xs)) in isUnique [1,2,3] |
| 2021-05-18 14:31:15 | <lambdabot> | True |
| 2021-05-18 14:33:46 | → | ozataman joins (~ozataman@71.190.112.58) |
| 2021-05-18 14:34:36 | <safinaskar> | i don't like all these solutions :( |
| 2021-05-18 14:34:43 | × | puke quits (~vroom@217.138.252.196) (Quit: puke) |
| 2021-05-18 14:34:49 | <dminuoso> | safinaskar: What dont you like about them? |
| 2021-05-18 14:34:56 | <mniip> | \xs -> length xs == S.size (S.fromList xs) |
| 2021-05-18 14:34:58 | × | tromp quits (~tromp@dhcp-077-249-230-040.chello.nl) (Remote host closed the connection) |
| 2021-05-18 14:35:01 | <safinaskar> | dminuoso: my version is simpler to understand |
| 2021-05-18 14:35:10 | → | howdoi joins (uid224@gateway/web/irccloud.com/x-gvcdyldsercsrxxi) |
| 2021-05-18 14:35:17 | <dminuoso> | safinaskar: I think you will find my last `isUnique` is very simple to understand. |
| 2021-05-18 14:35:19 | <merijn> | 1THat's linear, though |
| 2021-05-18 14:35:20 | <dminuoso> | and it performs well |
| 2021-05-18 14:35:21 | <int-e> | mniip: nub xs == xs |
| 2021-05-18 14:35:42 | <merijn> | safinaskar: Mine is simpler if you give the individual parts names :p |
| 2021-05-18 14:35:46 | <merijn> | :t M.fromListWith |
| 2021-05-18 14:35:47 | <lambdabot> | Ord k => (a -> a -> a) -> [(k, a)] -> M.Map k a |
| 2021-05-18 14:36:05 | <merijn> | safinaskar: That just builds a Map and uses the given function to handle duplicate keys |
| 2021-05-18 14:36:14 | <safinaskar> | is there some set merging function? (Set a -> Set a -> Maybe (Set a)). it should return nothing, if sets intersect |
| 2021-05-18 14:36:19 | <merijn> | safinaskar: So "map (,1)" turns everything into (v, 1) tuples |
| 2021-05-18 14:36:35 | <dminuoso> | safinaskar: In my case, we just continuously put each element into a set, but beforehand we check whether we already have the element in the set. The reason it performs well, is because we have a set behind it. |
| 2021-05-18 14:36:51 | <merijn> | safinaskar: And M.fromListWith (+) builds a Map with values as keys and counts as value (adding counts for duplicate keys) |
| 2021-05-18 14:37:05 | <merijn> | safinaskar: Finally "all (==1)" checks all values in the Map are 1 |
| 2021-05-18 14:37:08 | → | ddellacosta joins (ddellacost@gateway/vpn/mullvad/ddellacosta) |
| 2021-05-18 14:37:43 | <int-e> | safinaskar: the benefit of accumulating a set (what dminuoso did; ignore my version, that was just uselessly showing off that I know how to use `scanl`) is that the function becomes lazy, wheras anything based on `sort` will have to evaluate the whole list first |
| 2021-05-18 14:37:45 | <merijn> | safinaskar: You could define a merge strategy for that and get an efficient merge that does that, but that's kinda tricky |
| 2021-05-18 14:38:45 | <dminuoso> | safinaskar: https://gist.github.com/dminuoso/3e7c5c815ce0e09a02e809d99b39e963 |
| 2021-05-18 14:39:06 | → | cub3s_ joins (bifunc2@gateway/vpn/protonvpn/bifunc2) |
| 2021-05-18 14:39:49 | <dminuoso> | All the versions presented here, revolve around the same trick. Mine is just the very explicit and simple version. |
| 2021-05-18 14:40:14 | → | dhil joins (~dhil@29.29.39.217.dyn.plus.net) |
| 2021-05-18 14:40:15 | <cub3s_> | Why does Haddock complain about "Haddock parse error on input ->" (for the second "->") ? |
| 2021-05-18 14:40:17 | <cub3s_> | newtype MyType = MyType { |
| 2021-05-18 14:40:18 | <cub3s_> | foo :: Int -- ^ documented first parameter. |
| 2021-05-18 14:40:18 | <cub3s_> | -> Int } |
| 2021-05-18 14:40:22 | → | mikoto-chan joins (~mikoto-ch@gateway/tor-sasl/mikoto-chan) |
| 2021-05-18 14:40:46 | <dminuoso> | cub3s_: Where is the first -> ? |
| 2021-05-18 14:40:49 | × | acidjnk_new quits (~acidjnk@p200300d0c72b955231b1979c10e605d9.dip0.t-ipconnect.de) (Ping timeout: 245 seconds) |
| 2021-05-18 14:40:59 | <cub3s_> | dminuoso, foo is a function Int -> Int |
| 2021-05-18 14:41:11 | × | ddellacosta quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 240 seconds) |
| 2021-05-18 14:41:28 | <cub3s_> | doesn't haddock allow documentation of funcs inside types? |
| 2021-05-18 14:41:33 | × | chele quits (~chele@ip5b40237d.dynamic.kabel-deutschland.de) (Remote host closed the connection) |
| 2021-05-18 14:41:37 | <dminuoso> | Well you said the error is generated on "the second \"->\"". I see only one, so Im wondering whether you have shown the full code |
| 2021-05-18 14:41:49 | <boxscape> | can someone think of a yahb example where ghc asks you if you want to add something to an import list? For some reason I'm not getting this error with the examples I can think of |
| 2021-05-18 14:41:55 | <cub3s_> | dminuoso, oh lol. i'm an idiot. thanks for correcting. yeah, forget "second" |
| 2021-05-18 14:43:32 | → | sm2n_ joins (~sm2n@bras-base-hmtnon143hw-grc-16-74-12-28-7.dsl.bell.ca) |
| 2021-05-18 14:44:51 | → | puke joins (~vroom@217.138.252.196) |
| 2021-05-18 14:45:52 | → | Guest_63 joins (2f0b3ecf@47.11.62.207) |
| 2021-05-18 14:45:53 | → | acidjnk_new joins (~acidjnk@p200300d0c72b9590b0627b83407696f5.dip0.t-ipconnect.de) |
| 2021-05-18 14:46:16 | × | sm2n quits (~sm2n@bras-base-hmtnon143hw-grc-16-74-12-28-150.dsl.bell.ca) (Ping timeout: 252 seconds) |
| 2021-05-18 14:47:02 | <Guest_63> | how to remove ghcup fully from my ubuntu machine? |
| 2021-05-18 14:47:19 | → | qwerty2o_ joins (~qwerty2o@46.19.85.75) |
| 2021-05-18 14:48:03 | → | rayyyy joins (~nanoz@gateway/tor-sasl/nanoz) |
| 2021-05-18 14:49:48 | × | hypercube quits (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com) (Quit: WeeChat 3.1) |
| 2021-05-18 14:50:26 | × | qwerty2o quits (~qwerty2o@46.19.86.170) (Ping timeout: 240 seconds) |
| 2021-05-18 14:51:38 | mayleesia | is now known as maylee |
| 2021-05-18 14:52:00 | <[exa]> | Guest_63: how did you install it? |
| 2021-05-18 14:52:23 | <Guest_63> | i installed the haskell platform |
| 2021-05-18 14:53:21 | <[exa]> | hm not sure at that (I install it manually), but guess people here will know precisely |
| 2021-05-18 14:53:28 | → | argento joins (~argent0@168.227.96.26) |
| 2021-05-18 14:53:55 | × | qwerty2o_ quits (~qwerty2o@46.19.85.75) (Read error: Connection reset by peer) |
| 2021-05-18 14:54:01 | × | ozataman quits (~ozataman@71.190.112.58) (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
| 2021-05-18 14:54:14 | <maerwald> | Guest_63: remove ~/.ghcup |
| 2021-05-18 14:55:13 | <Guest_63> | maerwald:this didn't eork :( |
| 2021-05-18 14:55:20 | → | parabolize joins (~paraboliz@98.43.173.221) |
| 2021-05-18 14:55:53 | <maerwald> | I don't know what that means |
| 2021-05-18 14:56:12 | <[exa]> | Guest_63: how did it fail? |
| 2021-05-18 14:56:33 | <Guest_63> | terminal says command remove not found |
| 2021-05-18 14:56:42 | <maerwald> | lol |
| 2021-05-18 14:56:46 | × | sm2n_ quits (~sm2n@bras-base-hmtnon143hw-grc-16-74-12-28-7.dsl.bell.ca) (Remote host closed the connection) |
All times are in UTC.