Logs: freenode/#haskell
| 2020-10-21 10:47:01 | <lambdabot> | f a = |
| 2020-10-21 10:47:01 | <lambdabot> | (\ b -> |
| 2020-10-21 10:47:01 | <lambdabot> | case a b of |
| 2020-10-21 10:47:01 | <lambdabot> | (c, _) -> c, |
| 2020-10-21 10:47:01 | <lambdabot> | \ d -> |
| 2020-10-21 10:47:03 | <lambdabot> | case a d of |
| 2020-10-21 10:47:05 | <lambdabot> | (_, e) -> e) |
| 2020-10-21 10:47:29 | <ski> | but Djinn doesn't know `Num', nor does it understand recursive data types like `[]' |
| 2020-10-21 10:47:39 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-21 10:48:07 | <ski> | @djinn (a -> a -> a) -> Maybe a -> Maybe a |
| 2020-10-21 10:48:07 | <lambdabot> | f a b = |
| 2020-10-21 10:48:07 | <lambdabot> | case b of |
| 2020-10-21 10:48:08 | <lambdabot> | Nothing -> Nothing |
| 2020-10-21 10:48:10 | <lambdabot> | Just c -> Just (a c c) |
| 2020-10-21 10:48:33 | <nicknick> | I see. |
| 2020-10-21 10:48:34 | × | stefan-__ quits (~cri@42dots.de) (Read error: Connection reset by peer) |
| 2020-10-21 10:48:52 | → | stefan-__ joins (~cri@42dots.de) |
| 2020-10-21 10:49:23 | × | p-core quits (~Thunderbi@2001:718:1e03:5128:2ab7:7f35:48a1:8515) (Remote host closed the connection) |
| 2020-10-21 10:49:56 | <nicknick> | How can I solve f :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] ? Is that hard? |
| 2020-10-21 10:50:12 | <olligobber> | :t zip |
| 2020-10-21 10:50:13 | <lambdabot> | [a] -> [b] -> [(a, b)] |
| 2020-10-21 10:50:18 | <olligobber> | :t zipWith |
| 2020-10-21 10:50:19 | <lambdabot> | (a -> b -> c) -> [a] -> [b] -> [c] |
| 2020-10-21 10:50:39 | <nicknick> | :t zip or :t zipWith |
| 2020-10-21 10:50:40 | <lambdabot> | error: |
| 2020-10-21 10:50:40 | <lambdabot> | • Couldn't match expected type ‘[a]’ |
| 2020-10-21 10:50:40 | <lambdabot> | with actual type ‘t0 Bool -> Bool’ |
| 2020-10-21 10:50:47 | <nicknick> | Which is better? |
| 2020-10-21 10:50:57 | <olligobber> | zipWith does what you asked for |
| 2020-10-21 10:51:00 | <ski> | better for what ? |
| 2020-10-21 10:51:04 | <olligobber> | I just forgot that zip doesn't |
| 2020-10-21 10:51:45 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 240 seconds) |
| 2020-10-21 10:51:53 | <Echosolace> | @type foldl |
| 2020-10-21 10:51:54 | <lambdabot> | Foldable t => (b -> a -> b) -> b -> t a -> b |
| 2020-10-21 10:52:20 | <Echosolace> | Breaking this down, how many parameters are here? |
| 2020-10-21 10:52:23 | <ski> | > zipWith (+) [0,1,2] [30,40,50] |
| 2020-10-21 10:52:25 | <lambdabot> | [30,41,52] |
| 2020-10-21 10:52:34 | <Echosolace> | Is (b -> a -> b) a parameter? |
| 2020-10-21 10:52:35 | <ski> | > liftA2 (+) [0,1,2] [30,40,50] |
| 2020-10-21 10:52:36 | <lambdabot> | [30,40,50,31,41,51,32,42,52] |
| 2020-10-21 10:52:44 | <ski> | Echosolace : it's the type of the first parameter, yes |
| 2020-10-21 10:52:53 | × | Sanchayan quits (~Sanchayan@122.181.211.206) (Quit: leaving) |
| 2020-10-21 10:53:00 | <olligobber> | oh yeah, liftA2 also works |
| 2020-10-21 10:53:17 | <Echosolace> | but b is the first parameter, no? |
| 2020-10-21 10:53:22 | <ski> | no |
| 2020-10-21 10:53:26 | <Echosolace> | Crap. |
| 2020-10-21 10:53:26 | × | stefan-__ quits (~cri@42dots.de) (Read error: Connection reset by peer) |
| 2020-10-21 10:53:34 | <Echosolace> | Where do you see the first parameter? |
| 2020-10-21 10:53:39 | <nicknick> | I think guys didn't understand :) I need a function which satisfies this type signature f :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:53:40 | → | stefan-__ joins (~cri@42dots.de) |
| 2020-10-21 10:53:46 | <ski> | consider |
| 2020-10-21 10:53:50 | <ski> | foldl (+) 0 (2:3:5:7:[]) |
| 2020-10-21 10:54:03 | <Echosolace> | Yep. |
| 2020-10-21 10:54:11 | <olligobber> | nicknick, zipWith and liftA2 both have that type signature |
| 2020-10-21 10:54:16 | <Echosolace> | Oh. |
| 2020-10-21 10:54:22 | <olligobber> | well, a supertype of that type signature |
| 2020-10-21 10:54:36 | <ski> | `(+)' has type corrersponding to `b -> a -> b', `0' has type corresponding to `b', and `2:3:5:7:[]' has type corresponding to `t a' (or `[a]' more specifically). result has type `b' |
| 2020-10-21 10:55:02 | <ski> | @type zipWith :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:55:03 | <lambdabot> | Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:55:07 | <ski> | @type liftA2 :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:55:08 | <lambdabot> | Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:55:25 | <olligobber> | but there are other functions with that type signature |
| 2020-10-21 10:55:27 | <ski> | nicknick : both of the offered functions does satisfy that signature |
| 2020-10-21 10:55:45 | <ski> | (but they're more general, does also satisfy other signatures, as well) |
| 2020-10-21 10:55:56 | <nicknick> | What if I have to write |custom| function? |
| 2020-10-21 10:55:58 | <olligobber> | @type (\_ _ _->[]) :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:55:59 | <lambdabot> | Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:56:06 | <ski> | nicknick : then write a custom function ? |
| 2020-10-21 10:56:13 | <ski> | e.g. the one olligobber suggested |
| 2020-10-21 10:57:01 | <olligobber> | @type (\f x y -> f (sum x) (sum y)) |
| 2020-10-21 10:57:02 | <lambdabot> | (Foldable t1, Foldable t2, Num t3, Num t4) => (t3 -> t4 -> t5) -> t1 t3 -> t2 t4 -> t5 |
| 2020-10-21 10:57:20 | → | alp joins (~alp@2a01:e0a:58b:4920:f968:6025:1be8:4fb9) |
| 2020-10-21 10:57:20 | <ski> | @type let customFunction :: Num a => (a -> a -> c) -> [a] -> [a] -> [c]; customFunction f xs ys = zipWith f ys xs in customFunction |
| 2020-10-21 10:57:22 | <lambdabot> | Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:57:29 | <olligobber> | ^ |
| 2020-10-21 10:57:47 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-21 10:58:08 | <ski> | nicknick : there's many different such functions, having the given signature |
| 2020-10-21 10:58:08 | <olligobber> | @type (\f x y -> [f (sum x) (sum y)]) :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:58:09 | <lambdabot> | Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:58:30 | <olligobber> | there are infinitely many functions with that type |
| 2020-10-21 10:58:41 | → | justsomeguy joins (~justsomeg@unaffiliated/--/x-3805311) |
| 2020-10-21 10:58:42 | × | avoandmayo quits (~textual@122-58-158-238-adsl.sparkbb.co.nz) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-21 10:59:04 | <ski> | Echosolace : in that example, `b' would be `Integer', and `a' would also be `Integer'. in your earlier example, however, `b' would be `Bool' |
| 2020-10-21 10:59:39 | <olligobber> | @type (\f _ _ -> [f 0 0]) :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:59:40 | <lambdabot> | Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 10:59:47 | <Echosolace> | Ski: Got an ADA address I can tip? |
| 2020-10-21 11:00:13 | <ski> | dunno what that is |
| 2020-10-21 11:00:13 | → | raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) |
| 2020-10-21 11:00:48 | <Echosolace> | It's a crypto thing. Based on haskell. Big player in the space. |
| 2020-10-21 11:00:54 | <ski> | i see |
| 2020-10-21 11:01:04 | → | avoandmayo joins (~textual@122-58-158-238-adsl.sparkbb.co.nz) |
| 2020-10-21 11:01:11 | <Echosolace> | daedaluswallet.io |
| 2020-10-21 11:01:55 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 246 seconds) |
| 2020-10-21 11:02:51 | × | da39a3ee5e6b4b0d quits (~textual@n11211935170.netvigator.com) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-21 11:03:31 | <olligobber> | @type (\f _ _ -> f <$> [0..] <*> [0..]) :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
| 2020-10-21 11:03:33 | <lambdabot> | error: |
| 2020-10-21 11:03:33 | <lambdabot> | • Could not deduce (Enum a1) |
| 2020-10-21 11:03:33 | <lambdabot> | arising from the arithmetic sequence ‘0 .. ’ |
| 2020-10-21 11:03:37 | <olligobber> | -_- |
| 2020-10-21 11:03:57 | <olligobber> | @type (\f _ _ -> f <$> fromInteger [0..] <*> fromInteger [0..]) :: Num a => (a -> a -> c) -> [a] -> [a] -> [c] |
All times are in UTC.