Logs: freenode/#haskell
| 2021-04-22 10:12:34 | <lovesegfault> | is Rust's skip_while Haskell's span, kind of? |
| 2021-04-22 10:12:34 | <dibblego> | Optic' Text Char |
| 2021-04-22 10:12:45 | <lovesegfault> | Optic? |
| 2021-04-22 10:12:51 | Alleria | is now known as Guest94131 |
| 2021-04-22 10:14:28 | <slaterr> | maybe dropWhile? |
| 2021-04-22 10:14:34 | <slaterr> | > dropWhile (<5) [1..10] |
| 2021-04-22 10:14:36 | <lambdabot> | [5,6,7,8,9,10] |
| 2021-04-22 10:16:08 | <slaterr> | or T.drop for Text |
| 2021-04-22 10:16:36 | <slaterr> | :t T.dropWhile |
| 2021-04-22 10:16:37 | <lambdabot> | (Char -> Bool) -> T.Text -> T.Text |
| 2021-04-22 10:16:38 | → | philderbeast joins (~textual@bras-base-vldvpq5901w-grc-06-184-144-244-252.dsl.bell.ca) |
| 2021-04-22 10:16:42 | <lovesegfault> | oh, nice! |
| 2021-04-22 10:19:08 | <lovesegfault> | Is there a .chain() that lets me concat iterators? is is it just concat? |
| 2021-04-22 10:19:55 | × | unlink_ quits (~unlink2@p57b8541f.dip0.t-ipconnect.de) (Ping timeout: 252 seconds) |
| 2021-04-22 10:20:05 | → | unlink2 joins (~unlink2@p200300ebcf12ad00ad652fa1ddae7806.dip0.t-ipconnect.de) |
| 2021-04-22 10:20:55 | <slaterr> | example of input and output? |
| 2021-04-22 10:22:45 | <lovesegfault> | word = "abcd"; word.chars().take(1).chain(word.chars().skip(2)).collect() -> "acd" |
| 2021-04-22 10:23:22 | <lovesegfault> | word.chars().take(1).chain(word.chars().take(2)).collect() -> "aab" |
| 2021-04-22 10:23:44 | → | minoru_shiraeesh joins (~shiraeesh@46.34.207.53) |
| 2021-04-22 10:26:24 | <slaterr> | > let word = "abcd" in T.concat [T.take 1 word, T.drop 2 word] |
| 2021-04-22 10:26:26 | <lambdabot> | error: |
| 2021-04-22 10:26:26 | <lambdabot> | • Couldn't match expected type ‘T.Text’ with actual type ‘[Char]’ |
| 2021-04-22 10:26:26 | <lambdabot> | • In the second argument of ‘T.take’, namely ‘word’ |
| 2021-04-22 10:27:15 | <slaterr> | it should work with OverloadedStrings extension |
| 2021-04-22 10:27:46 | × | nfip^ quits (nfip@ip98-184-89-2.mc.at.cox.net) () |
| 2021-04-22 10:27:54 | lovesegfault | googles extension |
| 2021-04-22 10:28:29 | <idnar> | > let word = T.pack "abcd" in T.concat [T.take 1 word, T.drop 2 word] |
| 2021-04-22 10:28:31 | <lambdabot> | "acd" |
| 2021-04-22 10:28:38 | <slaterr> | {-# LANGUAGE OverloadedStrings #-} on top of .hs file, or Extensions: OverloadedStrings in cabal so that you can use it in all the files in that project |
| 2021-04-22 10:29:37 | <opqdonut> | btw does OverloadedStrings give you pattern matching on Text? |
| 2021-04-22 10:29:56 | <opqdonut> | (I expect not, but I'm willing to be surprised :) |
| 2021-04-22 10:29:57 | <slaterr> | this makes string literals polymorphic, so "abcd" is Data.String.IsString t => t, not String |
| 2021-04-22 10:30:46 | <slaterr> | opqdonut it does |
| 2021-04-22 10:30:51 | <opqdonut> | cool |
| 2021-04-22 10:30:59 | <idnar> | > let word = T.pack "abcd" in mconcat [T.take 1, T.drop 2] word |
| 2021-04-22 10:31:02 | <lambdabot> | "acd" |
| 2021-04-22 10:31:26 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds) |
| 2021-04-22 10:32:21 | <lovesegfault> | Sweet |
| 2021-04-22 10:32:46 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-04-22 10:33:07 | <idnar> | (that is possibly too cute) |
| 2021-04-22 10:34:12 | <xsperry> | :t mconcat |
| 2021-04-22 10:34:14 | <lambdabot> | Monoid a => [a] -> a |
| 2021-04-22 10:35:21 | <idnar> | the Monoid/Semigroup instance for functions gives f <> g = \x -> f x <> g x |
| 2021-04-22 10:35:47 | <olligobber> | > (drop <> take) 3 "anagram" |
| 2021-04-22 10:35:49 | <lambdabot> | "gramana" |
| 2021-04-22 10:37:30 | <slaterr> | > let word = T.pack "abcd" in (T.take 1 <> T.drop 2) word |
| 2021-04-22 10:37:32 | <lambdabot> | "acd" |
| 2021-04-22 10:37:52 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds) |
| 2021-04-22 10:38:10 | <lovesegfault> | what do I do if I want to map on [Text] ? I keep getting Expected type: Text -> [[Char]] |
| 2021-04-22 10:38:31 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-04-22 10:39:14 | <slaterr> | > map _ (undefined :: [Text]) |
| 2021-04-22 10:39:16 | <lambdabot> | error: |
| 2021-04-22 10:39:16 | <lambdabot> | Not in scope: type constructor or class ‘Text’ |
| 2021-04-22 10:39:16 | <lambdabot> | Perhaps you meant ‘T.Text’ (imported from Data.Text) |
| 2021-04-22 10:39:23 | <slaterr> | > map _ (undefined :: [T.Text]) |
| 2021-04-22 10:39:28 | <lambdabot> | error: |
| 2021-04-22 10:39:28 | <lambdabot> | • Found hole: _ :: T.Text -> b |
| 2021-04-22 10:39:28 | <lambdabot> | Where: ‘b’ is a rigid type variable bound by |
| 2021-04-22 10:39:41 | <idnar> | lovesegfault: sounds like you have Text vs String confusion |
| 2021-04-22 10:39:45 | <slaterr> | it will work, just give it a Text -> Text function |
| 2021-04-22 10:39:47 | <lovesegfault> | https://gist.github.com/e4d2141f1c7846972f2a967b18c234e5 |
| 2021-04-22 10:40:02 | <lovesegfault> | I thought my map here was giving me a Text? |
| 2021-04-22 10:43:18 | <idnar> | `\w -> T.pack (take 1 w + (filter isUpper . dropWhile isUpper) w)` is String -> Text |
| 2021-04-22 10:43:49 | <slaterr> | map (\w -> T.take 1 w `T.append` (T.filter isUpper . T.dropWhile isUpper) w) |
| 2021-04-22 10:43:58 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 265 seconds) |
| 2021-04-22 10:44:01 | <lovesegfault> | :O |
| 2021-04-22 10:44:12 | <slaterr> | :t filter |
| 2021-04-22 10:44:14 | <lambdabot> | (a -> Bool) -> [a] -> [a] |
| 2021-04-22 10:44:16 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-04-22 10:44:30 | <slaterr> | w is Text, not [Char] (aka String) |
| 2021-04-22 10:45:30 | <lovesegfault> | A bit annoying that I need to T. everything :( |
| 2021-04-22 10:45:43 | <idnar> | <> is nicer than `T.append` imo |
| 2021-04-22 10:46:07 | <lovesegfault> | idnar: is there a name for that operator? |
| 2021-04-22 10:46:19 | → | geowiesnot joins (~user@87-89-181-157.abo.bbox.fr) |
| 2021-04-22 10:47:14 | <lovesegfault> | woohoo the tests pass! |
| 2021-04-22 10:47:15 | <idnar> | not sure |
| 2021-04-22 10:47:41 | → | heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-04-22 10:47:52 | <lovesegfault> | any suggestions? https://gist.github.com/c858a83b4960a8bbc11ca9c5229b1983 |
| 2021-04-22 10:48:10 | <lovesegfault> | or, rather, how may I improve? |
| 2021-04-22 10:48:39 | <slaterr> | :t (<>) |
| 2021-04-22 10:48:40 | <lambdabot> | Semigroup a => a -> a -> a |
| 2021-04-22 10:48:46 | <ClaudiusMaximus> | @check (<>) == (mappend :: String -> String -> String) |
| 2021-04-22 10:48:47 | <lambdabot> | error: |
| 2021-04-22 10:48:48 | <lambdabot> | • No instance for (Eq (String -> String -> String)) arising from a use of ‘=... |
| 2021-04-22 10:49:12 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds) |
| 2021-04-22 10:50:20 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-04-22 10:52:01 | × | heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 245 seconds) |
| 2021-04-22 10:53:35 | <slaterr> | @pl (\c -> isSpace c || c `elem` ['-', '_']) |
| 2021-04-22 10:53:35 | <lambdabot> | liftM2 (||) isSpace (`elem` "-_") |
| 2021-04-22 10:53:45 | <slaterr> | yeah, probably not an improvement |
| 2021-04-22 10:53:58 | <lovesegfault> | What's this @pl business? |
| 2021-04-22 10:54:33 | <slaterr> | it rewrites the function using pointfree style |
| 2021-04-22 10:55:21 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 245 seconds) |
| 2021-04-22 10:55:29 | <slaterr> | @pl (\xs -> map (take 10) xs) |
| 2021-04-22 10:55:29 | <lambdabot> | map (take 10) |
| 2021-04-22 10:55:39 | <lovesegfault> | Ah, I see |
| 2021-04-22 10:55:41 | <lovesegfault> | nice |
| 2021-04-22 10:55:47 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-04-22 10:57:02 | <idnar> | (\w -> T.take 1 w <> (T.filter isUpper . T.dropWhile isUpper) w) is (T.take 1 <> (T.filter isUpper . T.dropWhile isUpper)) |
| 2021-04-22 10:57:51 | → | gzj joins (~gzj@unaffiliated/gzj) |
All times are in UTC.