<    April 2017    >
Su Mo Tu We Th Fr Sa  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28 29  
00:00 Rodya_ joined
00:02 eacameron joined
00:03 geekosaur joined
00:06 fizbin joined
00:06 contiver joined
00:06 unbalancedparen joined
00:08 pacak joined
00:08 eacameron joined
00:13 e14 joined
00:14 mizu_no_oto joined
00:14 fred-fri joined
00:15 <fred-fri> > putStr $ show $ min [1,2]
00:15 <lambdabot> <IO ()>
00:15 eacameron joined
00:15 sleffy joined
00:15 <fred-fri> ^^^ how can i fix the above?
00:15 <fred-fri> > putStr $ show [1,2]
00:15 <lambdabot> <IO ()>
00:15 <geekosaur> you can't do I/O in lambdabot
00:15 <monochrom> What is there to fix?
00:17 <MarcelineVQ> fred-fri: you may have wanted minimum
00:17 <fred-fri> putStr $ show [1,2] prints the list as expected, but when adding min it doesnt because it looses the show type i think
00:17 <geekosaur> :t min
00:17 <lambdabot> Ord a => a -> a -> a
00:17 <monochrom> Then what MarcelineVQ said.
00:17 oisdk joined
00:17 <geekosaur> has nothing to do with Show
00:18 <fred-fri> MarcelineVQ, geekosaur, monochrom I'm an idiot, thank you all
00:18 <geekosaur> however it probably gets reported that way because it thinks you are trying to show a function, which is a partial application of `min`
00:18 <fred-fri> makes sense
00:20 <monochrom> @type putStr $ show $ min [1,2]
00:20 <lambdabot> IO ()
00:20 <monochrom> @type show $ min [1,2]
00:20 <lambdabot> String
00:20 <monochrom> > show $ min [1,2]
00:20 <lambdabot> "<[Integer] -> [Integer]>"
00:20 <monochrom> Oh ha, that's why lambdabot doesn't give a type error either.
00:20 eacameron joined
00:21 <MarcelineVQ> that's an odd thing to have on by default :>
00:22 takle joined
00:22 <geekosaur> huh? the only way to "turn it off" is disallow partial application
00:23 <c0dehero> slightly off-topip, but anyone wanna help make the haskell logo on /r/place?
00:24 <geekosaur> unless you mean the Show instance for functions that lb uses
00:24 <MarcelineVQ> geekosaur: it wouldn't be a case of not defineing a show isntance for functions?
00:24 dfeuer joined
00:24 <monochrom> We agree violently.
00:24 <geekosaur> I think that's geenrally considered helpful given lambdabot's normal usage
00:25 <MarcelineVQ> I get it for IO results because you want to communicate that it doesn't execute but it seems out of place otherwise
00:26 <monochrom> I have a cunning plan. Every time you use lambdabot you first fill out a 5-minute form to choose your settings. :)
00:26 <MarcelineVQ> sounds reasonable, your reward is being told about @let import ...
00:27 arpl left
00:27 eacameron joined
00:28 <MarcelineVQ> "lambdabot: thank you for filling out this form, btw you can import with @let import ... and use @index to find out where things come from"
00:29 lambda-11235 joined
00:30 splanch joined
00:31 <Sornaensis> @let import System.IO.Unsafe
00:31 <lambdabot> .L.hs:139:1: error:
00:31 <lambdabot> System.IO.Unsafe: Can't be safely imported!
00:31 <lambdabot> The module itself isn't safe.
00:31 <monochrom> hehe
00:32 jmcarthur joined
00:33 eacameron joined
00:33 conal joined
00:34 MarioBranco joined
00:35 zeroed joined
00:36 dixie_ joined
00:37 hybrid joined
00:37 systadmin joined
00:38 ali_bush joined
00:38 ali_bush joined
00:38 takle joined
00:39 <lolisa> > undefined
00:39 <lambdabot> *Exception: Prelude.undefined
00:40 <lolisa> > unsafePerformIO
00:40 <lambdabot> error: Variable not in scope: unsafePerformIO
00:41 <lolisa> @let import Unsafe.Coerce
00:41 <lambdabot> .L.hs:145:1: error:
00:41 <lambdabot> Unsafe.Coerce: Can't be safely imported!
00:41 <lambdabot> The module itself isn't safe.
00:41 fizbin joined
00:41 <MarcelineVQ> what have I done
00:42 conal joined
00:43 <lolisa> @help
00:43 <lambdabot> help <command>. Ask for help for <command>. Try 'list' for all commands
00:43 <lolisa> @help command
00:43 <lambdabot> help <command>. Ask for help for <command>. Try 'list' for all commands
00:44 <lolisa> Wait, what is karma
00:45 <lolisa> @karma lambdabot
00:45 <lambdabot> lambdabot has a karma of 33
00:45 np356 joined
00:50 peterbecich joined
00:56 safe joined
00:56 codesoup joined
00:57 sujeet joined
00:57 ericsagnes joined
00:57 eacameron joined
00:58 takle joined
00:58 Coldblackice joined
01:04 hoknamahn joined
01:05 <fred-fri> whats a good way to round to nearest five?
01:07 <ertes> @let round5 x = 5 * round (x/5)
01:07 <lambdabot> Defined.
01:07 <ertes> > map round5 [2,3,7,8]
01:07 <lambdabot> [0,5,5,10]
01:08 Supersonic112_ joined
01:10 Kundry_Wag joined
01:15 <lolisa> > fix
01:15 <lambdabot> error:
01:15 <lambdabot> • No instance for (Typeable a0)
01:15 <lambdabot> arising from a use of ‘show_M228743708076234977828657’
01:15 scottj joined
01:15 <lolisa> > 1 + (fix id)
01:15 <lambdabot> mueval-core: Time limit exceeded
01:16 stef_204 joined
01:20 irclogger_com joined
01:20 Topic for
01:21 <pikajude> every time
01:21 meba joined
01:21 sujeet joined
01:24 <Cale> Recursion memes
01:25 <ertes> > fix (1 +)
01:25 <lambdabot> 9999999999999999999999999999999999999999999999999999999999999999999999999999...
01:27 <ChaiTRex> Trickery!
01:27 eacameron joined
01:27 <orion> How long do @let definitions persist?
01:27 <Cale> Until someone does an @undefine
01:28 <orion> @undefine round5
01:28 <lambdabot> There's currently no way to undefine just one thing. Say @undefine (with no extra words) to undefine everything.
01:28 <orion> @undefine
01:28 <lambdabot> Undefined.
01:28 <geekosaur> note that there is not a separate list for people in /msg, only the global one
01:28 <orion> So in other words, I could @let something in a private message and use it here?
01:28 <geekosaur> yes
01:28 <geekosaur> but also @undefine here could mess up people's private sessions
01:29 <geekosaur> (or someone using it in their session can mess things up for other uses including here)
01:29 <orion> I see.
01:30 vaibhavsagar joined
01:30 <Cale> Let lambdabot serve as a warning about global mutable state
01:30 <orion> ha
01:30 np356 joined
01:31 <MarcelineVQ> warning, global mutable state is cute robut
01:32 <fred-fri> > map read ["1","2"]
01:32 <lambdabot> [*Exception: Prelude.read: no parse
01:32 <geekosaur> > map read ["1","2"] :: [Int]
01:32 <lambdabot> [1,2]
01:33 parcs joined
01:33 <ChaiTRex> > read "[1, 2]" :: [Int]
01:33 <lambdabot> [1,2]
01:34 <fred-fri> > map (read::String->Int) ["1","2"]
01:34 <lambdabot> [1,2]
01:34 <geekosaur> read is polymorphic, and defaulting in ghci or lambdabot makes it default to type () (see the ExtendedDefaultRules extension)
01:34 <fred-fri> geekosaur wins
01:37 <ChaiTRex> > (map::(String->Int)->[String]->[Int]) (read::String->Int) ([("1"::String),("2"::String)]::[String])
01:37 <lambdabot> [1,2]
01:38 nut joined
01:38 eacameron joined
01:39 alasi joined
01:40 kirillow_ joined
01:41 <ski> @type read `asTypeIn` \read -> map (chr . read) ["1","2"]
01:41 <lambdabot> String -> Int
01:41 ubsan_ joined
01:42 sleffy joined
01:43 eacameron joined
01:46 eacamero_ joined
01:51 gugah joined
01:52 systemfault joined
01:52 <fred-fri> lambdabot is great but is there any pastebin like app where you can put share haskell and its runnable?
01:54 <geekosaur> codepad.org ?
01:56 <fred-fri> cool
01:57 mizu_no_oto joined
01:58 Rainb joined
02:00 hucksy_ joined
02:01 raynold joined
02:01 brynedwardz joined
02:01 mjz19910 joined
02:01 kappter joined
02:02 chrisdotcode joined
02:03 parcs left
02:04 Guest71 joined
02:05 mjz19910 joined
02:06 mjz19910 joined
02:08 takle joined
02:09 <fred-fri> i feel terrible for asking these basic questions but i cant get this to compile no matter how or where i put number conversions https://pastebin.com/BzQs4XVX
02:10 <fred-fri> btw i know i can just do the single conversion in the read
02:10 Kundry_Wag joined
02:11 mac10688 joined
02:11 <fred-fri> its calling the grade, and by extension the round5, functions that's the problem
02:11 bshum1 joined
02:12 vaibhavsagar joined
02:13 <glguy> fred-fri: there aren't any types that are both RealFrac and Integral that you'll want
02:14 <glguy> instead of round (x / 5). use x `div` 5
02:16 mjz19910 joined
02:17 takle joined
02:17 exferenceBot joined
02:19 mjz19910 joined
02:21 Goplat joined
02:21 doomlord joined
02:22 hexagoxel joined
02:24 <fred-fri> glguy, problem has shifted =) any ideas? https://pastebin.com/bSw5VXLt
02:25 mjz19910 joined
02:26 <fred-fri> i keep reading eg https://wiki.haskell.org/Converting_numbers but
02:26 mekeor joined
02:26 suppi joined
02:26 ryan_vw joined
02:26 <divVerent> fred-fri: I don't understand round5's type signature
02:26 <divVerent> what is that monster argument supposed to be
02:27 <divVerent> when the definition itself just expects a somewhat numeric x?
02:27 <divVerent> Also, your div should be a `div`.
02:27 takle joined
02:28 <divVerent> that grade definition is also ODD
02:28 ryan_vw left
02:28 <divVerent> like, it should map 40, 41, 42, 43, 44, 45 into 40, 41, 42, 45, 45, 45
02:29 aarvar joined
02:29 dsh joined
02:29 <divVerent> because if x >= 38, it'll pick the max of the rounded value and x itself
02:30 mjz19910 joined
02:30 <lpaste> ExpHP pasted “everybody's favorite game: What has ExpHP reinvented?” at http://lpaste.net/354186
02:30 <divVerent> BTW, also the `div` very likely should be /
02:30 <divVerent> as otherwise you'll get an integer number from it, which doesn't let you usefully round
02:30 <divVerent> so probably you need to rather do something like
02:31 <geekosaur> you missed glguy suggesting div instead of (/)
02:31 <divVerent> ah, I see
02:31 <divVerent> well, div is KINDA better
02:31 <divVerent> but the round logic doesn't work that way
02:31 <divVerent> to do a rounded integer division
02:31 <divVerent> rdiv :: Integral a => a -> a -> a
02:32 <fred-fri> removing all the type shenanigans, this is what i want to do https://pastebin.com/XxG1cSF8
02:32 <divVerent> rdiv a b = (a + ((b + 1) `div` 2)) `div` b
02:32 <divVerent> wait, not b+1, just b
02:32 <divVerent> indeed, rdiv a b = (a + (b `div` 2)) `div` b
02:33 mjz19910 joined
02:33 <divVerent> so for round5
02:33 takle joined
02:33 <divVerent> you'd use
02:33 <divVerent> 5 * ((x + 2) `div` 5)
02:34 <divVerent> or of course the proper set of type conversions (fromIntegral comes to mind for the input side), and using / and round
02:34 splanch joined
02:35 <fred-fri> i guess i can do the fromIntegral at the start and let grade and round5 operate on floating types
02:35 <fred-fri> that should make things easier, maybe?
02:35 <divVerent> maybe yes
02:35 zeroed joined
02:35 zeroed joined
02:35 <divVerent> would prefer rational types though
02:36 <fred-fri> but doesnt that cause issues for rounding
02:36 mjz19910 joined
02:37 <ExpHP> less issues than rounding floats...
02:38 <fred-fri> i see
02:38 <divVerent> so, 5 * round (x % 5)
02:38 <divVerent> x % 5 is basically a Rational
02:38 <divVerent> you can round that and multiply it by 5
02:38 <ExpHP> a rational is an exact result of dividing integers, a float is *sometimes* an exact result of dividing integers
02:38 <Cale> :t x % 5
02:38 <lambdabot> Ratio Expr
02:38 <divVerent> and round is a type conversion to anything Integral
02:38 <Cale> heh
02:39 <Cale> :t (x :: Integer) % 5
02:39 <lambdabot> error:
02:39 <lambdabot> • Couldn't match expected type ‘Integer’ with actual type ‘Expr’
02:39 <lambdabot> • In the first argument of ‘(%)’, namely ‘(x :: Integer)’
02:39 <Cale> :t \x -> (x :: Integer) % 5
02:39 <lambdabot> Integer -> Ratio Integer
02:39 xall joined
02:39 <ExpHP> > unlet x -- :V
02:39 <lambdabot> error: Variable not in scope: unlet :: Expr -> t
02:39 <fred-fri> > 5 * round (x % 5)
02:39 <divVerent> :t \ x -> 5 * round (x % 5)
02:39 <lambdabot> (Integral a, Integral a1) => a1 -> a
02:39 keemyb joined
02:39 <lambdabot> mueval-core: Time limit exceeded
02:39 mjz19910 joined
02:40 eacameron joined
02:40 <fred-fri> > 5 * round (3 % 5)
02:40 jgertm joined
02:40 <divVerent> yes, both sides Integral :)
02:40 <lambdabot> 5
02:40 <divVerent> @pf \ x -> 5 * round (x % 5)
02:40 <lambdabot> Maybe you meant: pl bf
02:40 <divVerent> @pl \ x -> 5 * round (x % 5)
02:40 <lambdabot> (5 *) . round . (% 5)
02:40 <divVerent> yes, much... better
02:40 <divVerent> reads like assembly, this pointfree representation
02:41 <fred-fri> maybe i should give up haskell and move directly to assembly... assembly has the highest abstractions
02:41 <divVerent> div 5; round; mul 5
02:41 <fred-fri> trolol
02:42 <divVerent> strongly typed assembly with lazy evaluation, hindley-milner and monads NOW
02:42 <* ExpHP> makes some remark about "@pl" and "perl"
02:42 <divVerent> and of course lambdas, we need those lambdas in assembly a lot
02:43 <ski> divVerent : i don't know about the latter, but <http://www.cs.cornell.edu/talc/>
02:43 <fred-fri> off topic: i was recently approached by a recruiter about a position as team lead where the stack is perl, r (not rust, r) and objective c. im a java dev.
02:44 <divVerent> not bad, this TAL
02:44 <divVerent> CALL (LAMBDA x, CALL x x) (LAMBDA x, CALL x x)
02:45 <divVerent> sounds like it'll compile to a single VLIW instruction called HCF
02:45 <fred-fri> most non programmers dont seem to understand first thing about differences between languages.
02:45 dfeuer joined
02:45 <divVerent> you'll do fine there though
02:46 <divVerent> you probably are qualified for the R and ObjC parts at least just by being here and knowing Java
02:46 <ExpHP> To be fair, I held for the longest time the idea that "once you learn one programming language, you've learned them all"
02:46 <divVerent> as for perl... just wing it
02:46 <divVerent> so did your predecessor :)
02:46 patbecich joined
02:47 <fred-fri> its true a lot of places the turnover of people is so high that no one really knows what theyre doing anyway
02:48 <fred-fri> are most of the regulars in this channel professional haskell devs or is it like 50/50 pro/hobby
02:48 <* ExpHP> pokes at http://lpaste.net/354186 with puppy dog eyes
02:48 <lolisa> > fix (+ 1)
02:49 <lambdabot> mueval-core: Time limit exceeded
02:49 <lolisa> > fix (1 +)
02:49 <lambdabot> mueval-core: Time limit exceeded
02:49 <lolisa> ertes, how come you get 99999 with fix (1 +)?
02:49 takle joined
02:49 <Cale> lolisa: By redefining fix temporarily
02:49 <divVerent> stupid lambdabot, we all know the fixpoint of (+ 1) is +Infinity
02:49 <divVerent> well, and -Infinity, and NaN
02:50 <divVerent> does NaN count as fixpoint if NaN /= NaN?
02:50 <ExpHP> divVerent: fix doesn't require Eq a :)
02:50 <divVerent> ExpHP: I know
02:50 <divVerent> was talking mathematically
02:51 <ExpHP> well then no, obviously it eats your children
02:51 <divVerent> fix doesn't REALLY look for fixpoints of functions :P
02:51 <divVerent> it more like defines a construct that IF it can evaluate, must also be a fixpoint
02:51 <lolisa> @let True False
02:51 <lambdabot> Parse failed: TemplateHaskell language extension is not enabled. Please add ...
02:52 <lolisa> @let True = False
02:52 <lambdabot> Defined.
02:52 <lolisa> > ! True
02:52 <lambdabot> <hint>:1:7: error:
02:52 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
02:52 <Cale> lolisa: That definition doesn't accomplish anything
02:52 <ExpHP> @let LANGUAGE = espanol
02:53 <lambdabot> .L.hs:162:1: error: Not in scope: data constructor ‘LANGUAGE’
02:53 <lolisa> > True
02:53 <Cale> It's a pattern binding which matches the pattern True (lazily) and binds no variables
02:53 <lambdabot> True
02:53 mizu_no_oto joined
02:53 <divVerent> anyway, whoever finds Haskell crazy hasn't done any QuakeC yet :P in many ways the exact opposite, because it was designed by someone without the slightest idea about languages or compilers
02:53 <divVerent> representative sample:
02:53 <lolisa> aww man
02:54 <divVerent> { float x = 1; x = 2; if (1 == 2) prrint(...); }
02:54 <lolisa> @let or = and
02:54 <lambdabot> Defined.
02:54 <ExpHP> divVerent: meh. beats vimscript
02:54 <divVerent> the print will execute, because x is a constant (because of the assignment), assigning to a constant just overwrites the memory representing the constant, boom
02:54 <lolisa> I feel like I'm doing pure sin
02:54 <divVerent> beats javascript, even
02:55 <ExpHP> javascript has actually kinda been pulling its weight lately
02:55 <lolisa> > or True False
02:55 <lambdabot> error:
02:55 <lambdabot> Ambiguous occurrence ‘or’
02:55 <lambdabot> It could refer to either ‘Data.List.or’,
02:55 <lolisa> @undefined or
02:55 <lambdabot> There's currently no way to undefine just one thing. Say @undefine (with no extra words) to undefine everything.
02:55 <divVerent> and I recently tried to convince Go people to keep a data type transitively comparable
02:55 <divVerent> well, I failed
02:55 <lolisa> @undefine or
02:55 <lambdabot> There's currently no way to undefine just one thing. Say @undefine (with no extra words) to undefine everything.
02:55 <divVerent> they insist on that change to make comparisons no longer transitive on a specific type
02:56 <lolisa> @undefined
02:56 <lambdabot> Undefined.
02:56 mac10688 joined
02:56 <ExpHP> @undefinemyclementines
02:56 <lambdabot> Unknown command, try @list
02:57 <ExpHP> (I've tried that @list thing and it doesn't actually list commands >_>)
02:58 <ExpHP> (okay I'm dumb never mind)
02:58 Argue joined
03:00 <lolisa> @karma ExpHP
03:00 <lambdabot> ExpHP has a karma of 0
03:00 <ExpHP> it has some dice rolling expression language
03:00 <ExpHP> @roll (2d7 + 3d6) * 7d18
03:00 <lambdabot> ExpHP: ((7+1) + (3+4+4)) * 76 => 1444
03:01 connrs joined
03:01 <ExpHP> that's my karma by the way. lambdabot will lie if you ask him
03:01 <ExpHP> or her
03:01 <ski> @poll-result should-lambdabot-be-more-polite
03:01 <lambdabot> Poll results for should-lambdabot-be-more-polite (Closed): yes=0, maybe=6, no=13, yes=8
03:04 zzzq joined
03:05 takle joined
03:05 zzzq joined
03:05 <ExpHP> @slap ExpHP
03:05 <* lambdabot> places her fist firmly on ExpHP's jaw
03:06 <ExpHP> it is a her!
03:08 <MarcelineVQ> @vixen
03:08 <lambdabot> The presidency has many problems, but boredom is the least of them.
03:10 HoierM joined
03:10 <ExpHP> @src fix
03:10 <lambdabot> fix f = let x = f x in x
03:11 <ExpHP> @src seq
03:11 <lambdabot> Source not found. BOB says: You seem to have forgotten your passwd, enter another!
03:11 <Cale> @vixen is @nixon
03:11 <lambdabot> Do you know what happened to the Romans? The last six Roman emperors were fags. . . . You know what happened to the popes? It's all right that popes were laying the nuns.
03:11 justanotheruser joined
03:11 Kundry_Wag joined
03:11 <MarcelineVQ> coincidence
03:12 <ski> @palomer
03:12 <lambdabot> That's a lie
03:12 <Cale> @keal
03:12 <lambdabot> ghc need to have plugin that allow copy paste in xp
03:13 raycoll_ joined
03:13 <ExpHP> oh no...
03:13 <ExpHP> @yarr
03:13 <lambdabot> What be a priate's favourite cheese?
03:13 <lambdabot> Yarrlsburg!
03:13 <MarcelineVQ> it's too bad, vixen is more interesting
03:14 sigmundv joined
03:16 Guest71 joined
03:16 armyriad joined
03:17 <c0dehero> lexi-lambda: nice work! :D
03:29 Vaelatern joined
03:29 madgoat joined
03:29 felixsch_ joined
03:30 Vaelatern joined
03:30 _sras_ joined
03:31 <_sras_> What is a good library that can be used to model Money and currencies?
03:31 zariuq joined
03:31 madgoat left
03:32 <lolisa> @quote Cale
03:32 <lambdabot> Cale says: "Betta watch your back when I'm packin' a nine/I'll pump you fulla holes like the rational line"
03:32 <lolisa> wut
03:32 <lolisa> @quote la
03:32 <lambdabot> applicative says: Even if no one else understands me, still, the Glasgow Haskell Compiler understands me
03:33 <lolisa> @quote lambdabot
03:33 <lambdabot> lambdabot says: In the definition of `yhjulwwiefzojcbxybbruweejw':
03:33 <lolisa> wait, wut
03:33 <lolisa> @quote lolisa
03:33 <lambdabot> No quotes match. Take a stress pill and think things over.
03:34 <Cale> @yhjulwwiefzojcbxybbruweejw
03:34 <lambdabot> "\"#$%&'()*+,\""
03:34 Vaelatern joined
03:34 <Sornaensis> Cale: what does it mean
03:35 <ski> @help yhjulwwiefzojcbxybbruweejw
03:35 <lambdabot> V RETURNS!
03:35 <Cale> There used to be a fixed variable which your expression was bound to while lambdabot was evaluating it, originally v
03:35 <Cale> and so using v in your expression would result in recursion
03:36 <ertes> lolisa: i redefined (+)
03:36 <ertes> secretly
03:37 <ski> @quote parametric.polymorphism
03:37 <lambdabot> acowley says: Parametric polymorphism is the inspiring story you tell them to get them riled up and raring to go. It's like Braveheart for programmers.
03:37 <ski> @quote about.parametric.polymorphism
03:37 <lambdabot> Dave_Benjamin says: please talk to your son or daughter about parametric polymorphism
03:37 sophiag joined
03:38 <lolisa> ertes, thx
03:38 <lolisa> @quote monad
03:38 <lambdabot> Botje says: replacing "monad" with "monkey" makes haskell much more easy to understand
03:38 <Cale> yhjulwwiefzojcbxybbruweejw was what the variable was briefly renamed to after people found out about v
03:38 <lolisa> @quote monad
03:38 <lambdabot> jcreigh says: I've found learning Haskell makes me feel vastly inferior to Haskell coders. ("Oh,", they say, "That's just a fold over the hyper-monad fluxbox list. Here's the one-line replacement
03:38 <lambdabot> for your entire program.")
03:38 <lolisa> @quote monad monoid
03:38 <lambdabot> No quotes for this person. My pet ferret can type better than you!
03:38 <lolisa> @quote monoid
03:38 <lambdabot> PhilipWadler says: I'm delighted to learn that "a monad is a monoid in the category of endofunctors"---anyone know where I can find a good tutorial?
03:38 <Cale> and before it became something a bit harder to manipulate :)
03:38 mac10688 joined
03:38 <lolisa> lol
03:39 <Cale> I wonder when Phil Wadler asked about that
03:39 <Cale> I could have given that tutorial :)
03:40 markasoftware joined
03:41 itachi joined
03:42 <_sras_> So, is there a good package that one can use to handle money?
03:43 <Cale> Might want to look at what hledger uses?
03:43 <Cale> I don't know
03:43 ChaiTRex joined
03:45 <tippenein> it uses Decimal, which.. I'm not sure would be recommended
03:45 <Cale> http://hackage.haskell.org/package/hledger-lib-1.2/docs/Hledger-Data-Types.html#t:Amount
03:45 <Cale> It has some types...
03:46 <tippenein> there is https://github.com/k0001/safe-money
03:46 <tippenein> depends what you mean by "handle money" I imagine
03:46 <ski> @quote AlanPerlis
03:46 <lambdabot> AlanPerlis says: The string is a stark data structure and everywhere it is passed there is much duplication of process. It is a perfect vehicle for hiding information.
03:46 <Cale> Statically encoding which currencies you're working with seems pretty niche to me
03:47 <_sras_> tippenein: Cale I am looking for something like this https://hackage.haskell.org/package/money-0.1.0/docs/Data-Money.html
03:47 <_sras_> But I am not sure about using that package. Is it commonly used?
03:48 <Cale> If I had to guess I would say no
03:48 <Cale> It's had 38 downloads ever
03:49 ericdwhite joined
03:49 <tippenein> the only thing in the readme is a link to a failing circle ci build
03:49 <tippenein> it's the code equivalent of a tumbleweed
03:53 <sophiag> anyone here familiar with prelude-extras? i'm trying to figure out how to use the Show1 class similar to what's suggested here: http://stackoverflow.com/questions/24482561/conditionally-derive-show-for-existential-type-parameterized-on-type-constructor
03:53 eklavya joined
03:54 thunderrd joined
03:57 isidore joined
03:57 sleffy joined
03:58 <glguy> always just ask the actual question
03:58 mada joined
03:58 <sophiag> i'm the child who doesn't know enough to ask a question
03:59 <Cale> The question posed by the original poster on stackoverflow doesn't make sense.
03:59 <sophiag> it makes sense, it's just extremely contrived
04:00 vikraman joined
04:00 <sophiag> the difference is i only have one variable wrapped in the existential
04:01 <Cale> Oh, maybe it does -- it sounded at first like he wanted to get rid of the Show constraint in X
04:01 whaletechno joined
04:01 <glguy> Yeah, you get an instance Show1 a => Show (X a)
04:02 <sophiag> right, and when i try something like that i get "parse error on input 'instance'"
04:02 <glguy> Rather than us guessing what you did wrong you can post the code to lpaste
04:02 <Cale> I guess if he really wanted that, you could have yet another analogue of Show1, where the Show b constraint was removed from show1's type
04:03 <Cale> sophiag: where are you writing it?
04:03 <Cale> It should be at the top level of a module
04:03 <sophiag> Cale: after the data type
04:04 <Cale> Oh, are you using the standalone deriving?
04:04 <sophiag> yes, but it doesn't seem to be making a difference
04:04 <Cale> {-# LANGUAGE StandaloneDeriving #-}
04:04 <sophiag> and i'm correct that in that answer the class is just an example of what's in prelude-extras?
04:05 <sophiag> the type causing me all this trouble (almost certain you
04:05 <sophiag> oops
04:05 <sophiag> ...almost certain you've seen it already: data LambdaT = forall a . LambdaType (a -> Bool)
04:06 <Cale> That looks like a pointless type
04:06 <Cale> You're forgetting the type of the argument to the function, so you'll never be able to apply it
04:06 e14 joined
04:07 <sophiag> the point is to store it in a record with a name that will match it up arguments of the same type in another record
04:07 <sophiag> so i can be certain it will work, but not through the type system
04:07 <Cale> The existential loses the information about which type of argument is required
04:08 ebzzry joined
04:08 <Cale> So when you pattern match the existential and get the function back out, you'll have a function of type a -> Bool where a is unknown.
04:08 <sophiag> you're saying if i put those lambdas in filters with lists of the appropriate type then it won't compile?
04:08 <Cale> and so it will never unify with anything
04:08 <Cale> You won't be permitted to apply the function
04:10 <sophiag> the only reason i don't want to pass in the type of a is so i can lambdas where a represents multiple types in a list of records
04:11 <sophiag> wow, that sentence didn't make much sense...but i think you can get it
04:11 <Cale> The problem with that is that if you don't know which type a is, you don't know what type of argument you need to supply
04:11 <Cale> The solution to this is to invent a type which in some fashion generalises all the types you actually need there
04:12 <Cale> There are two approaches: make a type with constructors corresponding to all the types you want to use explicitly
04:12 <sophiag> i do actually have that
04:12 Kundry_Wag joined
04:12 <Cale> Or else make a record type with all the operations you want to be able to assume are available
04:12 <sophiag> because i needed it to construct the lambdas after parsing
04:12 <Cale> (i.e. OOP)
04:12 <sophiag> oh damn
04:12 <sophiag> wait...why didn't i think of this...
04:13 <sophiag> i think you made my brain spark
04:13 <sophiag> (could be i'm doing this weird residency program where it's super loud and this is the first quiet time i've had all week...midnight on saturday)
04:14 toof joined
04:14 toof left
04:15 <vaibhavsagar> sophiag: I didn't realise it had gotten that loud
04:15 <sophiag> i think i have an idea to make it work that should have been super obvious, but lemme show a paste of what i'm thinking since i'm not sure of the syntax (basically in need an adt that i can use instead of the type variable)
04:16 <sophiag> ah! vaibhav :D
04:16 <sophiag> yes, it's ridiculous here tbh
04:17 <sophiag> i talked to three guys from winter batches and one said he ended up working at home the whole time and another said he had a huge gap in his github heatmap from when he was here...
04:17 <vaibhavsagar> that is literally the opposite of the experience I had
04:18 <sophiag> there's a thread about it and this woman was like, "i think it's wrong to assume everyone works best in the same kind of environment. i personally found it really hard to get work done when i was sitting alone in the quiet." like uh...
04:18 <vaibhavsagar> it is basically a large open office, so I'm not surprised that there are noise issues
04:19 <vaibhavsagar> I recommend passive-aggressive headphone usage
04:19 raycoll joined
04:19 <sophiag> well, i'm fine when it's just pair programming or whatever. but it seems a lot more tan that
04:19 <sophiag> i wear earplugs
04:19 <sophiag> they're not enough
04:19 <vaibhavsagar> D:
04:20 <Cale> "I find I get my best work done with wailing and screaming in the background."
04:20 xall_ joined
04:20 <sophiag> yeah...i've never in my life heard a programmer say "can we make it a whole lot louder in here?"
04:20 <vaibhavsagar> I like these: http://downbeats.com/
04:20 ericdwhite joined
04:20 <vaibhavsagar> but they're a non-solution to a serious problem
04:21 johnw_ joined
04:21 <sophiag> yeah, like this is surely well beyond what any earplugs are rated at
04:22 <sophiag> i brought it up, and nick said he felt the same way but they're so against telling people to just stfu
04:22 <sophiag> and the elephant in the room is like...you can't both be coding all day and loudly talking
04:22 <vaibhavsagar> the curse of self-direction
04:22 meba joined
04:23 <sophiag> the curse of being in a room with 60 people half of whom don't seem to be actually working...
04:23 <vaibhavsagar> I don't think I was very productive but I still enjoyed my time there a lot
04:23 <vaibhavsagar> I did a ton of "not actually working"
04:23 marcopullo joined
04:24 <vaibhavsagar> in summary, it is a good thing I'm not there now
04:24 <sophiag> that's the thing, i would prefer to not have to choose between productivity and getting along with people
04:24 <sophiag> ha
04:24 mizu_no_oto joined
04:25 raatiniemi joined
04:25 dequbed_ joined
04:25 rotcpy joined
04:25 edran joined
04:25 scopedTV joined
04:26 mxf joined
04:26 owickstrom joined
04:26 <sophiag> i also had someone basically tell me exactly the concrete form of the project i was thinking of without me having to research it so need to focus pretty seriously on that. an open source 802.1aq implementation. apparently there are none even though it's six years old and was referred to as "the most important development in the history of ethernet"
04:26 monty joined
04:27 <vaibhavsagar> are you both working on it together?
04:27 test1 joined
04:27 <johnw_> this might be better taken to priv chat
04:28 <vaibhavsagar> oops, sorry johnw_
04:28 <johnw_> :)
04:28 eb_ joined
04:28 <johnw_> anyone know what happened to the "chunking" function from Data.List.Lens.Split? or where that module went altogether?
04:28 tristanp joined
04:28 darthdeus joined
04:29 <sophiag> Cale: this seems like the smart way to do this, i.e. without existentials, but i'm not sure the syntax. http://lpaste.net/354189
04:29 padre_angolano_ joined
04:29 scottj left
04:30 <Cale> Well, function types aren't by default instances of Show
04:30 <sophiag> i suppose i just haven't had trouble with most
04:31 <sophiag> the issue here would seem to be in the third part not using the variable? is that correct?
04:31 <Cale> No, every one of those parts is a problem with respect to Show
04:32 <sophiag> oh, ok
04:32 <Cale> Because they're all functions, and functions don't normally have a Show instance
04:32 dunj3 joined
04:32 <Cale> What did you want to show?
04:32 monochrom joined
04:32 wei2912 joined
04:32 dbecvarik joined
04:32 fairfieldt joined
04:32 xa0 joined
04:32 suzu joined
04:32 kyren joined
04:32 ogre joined
04:33 alpounet joined
04:33 <Cale> I'm still pretty lost about how this code fits into the overall structure of the program... it's unusual for something called "Lambda" to show up at the type level.
04:33 <sophiag> theoretically i could avoid printing until eval, but then it makes it very difficult to test. for example, right now this part with existentials is typechecking, but i don't understand why which is...scary
04:33 <Cale> Usually you'll have a type for expressions, one constructor of which will be the constructor for lambdas
04:33 <Cale> But I don't know
04:34 <sophiag> it's essentially just like quote in lisps
04:34 Theophane joined
04:34 <sophiag> i want to be able to throw these functions in a data structure and use them later
04:34 <Cale> Also, you drop the RhsT on the left hand side of that data declaration now
04:34 <Cale> It's not a variable
04:35 <sophiag> right, that's the part i'm asking about mainly
04:35 zoran119 joined
04:35 <Cale> So LambdaT becomes a predicate on values, basically.
04:35 <sophiag> your suggestion about grouping together the possible types so i don't need LambdaT to be an existential? that's what i'm thinking
04:35 <sophiag> i needed RhsT anyway in order to parse them
04:35 <Cale> If I have any intuition about what's going on, I think I'd usually name "RhsT" something like "Value" -- isn't this the type of values for an interpreter?
04:35 zeroed joined
04:36 <sophiag> yes, that's accurate to say
04:36 nemesit|znc joined
04:36 dibblego joined
04:36 dibblego joined
04:36 Twey joined
04:36 <Cale> Or maybe do away with LambdaT altogether
04:36 XMunkki joined
04:36 rotty_ joined
04:36 <sophiag> "Value" sounds a bit confusing to me personally
04:37 <Cale> and just put constraint :: RhsT -> Bool
04:37 Tazca joined
04:37 davean joined
04:37 <Cale> as a field in Require
04:37 chirpsalot joined
04:37 MarioBranco joined
04:37 mitchty joined
04:37 mmachenry joined
04:37 <sophiag> i could do that
04:37 splanch joined
04:38 <sophiag> but i still can't use a data type in the declaration of another data type, right? that's the error i'm getting
04:38 <Cale> hm?
04:38 <sophiag> "data LambdaT RhsT ="
04:38 <Cale> You can use any data type in the declaration of any other, including mutual recursion
04:38 <sophiag> i thought so, but...
04:39 <Cale> It doesn't make sense that RhsT is occurring as an argument to LambdaT there
04:39 <geekosaur> um, that declaration is meaningless
04:39 <sophiag> ghc is saying it wants a type variable...does that even make sense?
04:39 <geekosaur> yes?
04:39 <Cale> yes, it wants a type variable there, just because that's how the syntax of data declarations goes
04:39 <geekosaur> what are you trying to accomplish with that?
04:40 <sophiag> oh you're saying just use a variable in LambdaT and pass RhsT to the constructor, yeah?
04:40 <Cale> It's data <TypeConstructorName> <typeVar1> ... <typeVarN> = ...
04:40 <geekosaur> because you are saying you want a type LambdaT which is always parameterized with RhsT? if that's what you want just use RhsT, don't specify it as a type parameter
04:40 BartAdv joined
04:40 crobbins joined
04:40 <sophiag> i think i get it now
04:40 <Cale> sophiag: No, just delete that RhsT
04:40 <Cale> It doesn't belong on the left side of the = sign
04:40 <sophiag> Cale: you're probably right
04:41 <Cale> Now, if you wanted to be really fancy, and define a type by cases on other types
04:41 <Cale> You might use a data family
04:41 <Cale> But I don't think that's what you're looking for
04:42 <sophiag> do you just mean a type class?
04:42 <Cale> No, fancier :)
04:42 <sophiag> ha
04:42 <Cale> Basically a function on types, defined by cases
04:42 <Cale> each of which is like its own data declaration
04:42 <sophiag> well, i do still have all this structure with parsing the ASTs
04:42 chu joined
04:42 <sophiag> so that's why those two types, OpT and RhsT, were useful
04:43 <Cale> What is this type Require?
04:43 <Cale> What are you hoping to express?
04:44 <sophiag> those are essentially "constraints" as in they'll be used to filter lists based on the string filed
04:44 <sophiag> *field
04:44 <sophiag> and if it's Nothing then they'll filter the whole list
04:45 <sophiag> so the dsl can fail specatularly, but that's ok for how i'm exposing it
04:45 fryguybob joined
04:45 <Cale> and if it's Just "foo"?
04:45 <sophiag> then it should match a list that's tagged "Just foo" and has the same type as a in a -> Bool
04:46 <Cale> What is the type of elements in the list?
04:46 mnoonan joined
04:46 <Cale> (Note: you have to say just one thing here :)
04:47 <sophiag> each list only has one type...but the list of records will contain lists of different types...
04:47 <Cale> It it RhsT?
04:47 patbecich joined
04:47 <Cale> right, okay
04:47 <sophiag> yes it is RhsT except i have a different constructor with the list form
04:47 <Cale> Okay, so what does the record look like?
04:47 <sophiag> the other one?
04:47 Xanather joined
04:47 <sophiag> data MultiList = SList [String] | CList [Char] | IList [Integer] deriving (Show)
04:48 <sophiag> data Amb = Amb { ambTag :: Maybe String, value :: MultiList } deriving (Show)
04:48 xplat joined
04:48 SimpleL joined
04:49 <sophiag> the thing is...it is nice to have those adts in between for parsing purposes
04:49 <Cale> Okay, so do we also need three different types of Require?
04:49 <Cale> Or do we want one type of Require, which can be applied to any of the types of list?
04:50 <sophiag> no, just one type
04:50 takle joined
04:51 <sophiag> i think it makes more sense to have those intermediate adts and then just use one record for each rather than three records for each
04:51 <Cale> btw, if you want imprecise Show instances for your types, you could write them by hand, like:
04:51 <sophiag> for several reasons
04:51 itachi joined
04:51 <Cale> instance Show OpT a where show (NumOp f) = "NumOp <function>"; show (EqOp f) = "EqOp <function>"; show (BoolOp f) = "BoolOp <function>"
04:52 <Cale> oops
04:52 <Cale> instance Show (OpT a) where
04:52 <sophiag> oh, ok. thanks, i was wondering the format for that
04:52 <Cale> Or just write
04:53 <Cale> instance Show (a -> b) where show _ = "<function>"
04:53 <Cale> and then derive the instance
04:54 <sophiag> using the show function?
04:55 <Cale> Once there's an instance of Show for functions, you should be able to use deriving
04:57 <sophiag> sorry, i'm still a bit confused. especially if i use "instance Show (a -> b)"
04:58 <Cale> Well, in order to derive an instance of Show, it needs to already have an instance of Show for each of the fields of your type's data constructors.
04:59 <sophiag> i see
04:59 <Cale> If we write an instance of Show which applies to any function type at all, it'll deal with the reason why you couldn't stick deriving (Show) on those
04:59 <Cale> The other option being just to write the instance of Show by hand, and specify how show works at that type.
05:00 <sophiag> ok, so i either do "instance Show (constructor ...)" for each constructor or a general one
05:00 govg joined
05:00 <Cale> for each *type* constructor
05:00 <sophiag> meaning like NumOp, not OpT yes?
05:00 <Cale> No, the opposite
05:01 <sophiag> ah ok
05:01 <sophiag> in that case it seems like clearly the better choice
05:01 mmachenry1 joined
05:01 <Cale> OpT is a type constructor, NumOp is a data constructor
05:01 meandi_2 joined
05:01 connrs joined
05:01 <Cale> type classes apply to types
05:01 <sophiag> oy, i've been calling OpT the "data type" and NumOp the "constructor" :(
05:02 monochrom joined
05:02 <Cale> That's fine
05:03 <sophiag> well, i'd ideally like to sound less foolish
05:03 <Cale> OpT is indeed a type (it just happens to also be a type constructor, which is a finer distinction that doesn't matter as much as that of being a data constructor most of the time)
05:03 vektorweg1 joined
05:04 <Cale> It's fine to use those words, they don't sound foolish, I'm just trying to be precise, because it's easy to be confused about what's at the type level and what's at the term/value level as a beginner.
05:04 <sophiag> ok, so i do need to keep those adts unless i want to totally refactor my parsers, but i think i can do away with a separate type for lambdas as you suggested by just combining two functions
05:05 <Cale> The distinction of being a type constructor is sort of a fine point -- type constructors are the things that instances of type classes match on when the system is deciding which instance applies for a given type.
05:07 <Cale> and when you write a data declaration, you introduce both a new type constructor, and a bunch of data constructors
05:07 <sophiag> i'm going to read simon pj and erik meijer's paper on type classes this week so hopefully i'll understand all this better
05:07 Guest71 joined
05:08 <sophiag> oh, i need to use standalone deriving. that's what you meant?
05:09 <Cale> er, do you?
05:09 <Cale> I didn't expect it
05:09 osa1 joined
05:09 <sophiag> that's what ghc says
05:09 <Cale> hmm
05:10 <sophiag> and apparently i need to write an instance for Require even though it's not an existential now?
05:10 splanch joined
05:11 <Cale> ahh...
05:11 <Cale> It's confused by the constraints on NumOp
05:11 <Cale> er... one sec
05:12 <Cale> yeah -- it doesn't actually need to worry, but it's worried :)
05:12 <Cale> If it just wrote the Show instance it usually writes, ignoring those constraints, it would be fine
05:13 <Cale> I guess standalone deriving will work
05:13 Kundry_Wag joined
05:13 <Cale> {-# LANGUAGE StandaloneDeriving #-}
05:13 <Cale> deriving instance Show (OpT a)
05:13 <Cale> works
05:13 <sophiag> yup, got that at least :p
05:14 HarveyPwca joined
05:14 <sophiag> but what i got myself confused about was i *do* either need to keep LambdaT and make it an existential, make Require an existential, or (seemingly worst option) put the Requires in an HList
05:15 <Cale> Why doesn't it work just to, say, make Require take a function of type RhsT -> Bool?
05:16 <sophiag> oh ok, i think i unconfused myself...
05:17 <sophiag> the idea was to just always pass RhsT to the type constructor so it's fine to cons them in a list
05:19 <lpaste> Cale annotated “No title” with “No title (annotation)” at http://lpaste.net/354189#a354190
05:19 <sophiag> oooo
05:19 <sophiag> :D
05:21 hsk3 joined
05:24 <sophiag> do i need the GADTs pragma to have the constraints in OpT without ghc considering it an existential?
05:24 <Cale> But yeah, if instead, you have a list of RhsT values, you obviously don't need that :)
05:25 <sophiag> hmm?
05:25 <Cale> Oh, I stuck that in hastily. You need either GADTs or ExistentialTypes to get that feature, but it's really neither of those things, it just doesn't have a name :P
05:25 <sophiag> right
05:25 <sophiag> i was just trying to figure out why you threw that in there
05:25 <Cale> Well, it's sufficient to make the module compile :)
05:25 <sophiag> oh yeah, you do need one or the other apparently
05:26 <sophiag> i guess because of the constraints
05:26 <Cale> Yeah, putting the constraints there means that GHC does something cute, where it sticks the type class dictionary into the data as an extra secret field
05:27 <sophiag> oh...that's interesting
05:27 <Cale> So, when you pattern match on NumOp, you learn that a has instances of Num and Fractional
05:28 <Cale> and the operations are available to use, even if the definition that you're writing didn't originally constrain the type a
05:29 takle joined
05:29 <Cale> which is a little bit like GADTs in that you're learning something about other types while pattern matching on data constructors (though usually with GADTs proper, you might learn exactly which type it was)
05:30 <Cale> well, specifically, you learn about the type arguments to the type whose data constructor it was :)
05:30 <sophiag> tbh i'm unclear on the difference between GADTs proper and these guys, which is why i keep saying "ADTs"
05:31 <Cale> The classic example of a GADT is something like this:
05:31 <Cale> data Expr a where
05:31 <Cale> Lit :: Integer -> Expr Integer
05:31 <Cale> IsZero :: Expr Integer -> Expr Bool
05:31 <Cale> IfThenElse :: Expr Bool -> Expr a -> Expr a -> Expr a
05:32 <sophiag> oh ok
05:32 <Cale> Notice that the type of the result can be more specific here than just "Expr a"
05:32 <Cale> Now we can write:
05:32 <Cale> eval :: Expr a -> a
05:32 <Cale> eval (Lit n) = n
05:32 <Cale> eval (IsZero e) = eval e == 0
05:32 <sophiag> i think it makes sense to actually rewrite OpT like that
05:33 <Cale> eval (IfThenElse b t e) = if eval b then eval t else eval e
05:33 <sophiag> because something i've put off thinking about is nesting the right hand sides in these lambdas :p
05:33 <sophiag> that's the only reason to include arithmetic expressions obviously
05:33 <Cale> So, notice how in the case of Lit, when we match on the Lit data constructor, GHC learns that in this branch of the pattern match, a = Integer
05:34 MrWoohoo joined
05:34 <Cale> and so we're allowed to provide n :: Integer as our result there
05:34 <Cale> and similarly in the IsZero branch of the pattern match, since IsZero has to produce an Expr Bool, GHC learns that a = Bool
05:34 <Cale> and so we're expected to produce a Bool result, which we do
05:35 nomicflux joined
05:36 <sophiag> oh yeah, i just tried to refactor it and realized i can't just be like (a -> a -> a)
05:37 <sophiag> for NumOp GADTs are perfect actually because i do want to define them that way
05:37 <sophiag> not sure about the other two cases where i know they're going to return Bool
05:38 <Cale> It does seem a little bit suspicious that this is all one type
05:39 <sophiag> i want to separate NumOp i think so i can define it recursively
05:40 <sophiag> but then i need to group it together with the others so i can still have all the Requires be of the same type :p
05:40 <ertes> @let boolsheet f = liftA2 f [False,True] [False,True]
05:40 <lambdabot> Defined.
05:40 Swizec joined
05:40 <Cale> haha
05:41 <Cale> > boolsheet (&&)
05:41 <lambdabot> [False,False,False,True]
05:46 <hsk3> main = forever $ do
05:46 <hsk3> l <- getLine
05:46 <hsk3> putStrLn $ map toUpper l
05:46 <ertes> maybe it would be better to keep the sublists
05:46 <hsk3> If I run that program with ./test < text.txt
05:47 <ertes> @let deepBoolsheet f = map (\b -> map (f b) [False,True]) [False,True]
05:47 <lambdabot> Defined.
05:47 <hsk3> Why does it exit with "test: <stdin>: hGetLine: end of file" ?
05:47 geekosaur joined
05:47 <hsk3> Is that an exception?
05:47 <Cale> yeah
05:48 <hsk3> But if I run that program with just ./test and type out the lines manually, I can't get an EOF with Ctrl-D
05:48 <hsk3> I'm on macOS
05:48 <ertes> hsk3: the way the APIs return EOF is inconsistent… some throw an exception, others return an empty result, so be sure to read documentation
05:48 patbecich joined
05:49 <ertes> getLine kinda has to throw an exception though, because an empty result would be ambiguous
05:51 enitiz joined
05:53 <sophiag> Cale: i'm having some weirdness wrapping that GADT i made in Maybe. does that make sense?
05:54 ChaiTRex joined
05:55 <Cale> uhh, can't think of what it would be
05:56 <sophiag> i just solved part of it and it was when the type constructor is followed by a type rather than a variable it doesn't want the constructor in the signature. so doesn't seem to have to do with Maybe
05:57 <sophiag> in other words, you want (OpT a -> OpT a -> OpT a) but (OpT a -> OpT a -> Bool) rather than (OpT a -> OpT a -> OpT Bool)
05:58 splanch joined
05:58 <sophiag> except then the function i wrote to unwrap Maybes without throwing an exception on Nothing needs to be changed i think
05:59 <sophiag> oy. i needed to think about nesting those expressions anyway tho
05:59 meandi_3 joined
06:01 <Cale> hmm...
06:03 HarveyPwca joined
06:03 <Cale> I was thinking earlier that you probably ought to get into using the Either String monad (or Either Something anyway), in order to propagate failure cases so that you can deal with them later, or let the user deal with them.
06:04 <sophiag> well that's sort of (not really) what i'm doing in the repl
06:04 <sophiag> because there's essentially two Rights
06:04 _sg joined
06:05 <Cale> yeah, if you're still at the part where you're fitting things together by hand, you'll know that the outcome will be Right, and won't have to worry about the other case :)
06:06 <sophiag> well i am worrying. it's just i have two Right cases so i made a type: "data Exprs = ExpString String | ExpAmb Amb | ExpReq (Require RhsT)"
06:07 biglama joined
06:07 <sophiag> although maybe that is convoluted since my motivation was needing a case for when Maybe would return Nothing
06:07 <sophiag> so i have "Just "unexpected input"" as one of the choices :p
06:09 <sophiag> ugh, well i think i need to revist this Maybe business tomorrow
06:10 <sophiag> there are just too many cases. i'm very happy to have ditched existentials tho :)
06:10 ekr joined
06:14 Kundry_Wag joined
06:14 Sh4rPEYE joined
06:16 suppi joined
06:19 locallycompact joined
06:19 Gurkenglas joined
06:20 <sophiag> Cale: thanks so much for the lessons. it singlehandedly turned an annoying day into a productive one :)
06:20 <Cale> No problem :)
06:21 <sophiag> now i have to head home and try to get to sleep so i can debug this thing tomorrow and hopefully even finish the basics of it :p
06:21 <Cale> I should probably sleep as well
06:21 <sophiag> it's been a very good learning experience though when it comes to structuring data in haskell's type system
06:22 jsgrant-_ left
06:22 <sophiag> welp, nighty night
06:22 <Cale> g'night!
06:22 ozgura joined
06:23 teggi joined
06:24 jsgrant-_ joined
06:31 magneticduck joined
06:32 cpup joined
06:33 Croniamental joined
06:35 MoALTz joined
06:37 insitu joined
06:37 Bose_ joined
06:41 codesoup joined
06:42 alexelcu joined
06:44 Sh4rPEYE joined
06:44 insitu joined
06:45 takuan joined
06:45 <MP2E> `/quit
06:47 splanch joined
06:49 teggi joined
06:50 ubsan_ joined
06:50 aglorei joined
06:52 splanch joined
06:53 splanch_ joined
06:54 iomonad joined
06:55 knx32542 joined
06:55 knx32542 left
06:57 castlelore joined
06:58 Kreest__ joined
07:01 connrs joined
07:01 markus1189 joined
07:02 markus1199 joined
07:05 teggi joined
07:07 kritzcreek_ joined
07:13 socxon joined
07:14 Kundry_Wag joined
07:15 castlelore joined
07:16 fotonzade joined
07:18 simukis_ joined
07:19 greister joined
07:22 Nikotiini joined
07:22 pavonia joined
07:23 np356 joined
07:25 07EAANMQ9 joined
07:28 falafel joined
07:31 plutoniix joined
07:33 splanch joined
07:33 osa1_ joined
07:35 detrumi joined
07:36 mmachenry joined
07:37 connrs joined
07:39 augur joined
07:41 Wizek joined
07:41 Wizek_ joined
07:42 ebzzry joined
07:42 takle joined
07:49 Levex joined
07:49 patbecich joined
07:50 eacameron joined
07:53 Sh4rPEYE joined
07:54 splanch joined
07:55 vektorweg1 joined
07:56 MarioBranco joined
08:02 descender joined
08:02 beanbagula joined
08:07 raichoo joined
08:08 posco joined
08:10 geekosaur joined
08:22 zero_byte joined
08:23 zeroed joined
08:24 meba joined
08:24 np356 joined
08:24 zq joined
08:25 <zq> :t manyTill
08:25 <lambdabot> error: Variable not in scope: manyTill
08:25 <zq> damn
08:25 Rainb joined
08:25 <zq> does lambdabot not have parsec loaded?
08:25 <c_wraith> apparently not
08:25 <c_wraith> @let import Text.Parsec
08:25 <zq> :m + Text.Parsec
08:25 <lambdabot> Defined.
08:25 <zq> c_wraith: thanks!
08:26 <c_wraith> :t manyTill
08:26 <lambdabot> Stream s m t => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
08:26 augur joined
08:27 chaosmasttter joined
08:28 Levex joined
08:29 cjh` joined
08:29 <zq> > parse ((,) <$> (manyTill anyChar . Text.Parsec.try $ Text.Parsec.char 'g') <*> Text.Parsec.many anyChar) "" "asdfgh"
08:29 <lambdabot> Right ("asdf","h")
08:29 anuxivm joined
08:29 <zq> is this a bug? i don't see why 'g' is consumed, since the manyTill end is wrapped in `try`
08:30 <zq> i expected: Right ("asdf", "gh")
08:30 fotonzade joined
08:32 <cocreature> zq: "try" does not result in a parser never consuming input. it results in a parser that doesn’t consume input _if it fails_
08:33 <opqdonut> you might want to try lookAhead instead of try
08:33 <opqdonut> my parsec is a bit rusty though
08:33 <zq> cocreature: ohcrap, i forgot
08:35 Salih joined
08:36 <cocreature> > parse ((,) <$> (manyTill anyChar . Text.Parsec.lookAhead $ Text.Parsec.char 'g') <*> Text.Parsec.many anyChar) "" "asdfgh"
08:36 <lambdabot> Right ("asdf","gh")
08:36 <cocreature> ^ zsq
08:36 <cocreature> ^ zq
08:36 marr joined
08:36 <cocreature> oh opqdonut already said that
08:36 <zq> opqdonut: cocreature thanks
08:36 ozgura joined
08:37 <zq> i'm a bit confused about lookAhead's commentary, though. "lookAhead p parses p without consuming any input.
08:37 <zq> If p fails and consumes some input, so does lookAhead. Combine with try if this is undesirable"
08:37 <cocreature> zq: note that "try" has no effect when you apply it to "char" since "char" already doesn’t consume input on failure
08:37 <zq> so, how could p consume some input if p is parsed without consuming any input?
08:37 anuxivm left
08:37 yellowj joined
08:37 <cocreature> zq: it is parsed without consuming input if p succeeds
08:39 <zq> oh i see
08:39 <zq> if p succeeds, then it rolls back. otherwise, if p fails, lookAhead fails with it
08:40 <cocreature> exactly
08:40 oish joined
08:40 <cocreature> the megaparsec docs are a bit clearer on this https://hackage.haskell.org/package/megaparsec-5.2.0/docs/Text-Megaparsec.html#v:lookAhead
08:43 enitiz joined
08:43 twold joined
08:46 bbcue joined
08:49 teggi joined
08:50 anuxivm joined
08:51 connrs joined
08:51 plutoniix joined
08:53 ragepandemic joined
08:54 Mysterious_Light joined
08:57 ebzzry joined
08:57 eklavya joined
08:58 oisdk joined
08:59 fred-fri joined
08:59 xyther joined
08:59 ragepandemic joined
08:59 Yuras joined
09:00 <fred-fri> does this challenge not have an error in it? should the answer not be 4 because 12 should be included in the set? https://www.hackerrank.com/challenges/between-two-sets
09:02 alexelcu joined
09:02 <cocreature> fred-fri: 12 is not a factor of 16 :)
09:02 caumeslasal joined
09:03 <cocreature> and it’s also not a factor of 32
09:03 oisdk_ joined
09:04 obadz joined
09:04 Aruro joined
09:06 thc202 joined
09:08 ner0x652 joined
09:11 xyther joined
09:12 Mysterious_Light joined
09:13 plutoniix joined
09:14 xyther joined
09:15 t0by joined
09:15 t0by joined
09:15 dawehner joined
09:17 Kundry_Wag joined
09:18 robotroll joined
09:19 takle joined
09:20 augur joined
09:21 insitu joined
09:21 <Aruro> why Char is not an instance of Num?
09:22 <fred-fri> cocreature, this is what I have so far https://pastebin.com/NcxMQ5fk
09:22 <fred-fri> pretty sure my first condition in the filter is OK but not the second
09:23 <Taneb> Aruro, why should it be? Characters aren't numbers
09:23 ragepandemic joined
09:23 <Taneb> What should 'x'*'[' be
09:23 aib joined
09:23 <Aruro> > instance Num Char where fromInteger = chr . fromInteger
09:23 <lambdabot> <hint>:1:1: error: parse error on input ‘instance’
09:24 nakal_ joined
09:24 <Aruro> ah, lambdabod can not make instances
09:24 Levex joined
09:25 dawehner_ joined
09:26 Kreest_ joined
09:26 freechips joined
09:26 <cocreature> fred-fri: I think it’s the other way around. your second condition tests correctly whether n divides all bs. however your first condition tests whether n divides all as instead of testing whether all as divide n
09:30 <Aruro> Taneb: [1..256] :: String will work with above definition
09:30 <fred-fri> cocreature if i only do filter (\n -> (sum (map (mod n) bs) == 0)) numbersBetween it still outputs empty
09:31 mmn80 joined
09:31 <fred-fri> ie that condition (which is the second one in my paste) seems wrong
09:31 <cocreature> Aruro: you can make an instance of Num for Char. the reason why there isn’t one is that arithmetic operations on Chars don’t make a lot of sense so requiring the explicit conversion via chr/ord ensures that you don’t accidentally use it
09:32 govg joined
09:32 e_svedang joined
09:34 catsup joined
09:34 <Xandaros> Are there any totality checkers for glasgow haskell? I don't care about safely using partial functions, just something that makes sure everything is total
09:34 <cocreature> fred-fri: ah you need "map (`mod` n)" i.e. partial application on the second argument
09:34 catsup joined
09:34 <freechips> a = 8/2 `mod` 5
09:35 <freechips> throws a weird error about ambiguous types
09:35 <freechips> same for a = 2.2^2 `mod` 5
09:36 <cocreature> / requires Fractional but mod requires Integral
09:36 <Taneb> Aruro, ['\1'..'\256'] works just as well
09:36 hmoorerg joined
09:37 <freechips> ah ok i was coming from python
09:37 <freechips> so ill just cast
09:37 _ashbreeze_ joined
09:37 <Xandaros> Why does it need integral? Does "5.2 `mod` 5.1 = 0.1" not make sense?
09:38 <fred-fri> cocreature, ah so i wasnt going crazy
09:38 <fred-fri> yes that works
09:38 <fred-fri> uh, what does it do
09:38 <freechips> a = (truncate (4/5)) `mod` 5 -- works
09:38 <freechips> also am i forced to use main = do
09:38 <freechips> and let before every variable?
09:39 oisdk joined
09:39 <Xandaros> mod' from Data.Fixed works for reals, it seems
09:39 Jackneill joined
09:40 danvet joined
09:41 insitu joined
09:41 dan_f joined
09:42 hmoorerg left
09:43 mounty joined
09:43 <freechips> getting so many errors..
09:43 <fred-fri> ooooh so mod and `mod` is the same function, just syntax becomes different
09:43 <fred-fri> mod a b == a `mod` b
09:43 hmoorerg joined
09:44 <fred-fri> hard to know for a noob who is just shotgunning when stuck
09:45 <Xandaros> Yeah - you can do that with any function that has at least two arguments, though it is most useful if it has exactly two
09:45 Jackneill_ joined
09:45 <freechips> yeah the compiler errors kinda suck. just using a parenthesis wrong game ve 300 errors. feels like returning to C
09:45 <Xandaros> Some functions are meant to be used this way and it reads really nicely when used infix
09:45 connrs joined
09:45 <freechips> i was using a = truncate (a/b) `mod` c --- just fine
09:46 <Aruro> freechips: u did not return to c, u did not learn enough :)
09:46 <freechips> actually a = (truncate (a/b)) `mod` c
09:46 initiumdoeslinux joined
09:46 <freechips> but a = (truncate (a^b)) `mod` c -- not fine
09:46 <freechips> but a = truncate (a^b) `mod` c -- fine
09:46 <freechips> no idea about that
09:47 <freechips> Aruro: ?
09:47 <Xandaros> > (truncate (2^5)) `mod` 5
09:47 <lambdabot> 2
09:48 <Xandaros> Seems to work fine
09:48 <freechips> basically every time i add a line i get 200 compiler errors. now a*(b-c) `mod` d -- not works
09:48 <freechips> Xandaros: don't know what to tell you..
09:48 inad922 joined
09:49 <freechips> https://ptpb.pw/qUno
09:49 <Xandaros> Can you lpaste your code ... nvm
09:50 <freechips> for comparison, this is the original py https://ptpb.pw/9vMo
09:50 <freechips> i thought i would need just a couple of changes, but turning that small snippet into haskell is annoying
09:51 patbecich joined
09:52 <Aruro> why do u need haskell?
09:52 <Aruro> for this code calculator is even better
09:52 <freechips> just wanted to try to see if haskell was faster
09:52 <Aruro> its not
09:52 <Aruro> haskell is slow on numerics
09:52 <freechips> also i want to get to use haskell sometimes
09:53 <Aruro> slowest of all
09:53 <freechips> ah
09:53 <freechips> cool...
09:53 ij joined
09:53 <freechips> but you see im gonna do these calculations in a programming language because ill need to interwine the 2 things.
09:53 <freechips> i need programming more than numbers
09:54 <freechips> so im not gonna drop down to a calculator or bc or whatever..
09:54 dawehner joined
09:55 <Xandaros> Ohh, I see... yeah, that's a subtle one
09:55 <Xandaros> Hmm, nope
09:56 <Taneb> freechips, do div' and mod' in Data.Fixed help? http://hackage.haskell.org/package/base-
09:57 <Aruro> freechips: define all your constants before main function, then no need of let
09:57 hurkan joined
09:57 <Aruro> just main = print c
09:57 <Xandaros> freechips: let qinv = (truncate (1/fromIntegral q)) `mod` p
09:57 iomonad joined
09:57 <Xandaros> Also, what Aruro said
09:57 FjordPrefect joined
09:58 fotonzade joined
09:58 <Xandaros> The (/) required q to be fractional, so it couldn't be integral anywhere else. It Is rather subtle
09:58 <freechips> Taneb: wut? im a noob
09:58 jgertm_ joined
09:58 <freechips> Data.Fixed?
09:59 <freechips> Aruro: thanks!
09:59 <freechips> that's nice
09:59 <Aruro> freechips: haskell has rather complicated system for crunching numbers, and beginners should HATE haskell for that, i do
09:59 <Xandaros> I mentioned Data.Fixed earlier...
09:59 <freechips> what about the other non-constants? like m1 etc
09:59 <Aruro> also possible
09:59 <Aruro> they are just math functions (no input output actions involved)
10:00 <Aruro> everything above main and main = print c
10:00 <Aruro> no lets
10:00 fizruk joined
10:00 dawehner joined
10:00 <Xandaros> In your current code, they are also constant. They are just calculated constants
10:01 azahi joined
10:01 <freechips> Integer is not fractional?
10:01 stef204 joined
10:02 <freechips> what if i just made a mod that extends to real numbers?
10:02 <freechips> much better than turning 1/q % p into what Xandaros wrote...it becomes hard to understand
10:02 osa1_ joined
10:03 <Xandaros> Data.Fixed.mod' is the first thing I mentioned -_-
10:03 <Xandaros> You didn't seem to want to use it
10:03 <freechips> ah ok i get it thanks Xandaros
10:03 <freechips> i did not understand it was an alternative implementation of mod
10:03 <Aruro> freechips: there http://lpaste.net/354198
10:03 <freechips> these subtleties really ruin the experience of haskell :(
10:04 zq left
10:04 <Aruro> freechips: yes, because u take number crunchin as easy task, its not
10:04 mohsen_ joined
10:04 <Aruro> remember horrors of float rounding errors
10:04 <Aruro> just be patient, and u will make it
10:05 <Aruro> annoying but possible
10:06 eacameron joined
10:09 doomlord joined
10:10 <freechips> import Data.Fixed
10:10 <freechips> mod = Data.Fixed.mod'
10:10 <freechips> complains...i want to overwrite mod
10:10 <Aruro> say mod1
10:10 <freechips> also it seems to be working fine in ghci :D
10:10 <freechips> so i can't overwrite mod?
10:11 osa1 joined
10:11 <freechips> Aruro: that lpaste gives me a lot of errors..
10:11 <freechips> ghc version 8.0.1
10:13 silver joined
10:13 <freechips> i mean i can deal with truncate. but truncate + fromInteger is not bearable. id much rather say mod=Data.Fixed.mod' and use `mod` as if it were normal
10:15 <zaquest> freechips, you can't override, you can either specify which version you want with x `Prelude.mod` y or x `Data.Fixed.mod` y, or hide prelude's mod with import Prelude hiding (mod)
10:15 <Xandaros> You can just do import Data.Fixed (mod') and then use `mod'`
10:16 <zaquest> not Data.Fixed.mod, YourModuleName.mod i mean
10:16 <freechips> alright
10:17 <freechips> mod' it is
10:17 <freechips> not too bad i guess
10:18 Kundry_Wag joined
10:19 <freechips> https://ptpb.pw/nITi had to add a couple of parens but otherwise pretty similar to the original py
10:19 <freechips> would you say that is good haskell style programming?
10:22 <Xandaros> One very important thing: Provide type signatures for your top-level definitions for documentation.
10:23 cyborg-one joined
10:23 <Xandaros> You don't necessarily need that for your constants but something like "main :: IO ()" is imo missing.
10:23 <Xandaros> You may also want to indent the "print m"
10:24 <Xandaros> (The "do" is also superfluous, but let's not confuse you with the semantics of do just yet :P)
10:24 <zaquest> freechips, there's also no indentation in main, and you don't need do block for a single statement so just main = print m
10:25 <freechips> alright thanks. id problably use signatures for a real program but this is just a quick number-script for now
10:28 zoran119 joined
10:28 zeroed joined
10:29 coot joined
10:29 t7 joined
10:30 <lpaste> ads pasted “sdf” at http://lpaste.net/354201
10:31 ragepandemic joined
10:32 zoran119 joined
10:32 prophile joined
10:32 doomlord joined
10:33 AndreasK joined
10:34 jgt joined
10:37 <jgt> hey folks
10:38 netheranthem joined
10:38 <jgt> I want to send my client a file from a Yesod app. I know I can do something like `sendFile "text/plain" "foo.txt"`, but this expects a file to exist at that path. Can I send a file response without actually writing this (temporary) file to disk?
10:38 <Aruro> onse without
10:38 <jgt> or is it a better idea to just write to a temporary file before sending it?
10:39 <michi7x7> jgt: can't you just set the content-type and content-disposition headers manually?
10:40 <jgt> michi7x7: Oh… I suppose I could. I hadn't thought of that
10:41 louispan joined
10:41 hoknamahn joined
10:42 Eduard_Munteanu joined
10:44 contiver joined
10:45 byte512 joined
10:45 RegEchse joined
10:49 boombanana joined
10:50 <jgt> michi7x7: that totally worked, and was very easy
10:50 <jgt> to an almost spooky degree
10:51 <jgt> so… Thanks!
10:52 <michi7x7> jgt: you're welcome
10:52 fizbin joined
10:52 litchblade joined
10:53 detrumi joined
10:55 sepp2k joined
10:56 gillesmajor joined
10:56 gillesmajor left
10:57 hackebeilchen joined
10:57 <freechips> it also looks like N is a reserved variable.....hmmm
10:57 <freechips> ah i cannot have variables that start uppercase
10:58 patbecich joined
11:00 takle joined
11:02 splanch joined
11:08 MindlessDrone joined
11:08 takle joined
11:11 govg joined
11:12 justicefries left
11:13 robotroll joined
11:13 Zialus joined
11:14 mheinzel joined
11:14 louispan joined
11:16 vaibhavsagar joined
11:16 deepfire joined
11:16 splanch joined
11:16 razi1 joined
11:19 vydd joined
11:19 vydd joined
11:19 Kundry_Wag joined
11:20 splanch_ joined
11:23 JuanMiguel joined
11:25 ziocroc joined
11:27 fizbin joined
11:28 fuzzy-id joined
11:29 <fuzzy-id> may i ask what package you guys are using when it comes to date and time processing?
11:30 <fuzzy-id> i made a decision for hourglass and just found several drawbacks
11:30 <cocreature> fuzzy-id: I use the time package "time"
11:30 <fuzzy-id> e.g. no instance for Hashable, no arithmetics on for time periods and time stamps
11:30 <cocreature> eh remoe one of those times
11:31 <cocreature> fuzzy-id: fwiw the Monoid instance on periods in "hourglass" let’s you add them
11:31 Fendor joined
11:32 sdothum joined
11:32 <cocreature> and there is a "timeAdd" function to add intervals to dates
11:32 <cocreature> adding to time stamps doesn’t make sense
11:32 <fuzzy-id> ah, ok, i haven't seen the Monoid instance
11:33 mojjo joined
11:33 <cocreature> I guess subtracting two periods might be slightly annoying
11:33 byte512 joined
11:33 tomboy64 joined
11:35 <fuzzy-id> i'll probably have a look at time anyways
11:35 <fuzzy-id> why did you choose it over hourglass, btw?
11:37 <cocreature> fuzzy-id: because it’s what most other people seemed to do :) iirc it’s even bundled with ghc
11:39 meoblast001 joined
11:39 Sh4rPEYE joined
11:40 coot joined
11:42 <Sh4rPEYE> Hey. I'd like to learn something about algorithms, preferably in Haskell (or at least some other functional language). My background is just high-school math, and I didn't even finish calculus yet. No CS whatsoever (i.e. I don't know anything about graphs or similar common CS data structures and algorithms and I feel I'm missing put a lot).
11:42 <Sh4rPEYE> Do you know any good book or resource I could use?
11:44 dysfun joined
11:45 <Sh4rPEYE> I was looking at: Grokking algorithms (Python, though), Intro to algorithms (Scheme), SICP (less algorithm-y, but still pretty informative; Scheme).
11:45 <dysfun> hello. how can i write a lens over a data structure which depends on some data within that data structure?
11:46 <dysfun> (i have a map within the data structure and i need to lookup the 'current' key to navigate within it)
11:46 eacameron joined
11:49 <michi7x7> Sh4rPEYE: you should probably just start with learn you a haskell. This should teach you the basics about implementing algorithms in Haskell
11:49 Aruro joined
11:51 <Sh4rPEYE> michi7x7: I'm learning Haskell with "Haskell programming from first principles" and I find it really good! If I start with another introductory book now there might be a lot of needless repetition... Isn't there something dedicated to functional algorithms?
11:52 Itkovian joined
11:52 <Sh4rPEYE> The boo fits my needs in all other aspects
11:52 <cocreature> there is “pearls of functional algorithm design” but it’s not really targeted at beginners iirc
11:53 <Fendor> Learn yourself a Haskell for great good is imo one of the best books for beginners
11:53 <Fendor> introduces some algorithms too
11:53 <dysfun> a very different type of book though
11:53 <Fendor> yes
11:54 <Sh4rPEYE> When I searched
11:55 <Sh4rPEYE> * sorry: when I looked for the best book to learn Haskell, LYAH was said to be too shallow. Thus I chose Haskellbook instead...
11:56 <Sh4rPEYE> Of course I can read it as well. I just though there'd be a lot of ground I'd already covered with HaskellBook. What about the books I takhled about? SICP/Intro/Grokking?
11:57 <Axman6> dysfun: yu might find it easiest to do it by hand: current (Foo cur mp) f = at cur f mp (I think)
11:57 <dysfun> :/
11:57 <Axman6> :t at 1
11:57 <lambdabot> (Functor f, Num (Index m), At m) => (Maybe (IxValue m) -> f (Maybe (IxValue m))) -> m -> f m
11:58 <Axman6> :t at 1 @_ @_ @(Map k v)
11:58 <lambdabot> error: parse error on input ‘@’
11:59 <Axman6> dysfun: it's not like it's ugly or anything :\
12:00 <michi7x7> Sh4rPEYE: well, LYAH is very well structured. You can skip things you already know and probably find some hints here and there. Don't know about books deticated to algorithms though
12:01 eacameron joined
12:02 <Axman6> ther's Okasaki's functional data structures book
12:02 <Axman6> but understanding the finer points in it requires a good grasp of laziness and its implications
12:03 <Axman6> Sh4rPEYE: what exactly do you mean by "functional algorithms" anyway?
12:05 <Sh4rPEYE> Axman6: I should've rather said "functional implementations" I guess. I could as well use a general algo book and implement them myself, but as I'm just a beginner, it'd be nice to check against something.
12:06 <Axman6> well look at Okasaki's book
12:06 <cocreature> Sh4rPEYE: I think one problem is that a significant portion of standard algorithms & data structures don’t fit easily in a functional paradigm
12:07 <cocreature> so you can either write an imperative algorithm in a functional language (which is a perfectly reasonable thing to do) or you try to look for other algorithms
12:08 <Axman6> paticulatly when such a large number of imperative programmer's algorithmic knowledge boils down to "why not just use a hashmap, they're constant time everything"
12:08 <cocreature> tbf hash maps are pretty great :)
12:08 louispan joined
12:08 bennofs joined
12:09 <bennofs> Is it possible to have cabal fallback to hardcoded paths if pkg config is not available?
12:09 <Axman6> not if you need immutability
12:09 <bennofs> I thought using Manual: false flags would do that, but it seems it doesn#t
12:10 dawehner joined
12:11 <Sh4rPEYE> cocreature: Yes, I was unable to find something myself... That's why I eventually came here to ask.
12:11 <cocreature> Sh4rPEYE: it kind of depends on what your goal is. do you want to learn standard algorithms using a functional language or do you want to learn functional algorithms?
12:12 <Sh4rPEYE> cocreature: As I'm a beginner, I could benefit from both. I'd rather go the functional algorithms route, because I'm sure I'll have to learn imperative at the University.
12:13 <Sh4rPEYE> cocreature: Not mentioning functional algorihms will be more fun :-D
12:13 <Axman6> do you have any particular algorithms you want to now about?
12:13 <cocreature> Sh4rPEYE: I think I would recommend going with standard algorithms either in a functional language or even an imperative one first since most literature will probably assume you know those
12:13 dawehner_ joined
12:14 MindlessDrone joined
12:14 <Sh4rPEYE> Axman6: Not really. I keep hearing graphs are great for various programming tasks, so maybe some algos associated with that.
12:15 <Sh4rPEYE> cocreature: And what would you recommend for that?
12:15 <Axman6> I've never actually found a use for a graph structure
12:16 ragepandemic joined
12:16 <cocreature> Sh4rPEYE: the standard book on that topic is “introduction to algorithms” but personally I’ve mostly learned them from the lecture notes associated with the courses I attended
12:18 <Sh4rPEYE> Axman6: Well then I've been mystified. What algos should I learn in your opinion then?
12:18 <Sh4rPEYE> I know the questions I keep asking are too general; it's just that I don't know almost anything about the matter, so I have to ask in this stupid way.
12:19 <cocreature> unless you have some specific application in mind, learn a few of each category so you know what’s out there when you’re trying to solve a problem
12:19 <Sh4rPEYE> cocreature: Ok, so I'll take a look at the Intro to algorithms
12:19 <cocreature> you can spend years studying sorting algorithms but that won’t help you if your programs doesn’t have anything to do with sorting
12:19 zargoertzel joined
12:19 <cocreature> and the same holds for any other category of algorithms
12:20 <Sh4rPEYE> Sure. Some general knowledge is something I had on my mind initially
12:21 vkmc1 joined
12:24 Kundry_Wag joined
12:25 meoblast001 joined
12:25 meba joined
12:25 zariuq joined
12:27 wei2912 joined
12:34 theelous3 joined
12:34 stef204 joined
12:38 fakenerd joined
12:40 henriksod joined
12:41 bbee joined
12:42 Argue_ joined
12:43 Itkovian joined
12:44 oisdk joined
12:45 Rodya_ joined
12:45 <kgadek> hi. I'm wondering on real-world usage of various exceptions. Async seem unmanageable, I think I recall someone mention disadvantages to checked exceptions. Need food for thought, any good pointers?
12:46 <Aruro> Sh4rPEYE: u can study this https://en.wikipedia.org/wiki/List_of_algorithms
12:47 <Aruro> Sh4rPEYE: then this https://en.wikipedia.org/wiki/Computational_complexity_theory
12:47 Kundry_Wag joined
12:48 _sras_ joined
12:48 Kundry_Wag joined
12:49 <_sras_> I am seeing some spooky behavior in ghci. One of my programs produce a different output when run immediatly after a compile.
12:49 Kundry_Wag joined
12:49 <_sras_> Output changes when it is run a second time.
12:49 <mniip> petition to expand the r/haskell icon 2 pixels down and use a readable 3x5 font
12:50 mbw joined
12:51 <_sras_> Both of the times, the program is stuck in an infinte loop, so I have Ctrl c it. But when run immediately after a compile, it prints some output from 'traceShow' calls. This disappear when running the same function a second time.
12:53 <kgadek> _sras_: looks like race condition
12:53 fakenerd joined
12:53 <kgadek> I can imagine that after compile, the app is in cache so is quicker to get to some state
12:54 <kgadek> or the other way around: first exec causes cache-miss, subsequent will be ran from cache
12:54 <kgadek> do you have a good repro?
12:55 meoblast001 joined
12:55 eacameron joined
12:57 <mbw> Hello everybody. Is there some tutorial-like literature about deriving parallel versions of sequential functions? I have found quite a few papers which deal with monoid/list homomorphisms, which once identified seem to imply the possibility of a divide&conquer approach. However, all these papers seem to deal with automatic parallelization by a compiler, not "by hand", for instance via equational reasoning.
12:57 <mbw> To me it seems there is a huge gap between "foldMap == mapReduce :D" and stuff aimed at compiler implementers...
13:00 <_sras_> kgadek: repro?
13:00 patbecich joined
13:00 <kgadek> code that reproduces the issue
13:00 <kgadek> that you can share
13:03 Itkovian joined
13:03 hypermonad joined
13:04 dcoutts_ joined
13:04 <drdo> Hmm, is there any way to call a function with an explicit class instance?
13:05 <Aruro> :t read :: String->Int
13:05 <lambdabot> String -> Int
13:06 phyrex1an joined
13:07 <drdo> Aruro: The problem is really that you can only have one instance for Int, in that example
13:07 anton__ joined
13:08 xall_ joined
13:10 minn joined
13:11 eacameron joined
13:11 Itkovian joined
13:12 <Aruro> drdo: elaborate
13:12 Itkovian joined
13:12 tsmish joined
13:13 <drdo> Aruro: Imagine you want to print something of type [A]
13:14 <drdo> But you want to print the As in some way different from the Show instance of A
13:15 <drdo> the show function for List takes an implicit argument of the Show instance to print the elements with
13:15 <drdo> I'd like to explicitly pass that Show instance
13:15 Kundry_Wag joined
13:16 miklcct_ joined
13:17 Itkovian joined
13:18 m0rphism2 joined
13:18 HoierM joined
13:24 MindlessDrone joined
13:25 a3Dman joined
13:27 jgertm joined
13:28 ziocroc joined
13:29 eacameron joined
13:32 Mysterious_Light joined
13:32 Deide joined
13:32 SCHAAP137 joined
13:32 deepfire joined
13:34 Itkovian joined
13:34 xall_ joined
13:35 bollu joined
13:36 <bollu> if there's a function of the form f :: (a -> b) -> c. At runtime, can I "peek" at what function the first parameter is to "f"?
13:36 <bollu> I don't care if this involves deep GHC magic
13:36 Fairy joined
13:37 <bollu> I want to inspect the body of (a -> b)
13:37 madgen joined
13:37 <bollu> actually, is this possible with TH at compile time at least?
13:38 erisco joined
13:38 <madgen> Hello, do type class laws needs only apply at semantic level or syntactic as well?
13:39 ziocroc joined
13:39 <madgen> e.g. having an explicit Append constructor and instantiating to Monoid might lead to values with different associativity syntactically, but are really the same
13:39 a3Dman joined
13:40 govg joined
13:40 <erisco> madgen, the laws are stated with an unspecified equality (as far as I can tell) but it is assumed to be whatever == is
13:41 <cocreature> bollu: in general you can’t, even at compile time. the definition of the function might not be available (e.g. if it is from a separate module).
13:41 <bollu> cocreature: ah, unfortunate
13:41 <madgen> erisco: hmm, not the answer I was hoping for, but oh well. Thank you very much!
13:41 <bollu> cocreature: I'm trying to JIT out a free monad at compile / runtime
13:42 <bollu> cocreature: so to encode the branches of the language of the form Lang next = Get Key (Value -> next) | …
13:42 <bollu> I need to be able to find out which function is passed to Get
13:42 <erisco> madgen, what answer were you hoping for?
13:42 <bollu> cocreature: any ideas on how to solve this?
13:42 robotroll joined
13:43 descender joined
13:43 <madgen> erisco: "it won't blow up in your face if you use it like that" or something to that effect
13:43 <cocreature> bollu: what exactly do you hope to end up with?
13:44 FreeBirdLjj joined
13:44 <erisco> madgen, can you explain your circumstance more?
13:44 <bollu> cocreature: a way to feed in a free monad and get out corresponding LLVM
13:44 <bollu> cocreature: either at compile time or at runtime
13:44 <_sras_> kgadek: When I change a division operation into an addition, it runs to completion....
13:45 <erisco> "having an explicit Append constructor" does this just mean Append is a constructor? "instantiating to Monoid" does this just mean there is an instance of Monoid for the type of Append?
13:45 <_sras_> kgadek: the concerned datatype is Scientific
13:45 <erisco> "lead to values with different associativity syntactically but are really the same" well, that is the associativity law
13:45 <madgen> erisco: So I have a bounded lattice over an elaborate mathematical structure, in which equality is non-trivial, instance of a bounded lattice requires absorption but it is not always clear if the operand is top or bottom without further evaluation
13:46 bbear joined
13:46 <madgen> erisco: so I was thinking of representing Meet and Join explicitly as data structures
13:47 anton__ joined
13:47 <kgadek> drdo: if you want your own Show instance, just write a newtype. Then you just use `show . PrintWithMyCustomFunction`
13:47 <madgen> erisco: with the whole Append thing I was giving a simpler example, but yeah basically do I need the law to be satisfies with `==` is my actualy question as your paraphrased very nicely
13:47 <cocreature> bollu: that’s definitely not possible at runtime. at compile time you could try to lookup the definition and throw an error if it’s not available
13:47 <cocreature> bollu: but really if you want to JIT I wouldn’t allow arbitrary Haskell functions
13:48 tobiasBora joined
13:48 <kgadek> _sras_: if you're dealing with race condition, the change of div into (+) could have random impact. Inc. "now the program seems to work"
13:48 <kgadek> *incl
13:49 <_sras_> kgadek: From the documentation page of Data.Scientific. "WARNING: recip and / will diverge (i.e. loop and consume all space) when their outputs are repeating decimals."
13:49 <_sras_> is this what is happening?
13:50 <kgadek> hmm, doesn't look like so
13:50 <erisco> madgen, == does not have to be structural equality. maybe that helps you
13:51 <kgadek> _sras_: do you have any parallelism in your code?
13:51 <_sras_> kgadek: No
13:51 jmcarthur joined
13:51 <drdo> kgadek: right, there's the newtype trick
13:51 <drdo> thanks
13:52 <madgen> erisco: Indeed. Anyway, thank youuu.
13:52 Itkovian joined
13:53 <bollu> cocreature: hm, but I'm not sure how to restrict this to "subset of Hask"
13:54 <bollu> cocreature: interesting, let me try this at compile time
13:54 flocks joined
13:54 <cocreature> bollu: well just make an ADT that represents the language you can actually JIT
13:54 <bollu> cocreature: but at that point, I lose the ability to use do-notation to represent variable binding? that is what makes the free monad so cute
13:55 <bollu> cocreature: do's <- automatically becomes the Lang's (Value -> next)
13:55 <cocreature> bollu: not necessarily. depending on your ADT you can provide an instance of Monad
13:55 <bollu> cocreature: really?
13:55 <bollu> cocreature: example?
13:55 <bollu> cocreature: I've never seen this before
13:55 <kgadek> _sras_: hm. Honestly, don't know what to tell you now. Don't have much time now to investigate, sorry. This could be "this thingy from Scientific has a bug", "this thingy from Scientific is implicitly parallel", to even "ghc bug"
13:56 <freechips> can i find something like python's 3 parameter pow in haskell?
13:56 Itkovian joined
13:56 <freechips> like when you have a**b % c then you can use pow(a,b,c) and it will be much faster
13:56 <freechips> because of another algorithm
13:56 <cocreature> bollu: https://github.com/angerman/data-bitcode-edsl/blob/master/src/EDSL/Example/HelloBranch.hs#L22
13:57 <bollu> cocreature: neat, much appreciated
13:57 lolaol joined
13:57 <kgadek> freechips: you think about modulo exp. I don't recall this being in stdlib
13:57 <bollu> cocreature: has anyone tried this before?
13:57 <angerman> cocreature: you keep on plugging my edsl :p Thanks :D
13:57 <bollu> cocreature: JITting free / something similar?
13:57 <bollu> angerman: hey :)
13:57 <cocreature> angerman: it’s pretty neat!
13:58 <kgadek> freechips: https://rosettacode.org/wiki/Modular_exponentiation
13:58 <angerman> cocreature: hope I'll be able to get back to that... however currently the linker is more important.
13:59 <cocreature> angerman: judging from your ramblings in #ghc your pain tolerance seems to be quite high given than you’re still working on the linker :P
13:59 osa1 joined
13:59 osa1 joined
13:59 <angerman> cocreature: well. "Der Weg ist das Ziel"? :p
13:59 <cocreature> heh
13:59 <kgadek> freechips: this ^ could be your starting point. I would certainly try to generalize this code. And if you hit performance issues with this code, specialize (unbox) version
14:00 <angerman> cocreature: as long as I'm making *some* progress, I'm happy. And elf/armv7 is working proper now.
14:00 <cocreature> angerman: btw, why are you working on the linker? I missed the beginning of all this :)
14:00 <angerman> cocreature: just found out we don't have *any* elf/aarch64 code. And there I was thinking, that excoding macho/aarch64 was missing because no one used it. Didn't know how wrong i was.
14:01 <angerman> cocreature: TH all the things.
14:01 <freechips> kgadek: thanks! this site is cool, it'll tell you the best possible manner to to this, such that if i didn't know a function was in the stdlib i would find out
14:01 <cocreature> angerman: ah is that the “TH in crosscompilation” stuff?
14:01 <angerman> cocreature: yep
14:01 <cocreature> nice
14:01 <freechips> anyway haskell doesnt have it in the stdlibs....kinda sad
14:01 <bollu> cocreature: so you;re telling me that I can build an EDSL with do-notation and still have compile-time /runtime inspectability?
14:02 twanvl joined
14:02 <bbear> is the Foldable type class a Monad ?
14:02 <bollu> bbear: no, not all Foldable are Monad.
14:03 <bbear> :t (find foo where foo _=true)
14:03 <lambdabot> error: parse error on input ‘where’
14:03 <bbear> and List is a Monad ?
14:03 <bollu> bbear: yes, it is
14:04 <bbear> I am trying to get a working example of chaining operations with (>>=) using Lists and Maybe
14:04 <cocreature> bollu: well, if you want to use do-notation only for variable binding you should be able to just use some State Int monad that generates new names and then use those
14:05 <cocreature> wrap this up behind a nice API and you should be good to go
14:06 <bollu> cocreature: cool
14:07 Levex joined
14:07 <bollu> cocreature: I'm assuming this can be inspected at compile time as well?
14:07 <cocreature> bollu: well you run into the same problems of definitions potentially not being available
14:07 <kgadek> drdo: not actually a trick, this was (AFAIK) newtype
14:07 <kgadek> 's design goal
14:08 <bollu> cocreature: I see. worth a shot though
14:08 <cocreature> bollu: at least you can definitely inspect them at runtime
14:08 <bollu> cocreature: think I'll get any speedup by doing this?
14:09 <cocreature> bollu: what is “this” and what are you comparing the performance to?
14:09 <_sras_> kgadek: evaluating 1/3 from ghci indeed hangs.
14:09 <bollu> cocreature: let's say I implement a DSL to express stencil computations.
14:09 <cocreature> JITing can obviously improve performance
14:09 <bollu> yeah
14:09 <bbear> :t let lowerCase = ['a'..'z'] in [[x,y,z]| x<-lowerCase , y<-lowerCase, z<-lowerCase]
14:09 <lambdabot> [[Char]]
14:09 <bollu> has someone tried this? If not, I find this to be an interesting experiment :)
14:09 <bollu> cocreature: It would be nice if I can package this up as a library or something
14:10 <cocreature> lot’s of people have tried JITing languages
14:10 <_sras_> So the question is "How can I divide two scientific values and safely limit the computation to some number of decimal places"
14:10 <bollu> cocreature: yes, I know that :) But, I meant, an embedded easy to use haskell DSL
14:11 <cocreature> bollu: I guess you can see accelerate as one such example
14:11 <cocreature> anthony cowley also has one but it’s not public
14:11 vektorweg1 joined
14:11 <cocreature> stephen diehl probably has worked on several of those iirc
14:11 <bollu> cocreature: Interesting
14:12 <bollu> cocreature: cool, thanks for the pointers
14:12 eacameron joined
14:14 caumeslasal joined
14:15 Noldorin joined
14:15 abhiroop joined
14:15 <_sras_> How can I safely divide two scientific values, without getting into an endless loop?
14:16 harfangk joined
14:16 <abhiroop> Are there any examples of actually parsing binary data using binary or cereal or attoparsec available? I could not find anything
14:16 insitu joined
14:17 baldrick joined
14:20 <bbear> OMG I understood Monads
14:20 <bbear> I just chained two operations together.
14:21 mkoenig joined
14:21 <bollu> bbear: :)
14:21 dawehner joined
14:23 <cocreature> bbear: it’s obligatory that once you have understood monads, you write a monad tutorial
14:24 <bbear> let myDict = let lowerCase = ['a'..'z'] in [[x,y,z]| x<-lowerCase , y<-lowerCase, z<-lowerCase] in (>>=) (find (\x-> (head x)=='u') myDict) (find (\x-> x=='a'))
14:25 <bbear> yes I thought about that « teaching Haskell the right way »
14:26 <bbear> I am not sure I fully understand it yet and, well, I think probably the most effective way to learn Haskell is to try to solve real problems.
14:26 codesoup joined
14:26 <bbear> :t let myDict = let lowerCase = ['a'..'z'] in [[x,y,z]| x<-lowerCase , y<-lowerCase, z<-lowerCase] in (>>=) (find (\x-> (head x)=='u') myDict) (find (\x-> x=='a'))
14:26 <lambdabot> Maybe Char
14:27 <_sras_> Can someone help be explain the behaviour of Scientific library when it just hangs on evaluating (1/3), when I am only asking to print a couple of decimal places.
14:28 <bbear> I must master (return) now
14:28 freeside joined
14:29 marcopullo joined
14:30 <bbear> this video is not bad https://www.youtube.com/watch?v=gEoruozy3mk
14:30 bennofs joined
14:30 e_svedang joined
14:31 FreeBird_ joined
14:32 Rodya_ joined
14:32 fotonzade joined
14:32 <bbear> what is the return useful for ?
14:32 <bbear> Just to end the Monadic chain ?
14:33 e14 joined
14:34 zariuq joined
14:34 <bollu> bbear: it's used to lift a non-monadic value into the monad's context
14:35 Sose joined
14:35 <bbear> ha yes
14:36 albertus1 joined
14:36 dominik joined
14:36 ariakenom joined
14:40 <_sras_> bbear: it just "wraps" the given value in the expected data type. so return 4 :: [Int] will give you [4], and return 4 :: Maybe Int will give you 'Just 4'...
14:40 <bbear> ah ok
14:40 fizbin joined
14:41 <_sras_> bbear: if you are wondering where the "expected" part, come from, it is from type inference mechanism.
14:41 <ggVGc> imo, return is a very bad name
14:41 mojjo` joined
14:41 <ggVGc> pure is much more descriptive
14:42 <bbear> :t read "11" ::Int
14:42 <lambdabot> Int
14:42 <jmcarthur> I think neither return nor pure are great names.
14:43 <jmcarthur> But agreed that pure is better than return.
14:43 <_sras_> bbear: Yes. something similar. Here, Haskell know that you want an Int. So it calls the "read" function in the "Read" instance of the Int.
14:43 <bbear> Read is a typeclass ?
14:44 eacameron joined
14:44 <_sras_> Yes
14:44 <bbear> Like Monad is typeclass
14:44 <_sras_> Exactly
14:44 <bbear> typeclass is really at the top of everything in Haskell ?
14:44 eklavya joined
14:44 ziocroc joined
14:45 <_sras_> bbear: I am not sure about that.. :)
14:45 nadirs joined
14:46 <_sras_> bbear: I mean, I am a beginner myself.
14:46 <cocreature> bbear: what exactly do you mean by “at the top of everything”? what concepts are we talking about here and when is one of those above another one?
14:47 burtons joined
14:47 Fairy joined
14:49 <bbear> typeclass defines a lot of things I mean.
14:49 ljhms joined
14:51 <cocreature> typeclasses are an important concept, yep
14:52 <orion> And yet, there are those who say that you should avoid typeclasses because you likely won't need them.
14:52 Itkovian joined
14:53 <cocreature> they might say that you should avoid _creating new typeclasses_. but I’ve never heard anybody say that you shouldn’t use typeclasses at all.
14:53 <orion> cocreature: That's what I meant.
14:53 <_sras_> Can someone tell me how am I supposed to work with monetary values stored in Scientific. It turns out that I cannot use it in currency conversions because it gets into an endless loop when the result in a repeating fraction..
14:54 <cocreature> and the most vocal proponent of this (gabriel) has slightly retracted his statement since iirc
14:54 <orion> _sras_: Can you give a concrete example?
14:54 <_sras_> orion: https://github.com/basvandijk/scientific/issues/38
14:54 argent0 joined
14:54 Salih joined
14:55 <_sras_> orion: It just hangs, even when I use a function to print it, that is supposed to print only a specified number of decimal places.
14:56 <bbear> you can't write a concat function in monadic way ?
14:57 baldrick joined
14:58 insitu joined
14:59 eacamero_ joined
14:59 <bbear> https://youtu.be/mlTO510zO78?t=1435
15:00 <Cale> bbear: join
15:00 <Cale> > join [[1,2,3],[4,5],[6,7,8]]
15:00 <lambdabot> [1,2,3,4,5,6,7,8]
15:00 <Cale> :t join
15:00 <lambdabot> Monad m => m (m a) -> m a
15:00 burtons joined
15:01 Welkin joined
15:01 patbecich joined
15:01 <cocreature> bbear: if you want an exercise, try implementing the "join" function Cale showed using ">>=" :)
15:01 mmhat joined
15:02 <bbear> yes I was looking for that sort of challenge.
15:02 <bbear> Is that sort of thing implemented separately for each Monadic type ?
15:02 <cocreature> nope
15:03 <_sras_> cocreature: nope?
15:03 <Cale> Only (>>=) and return are implemented separately
15:03 <bbear> so there is only one join for all Monads ?
15:03 <Cale> Everything else derived from them is written only once
15:03 <bbear> okay
15:04 <cocreature> _sras_: join is not implemented separately for each type. it’s implemented in terms of ">>=". that however is implemented separately for each type
15:04 Aruro joined
15:04 <Cale> That's actually kind of the entire point of Monad right there
15:04 <cocreature> or of typeclasses in general :)
15:04 <Cale> yes
15:04 <bbear> and what is the implementation of (>>=) for lists ?
15:04 <Cale> Or even more generally, it's the point of abstraction ;)
15:04 <Cale> Well, let's look at its type
15:05 <Cale> and see if we can guess
15:05 <noam> I'm trying to derive Eq instance for a parameterized type, but can't get it to work, help? code: http://rextester.com/WOAI98630
15:05 <Cale> [a] -> (a -> [b]) -> [b]
15:05 <Fendor> > [1,2,3] >>= (2*)
15:05 <lambdabot> error:
15:05 <lambdabot> • Ambiguous type variable ‘b0’ arising from a use of ‘show_M588818997035...
15:05 <lambdabot> prevents the constraint ‘(Show b0)’ from being solved.
15:05 eacameron joined
15:05 dcoutts_ joined
15:05 <Cale> So you give it a list of values of type a, and a function which given a value of type a, will produce a list of values of type b, and it somehow gets you a list of values of type b
15:05 <_sras_> Cale: No. I thought bbear was asking if every Monadic type has to implement its own Monad instance.
15:05 <Cale> ah
15:05 <Cale> Well, *that* is the case
15:06 <Aruro> > [1,2,3] >>= return . (2*)
15:06 <lambdabot> [2,4,6]
15:06 <glguy> noam, it looks like you're done
15:07 <Fendor> Aruro, thanks, tried to find my error for the last 2 minutes
15:07 <Cale> bbear: So, the obvious thing to start would be to apply the function to all the elements of the given list:
15:07 <noam> glguy: i get ```Variable ‘a’ occurs more often than in the instance head
15:07 <noam> in the constraint: Eq (f a)```
15:07 <Cale> xs >>= f = ... map f xs ...
15:07 <bbear> (>>=) [1,2,3] return
15:07 electrostat joined
15:07 <Cale> but map f xs has type [[b]]
15:07 <Cale> while we want [b]
15:07 mojjo` left
15:07 <Cale> So, the obvious thing to do then is to concatenate :)
15:08 <cocreature> noam: does enabling "FlexibleInstances" work?
15:08 <glguy> noam, ah I guess that got cut off in the paste
15:08 <Cale> xs >>= f = concat (map f xs)
15:08 <Cale> > (>>=) [1,2,3] return
15:08 <lambdabot> [1,2,3]
15:08 <glguy> Noam, you can either add a Show1 constraint to do it or separate constraints for f String
15:08 <Cale> One of the monad laws is that x >>= return is always x
15:09 <glguy> and f Int
15:09 <_sras_> bbear: Also, it might me well to mention that every instance of the Monad you write have to obey the Monad laws. https://wiki.haskell.org/Monad_laws
15:10 Nolar joined
15:10 <glguy> Noam, it doesn't help to have a constraint on f a, that a isn't related to String or Int
15:10 <cocreature> if your Monad instance doesn’t obey the laws you’ll get arrested
15:10 <Aruro> _sras_: does not have, better have
15:10 <cocreature> by the monad police
15:10 jan_path joined
15:11 <bbear> but thats useless since I already had x
15:11 <noam> glguy: I want it to be general so i can later put any Eq-type in `PersonF`. No idea what is this `Show1` thing is :p
15:11 <bbear> nevermind
15:11 MitchellSalad joined
15:11 ziocroc joined
15:11 <glguy> Noam, ok, then you'll need to read about Show1
15:12 e14 joined
15:12 hsk3 joined
15:12 <glguy> http://hackage.haskell.org/package/base-
15:12 Khisanth joined
15:13 <glguy> that's the version in base, which is a little harder to use than the one in prelude-extras
15:13 dzdcnfzd joined
15:14 <dzdcnfzd> I was trying to stack build a package that depends on stack using an EC2 Micro Instance and I kept getting compiler errors with exit code -11. geekosaurus, here, suggested it could be a memory issue. Does anyone have experience developing on EC2 with Haskell, or generally have any pointers about how much memory I'll likely need?
15:14 ckubrak joined
15:15 <noam> glguy: I'll check this out. Do I need Show1 or Eg1? (well actually I want both Show and Eq instances anyway)
15:16 safe joined
15:19 alx741 joined
15:20 <cocreature> dzdcnfzd: less than 2gb is probably going to be problematic
15:21 <glguy> dzdcnfzd: it completely matters what you are compiling
15:21 wtetzner joined
15:22 <dzdcnfzd> glguy: in this case I just added "servant" to the deps
15:22 <dzdcnfzd> and it started running into problems
15:22 lambdafan joined
15:22 <lpaste> lambdafan pasted “open a file skipping the first line” at http://lpaste.net/354209
15:22 <Aruro> why liftA functions are not in prelude? since applicative is
15:23 <lambdafan> Check out BasicPrelude, or any of the others.
15:24 <lpaste> lambdafan revised “open a file skipping the first line”: “open a file skipping the first line” at http://lpaste.net/354209
15:24 <Aruro> seems authors are not annoyed to write x <$> y <*> z all the time
15:24 <Cale> Aruro: I'm not sure, but there's a lot of politics involved in getting anything into the Prelude.
15:24 <lambdafan> Isn't that why other preludes have appeared?
15:25 <Cale> It was already pretty challenging to get Applicative in there on its own :)
15:25 <noam> glguy: If I understand the docs correctly, I need to define the instance of `Eq1` myself, and this will be a lot of boilerplate for a larger type or multiple type. I'd rather avoid boilerplate.
15:25 <dzdcnfzd> cocreature: if I get a 2gb instance, do you think that'd work
15:26 <Cale> Aruro: and yeah, usually people actually do use <$> and <*> over liftAn, perhaps because it's a little easier to manipulate
15:26 <cocreature> dzdcnfzd: maybe? as glguy said it really depends on the things you compile
15:26 <erisco> Aruro, if that reason alone was acceptable then everything involving Applicable would be in Prelude. you see the problem?
15:26 <_sras_> orion: Any luck?
15:26 <dzdcnfzd> cocreature: what's the important metric? Number of transitive deps?
15:26 <glguy> noam, yeah, the design you're using will require some extra work
15:26 <Welkin> Aruro: <$> <*> is more general
15:27 meba joined
15:27 <erisco> and, really, why should Prelude be bigger? import what you need
15:27 <Cale> Applicable ;)
15:27 <cocreature> dzdcnfzd: the number of deps does not matter unless you want to compile them in parallel. it depends on the code inside those deps :)
15:27 <erisco> Cale, I see I missed an opportunity :P
15:27 <Welkin> it' common for haskell files to have 20 or 30 lines of imports at the top
15:27 <Welkin> that is normal
15:27 <erisco> take (.) for example
15:28 <Welkin> import away
15:28 <glguy> there might be ghc.generics code or template haskell code to automate instance generation. I don't remember
15:28 <erisco> if you would rather (.) from Category then you have to hide the Prelude definition of it
15:28 <Cale> Welkin: Yeah, it's actually kind of annoying :)
15:28 <Aruro> typing <$> is not best thing in life
15:28 SpinTensor joined
15:28 <Welkin> lol
15:28 <erisco> and so the more you put into Prelude the more it conflicts with other modules
15:28 <dzdcnfzd> cocreature: I see. Is there any way, as a dev, I can make these guesses? "I'm compiling an app which uses libs X, Y, and Z. How much memory am I likely to need?"
15:28 <noam> glguy: I looked at generics and it might be what I want yes. looks super complicated though
15:28 <dzdcnfzd> or is this just totally guesswork
15:28 <Cale> I really wish there was at least a way to combine together all the imports of the same module
15:29 <Welkin> Cale: alternative preludes?
15:29 <noam> glguy: In any case thanks for the `Eq1` pointer. I wouldn't have found it myself
15:29 <cocreature> dzdcnfzd: just try it out :)
15:29 <Welkin> Aruro: you could import an alternative prelude if you want
15:29 <Welkin> there are many
15:29 <Cale> I'd love to be able to write things like import Data.Text (Text), qualified as T
15:29 <cocreature> Cale: it’s a shame that anthony’s proposal for that got stuck
15:30 <Welkin> Cale: what do you mean?
15:30 <Cale> Welkin: That would unfold to
15:30 <Cale> import Data.Text (Text)
15:30 <Cale> import qualified Data.Text as T
15:30 <dzdcnfzd> cocreature: in particular, with this build, the error code is -11, which is segfault -- how would you go about verifying that it's an oom issue? (see https://github.com/commercialhaskell/stack/issues/2575#issuecomment-248172456 for an example of why I think it is)
15:30 <Welkin> oh
15:31 <Aruro> there should be applicative tick like 'm' means m <$> x <*> y
15:31 <Welkin> I'm okay with typing imports multiple times
15:31 <Aruro> i hate imports, super ugly
15:31 <erisco> Aruro, use Idris where they have idiom brackets
15:31 <Welkin> Aruro: you can extend the language however you want
15:31 <Cale> It's not the worst thing in the world, but it's kind of annoying. Especially the maintenance of those imports with respect to warnings that you're importing things redundantly
15:31 <Welkin> everything is just libraries
15:32 <Welkin> but beware that you may make your code impossible for others to read/use
15:32 <Cale> Like, I might not actually need the unqualified import of Text because maybe none of my type signatures in the module involve Text yet.
15:33 <Cale> I could just ignore the warning, but those warnings are in general pretty useful for trimming the imports :)
15:33 <Welkin> Aruro: also, you just described liftA2
15:33 Rodya_ joined
15:33 <Aruro> yes, i was complaining why its not in prelude
15:33 <Welkin> forget about the prelude
15:33 raichoo joined
15:33 <Welkin> it's just there for convenience
15:34 <erisco> import Prelude ()
15:34 <Welkin> it is not meant as a "Standard library" like in other languages
15:34 <Cale> You basically can't write anything nontrivial in Haskell anymore without importing at least a handful of modules.
15:34 <Aruro> why not, i want no imports
15:34 <erisco> first you have to set up your LANGUAGE pragma with a dozen extensions
15:34 <Cale> :D
15:34 <erisco> that's even before you get to importing :P
15:34 <Welkin> Aruro: then create a file called Imports.hs with all your imports, done
15:34 fizbin joined
15:35 justanotheruser joined
15:35 <Aruro> Welkin: true :)
15:35 bollu joined
15:35 <Cale> Actually, I think it might be better to have separate pragmas now, Ed Kmett style, just because it makes them easier to manipulate.
15:35 <Welkin> Cale: what is ed's style?
15:35 <Cale> One LANGUAGE pragma per line
15:36 <Welkin> oh, yeah
15:36 <Welkin> I use that too now
15:36 <Welkin> I saw it in many places and just started using it
15:36 <Cale> (I'm associating that with him just because some of his talks started with a slide filled with pragmas :D)
15:36 <Welkin> but then you need to line up the closing brackets of all of them
15:36 <Cale> no
15:36 <Welkin> yes!
15:37 <Cale> I also don't like lining up module names and import lists in the imports
15:37 <Welkin> o.o
15:37 <Cale> It just wastes time, and makes things hard to edit
15:37 <Welkin> everything needs to be lined up perfectly
15:37 <Cale> You add a new import with a longer name, and then you have to edit everything again
15:38 <tsahyt> I do like to keep qualified imports separate from unqualified ones
15:38 <erisco> this is my style http://lpaste.net/354211
15:38 <Cale> and it doesn't actually make anything more readable, since those are separate unrelated things
15:38 <jmcarthur> I love the idea of hindent, if only it supported a style I liked.
15:38 <tsahyt> i.e. in a separate block of imports, separated by an empty line
15:38 <Cale> tsahyt: I like to keep them in alphabetical order, ignoring the qualified bit
15:38 <Welkin> lol what
15:39 <Cale> I really really wish that the syntax was import Foo qualified as ...
15:39 <tsahyt> Cale: yeah me to. I sometimes forget doing that though, so I end up with ordering commits.
15:39 <Welkin> Cale: you don't like to line them up, but they need to be alphabetized?
15:39 <tsahyt> jmcarthur: Is this yours? http://hackage.haskell.org/package/stable-memo
15:39 <Welkin> o.o
15:39 <Cale> Welkin: yeah, because that serves a purpose when you're trying to find stuff
15:39 <jmcarthur> tsahyt: yes
15:39 <Welkin> alphabetizing is the most annoying thing ever
15:39 <Welkin> I hate it
15:39 <tsahyt> jmcarthur: I just remembered when I saw your nick. It doesn't compile with GHC 8 anymore, due to a version bound problem.
15:39 <tsahyt> On ghc-prim iirc
15:39 <Cale> Well, you can almost just sort, except for the qualified ones :)
15:40 <Welkin> I tend to group by purpose
15:40 <Aruro> why ghc does not infer imports from types?
15:40 <Aruro> in most cases there are no problems
15:40 <Cale> Welkin: Oh, I do that too actually.
15:40 <glguy> Aruro: because it infers types from imports
15:40 Guest71 joined
15:40 <Welkin> all of the containers go together, all of the control modules together, specific libraries, internal modules
15:40 <jmcarthur> tsahyt: I really need to stay on top of these things. Thanks for letting me know. I will update it. I should probably also throw all my projects on github just so there is a reasonable place for people to file bug reports like this...
15:40 <Cale> Usually project imports are separate from imports from our in-house library of miscellany which are separate from external imports.
15:41 <sm> Welkin: omg that would be an endless project
15:41 <sm> I group by mine / external, that's it
15:41 <jmcarthur> tsahyt: What I first made that I was still on my stubborn kick of using darcs (and I'd still like to be, but I have since compromised on only using darcs for projects I don't intend to share with others...)
15:41 <tsahyt> jmcarthur: it's been a while but it compiled just fine after just changing the version bound, and from what I could gather nothing should be affected by the changes in ghc-prim, but I didn't test it properly. I ended up needing something that worked via Eq on the keys
15:42 <jmcarthur> tsahyt: Thanks!
15:42 <tsahyt> you're welcome. I figured it's such a small change that sending an actual patch would be more work than just telling you. I just never got around to it :)
15:42 <tsahyt> more work in applying the patch I mean
15:42 <sm> jmcarthur: the darcs authorities notice you have not yet reported to darcs hub yet.
15:43 insitu joined
15:43 <tsahyt> I should maybe have a look at darcs one day. but git also does everything I want from it.
15:43 m1911 joined
15:44 kritzcreek_ joined
15:44 Lord_of_Life joined
15:45 iomonad joined
15:45 simendsjo joined
15:45 m1911 joined
15:45 <jmcarthur> sm: I haven't?
15:45 <sm> jmcarthur: oops, the darcs authorities are wrong. Their bureaucracy is imperfect, thank god
15:45 <jmcarthur> :)
15:46 m1911 joined
15:46 cmsmcq_ joined
15:47 <tsahyt> since people keep asking me about haskell books, were there ever any plans of a second edition of real world haskell?
15:47 <erisco> {#- LANGUAGE x, y #-} = {-# LANGUAGE x #-}; {-# LANGUAGE y #-} it's a monoid morphism :3
15:47 <tsahyt> I used that book back then and it was already slightly outdated, but I found it to be a very good resource for learning the language initially
15:47 iomonad joined
15:48 jathan joined
15:49 <erisco> "book, back then" not "book back, then" heh
15:49 hypermonad left
15:50 <Aruro> its one of those rare books which treated haskell like programming language not like Cathegory Theory toy
15:51 mada joined
15:51 <tsahyt> yes. it's probably part of the reason why I saw practical value in the language from the very start. I only later got bogged down in exploring all the nice abstractions
15:52 <hsk3> These two books are great for beginners: http://learnyouahaskell.com http://haskellbook.com
15:52 <tsahyt> but I'm also a sucker for elegant design based on mathematical ideas
15:52 mak joined
15:52 <tsahyt> so I'd have stuck with it either way I guess
15:52 <hsk3> i'm a sucker for pure funcs
15:52 <tsahyt> hsk3: they're what I usually recommend these days
15:52 <Welkin> I couldn't get into RWH
15:52 <Welkin> o.o
15:53 <hsk3> RWH was really bad imo, sorry to say. I was spending 99% of my time reading about some goddamn JSON parser lol
15:53 <hsk3> gave up
15:53 <Welkin> lol, exactly
15:54 <jmcarthur> I don't have unit tests for this. Wat.
15:54 iomonad joined
15:54 <erisco> you always have the mempty test
15:55 <Aruro> hsk3: a least it was the book which described clearly crap like hSetBuffering
15:55 <tsahyt> hsk3: that's a bit of an exaggeration. the JSON example is really rather short
15:55 argent0 joined
15:55 <hsk3> maybe i'll try it again
15:55 <hsk3> now that i know more about it. always good to learn stuff from diff authors
15:56 <hsk3> u get diff take on things
15:56 <Aruro> haskell designers hate beginners, this book helped that part
15:56 zero_byte joined
15:57 enitiz joined
15:57 <Aruro> solving real world things with begginner unfriendly tool
15:57 gawen joined
15:57 <tsahyt> hsk3: the libraries used in RWH are really outdated these days. you'll probably run into quite a few problems because the APIs simply aren't the same anymore
15:57 <hsk3> ah damn
15:57 <hsk3> ok
15:57 <hsk3> thanks for the heads up
15:58 mizu_no_oto joined
15:58 <erisco> the meaning people often ascribe to "real world" either doesn't understand what "real" or "world" means
15:58 Mysterious_Light joined
15:58 takle joined
15:58 <Welkin> it's a crappy reality tv show
15:58 Mysterious_Light joined
15:58 Terry_ joined
16:00 NikolajK joined
16:00 <Aruro> just today guy got stuck in ingenious design of haskell numerical classes, i think he went back to python
16:00 <tsahyt> Aruro: I've found that the haskell language as such is actually very beginner friendly. it's the towers of abstraction that we've come to love and expect that isn't
16:00 <NikolajK> does Haskell have join for IO (IO ())?
16:00 dawehner joined
16:00 <erisco> yes, as do all instances of Monad
16:00 <tsahyt> :t join (f :: IO (IO ()))
16:00 <lambdabot> error:
16:00 <lambdabot> • No instance for (FromExpr (IO (IO ()))) arising from a use of ‘f’
16:00 <lambdabot> • In the first argument of ‘join’, namely ‘(f :: IO (IO ()))’
16:00 <tsahyt> damn
16:00 <tsahyt> :t join (undefined :: IO (IO ()))
16:00 <lambdabot> IO ()
16:01 <tsahyt> there
16:01 <jmcarthur> :t join :: IO (IO a) -> IO a
16:01 <lambdabot> IO (IO a) -> IO a
16:01 <tsahyt> :t join
16:01 <lambdabot> Monad m => m (m a) -> m a
16:01 <tsahyt> the general version
16:01 <tsahyt> NikolajK: note that this doesn't constrain you to some specific monad. it works for all monads
16:01 <NikolajK> can someone tell me what's wrong here, then
16:01 <NikolajK> https://pastebin.com/cWk0PHrW
16:01 Mysterious_Light joined
16:01 <tsahyt> you could read this as forall m. Monad m => m (m a) -> m a
16:02 <tsahyt> forall m a. actually
16:02 <tsahyt> NikolajK: why the join and fmap construct over just using >>=?
16:03 <NikolajK> it's just to understand
16:03 <tsahyt> :t \f -> join . fmap f
16:03 <NikolajK> the code with do works, I'd like to write it with join now
16:03 <lambdabot> Monad m => (a1 -> m a) -> m a1 -> m a
16:03 <tsahyt> :t (>>=)
16:03 <lambdabot> Monad m => m a -> (a -> m b) -> m b
16:03 <tsahyt> well, up to argument order
16:03 <Aruro> NikolajK: import Control.Monad
16:04 <jmcarthur> NikolajK: Is the error message that join doesn't exist? You might need Control.Monad.
16:04 <NikolajK> oh, thx!
16:04 nomicflux joined
16:04 <NikolajK> why can I use monadic do wihtout that package then oO
16:04 <Aruro> because!
16:04 <jmcarthur> The Monad type class is in Prelude, but some of the related functionality is not.
16:05 <NikolajK> makes you think join isn't implemented ;)
16:05 <erisco> the do-notation only needs >>=
16:05 sepp2k joined
16:05 <NikolajK> I thought that might be the case because I read somewhere IO is treated specially
16:07 tdfirth joined
16:07 <erisco> > do 5
16:07 <lambdabot> 5
16:07 <erisco> though I haven't figured out that one
16:07 <jmcarthur> IO doesn't get any special treatment in terms of interface.
16:07 <jmcarthur> It's only "special" in that it's a primitive type.
16:08 gugah joined
16:08 FreeBirdLjj joined
16:09 ggsmid joined
16:09 <erisco> I guess if you go through the desugaring rules only <- is relevant and everything else is just as-is
16:09 <erisco> and "let" is special, but otherwise
16:10 tdfirth joined
16:10 <erisco> and so the types are figured out after that
16:11 JuanDaugherty joined
16:11 <erisco> otherwise I'd expect it to be looking for a Monad instance with "do 5"
16:11 cobreadmonster joined
16:11 FreeBird_ joined
16:12 <Aruro> :t do undefined
16:12 <lambdabot> a
16:13 <Cale> > let in do 0
16:13 <lambdabot> 0
16:13 raynold joined
16:13 eazar001 joined
16:14 MindlessDrone joined
16:14 <erisco> > do let; 0
16:14 <lambdabot> <hint>:1:10: error:
16:14 <lambdabot> parse error (possibly incorrect indentation or mismatched brackets)
16:15 <Cale> > do let {}; 0
16:15 <lambdabot> 0
16:15 <erisco> weird
16:15 <Cale> It thinks the 0 is inside the let
16:15 BartAdv joined
16:16 <erisco> ah I suppose that is ambiguous
16:16 insitu joined
16:17 <erisco> give me the book back then
16:17 eklavya joined
16:17 <Cale> > do let in "the cat, would you?"
16:17 <lambdabot> "the cat, would you?"
16:18 <hpc> heh
16:20 connrs joined
16:21 yellowj joined
16:24 mrwonko joined
16:24 eklavya_ joined
16:24 <Hafydd> Haha.
16:25 <mrwonko> Hi, I just stumbled across a `AppSettings {..}` constructor and am wondering about the .. syntax. It's one of those phrases you can't Google for... Looks like it might use variables of matching name? Where can I find out more?
16:25 <bollu> > let in 5
16:25 <lambdabot> 5
16:25 <bollu> interesting
16:25 <bollu> why would that even be needed?
16:25 <bollu> is there some sort of laziness effect?
16:25 <erisco> mrwonko, is that actual code?
16:26 <Hafydd> mrwonko: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#record-wildcards
16:26 <mrwonko> erisco, yes, the yesdo-postgresql template contains a "return AppSettings {..}" line
16:27 <mrwonko> *yesod
16:27 <mrwonko> thanks, Hafydd, I'll take a look
16:27 <Hafydd> Yes, do!
16:27 <lambdafan> http://stackoverflow.com/questions/43170646/how-can-i-replace-my-usage-of-bracket-with-bracketp
16:27 <erisco> eh, I don't know why people are so attracted to these things
16:27 urodna joined
16:27 <lambdafan> I'm trying to replace my usage of bracket with bracketP
16:30 <erisco> I recently started using record puns because that solves a legitimate problem
16:30 Rainb joined
16:30 <erisco> but I am not sure what this wildcard is solving
16:31 aglorei joined
16:31 Edith joined
16:31 Unhammer joined
16:32 tomboy64 joined
16:32 <mrwonko> here's the context I saw it in, fwiw: https://github.com/mrwonko/victory-disaster/blob/master/Settings.hs#L63-L88 without the wildcard there'd be a lot of redundancy, wouldn't there?
16:33 wildlander joined
16:33 azahi joined
16:33 Unhammer joined
16:33 aglorei joined
16:33 balor joined
16:34 tomboy64 joined
16:34 Rodya_ joined
16:34 cpup joined
16:34 rios joined
16:35 <erisco> eh, it could be written in Applicative-style instead
16:35 <erisco> but this introduces issues with maintaining correct order
16:36 <erisco> I can see the legitimacy in this specific scenario
16:36 ChaiTRex joined
16:37 pepe` joined
16:37 <erisco> it is overlapped with implicit parameters
16:38 <erisco> so you could also see X{..} as the implicit wrapper on the constructor X
16:39 <erisco> except in the pattern position where it means something else
16:39 raycoll joined
16:39 <erisco> and I don't like it in the pattern position at all because it adds a problem
16:39 plshelpme joined
16:40 <erisco> the problem record puns solves is you do not depend on the constructor arity in your definitions
16:40 <pepe`> TH question: does anyone know the incantation to splice a type variable in when generating a type ?
16:40 <pepe`> > wrapInIO ( _ :: Proxy a) = [| IO $a |]
16:40 <lambdabot> <hint>:1:26: error:
16:40 <lambdabot> parse error on input ‘=’
16:40 <lambdabot> Perhaps you need a 'let' in a 'do' block?
16:40 <erisco> so if you add or remove fields in your data you do not necessarily have to change other definitions
16:41 <erisco> now if you add this wild card you reintroduce the problem!
16:41 <pepe`> > let wrapInIO ( _ :: Proxy a) = [| IO $a |] -- $a does not do what I want
16:41 <lambdabot> <hint>:1:33: error: parse error on input ‘|’
16:41 dfeuer joined
16:41 <pepe`> And of course that should be a type splice: wrapInIO ( _ :: Proxy a) = [t| IO $a |]
16:42 <erisco> because you can cause name conflicts
16:43 <erisco> (you also do not depend on field order with record puns, I forgot)
16:47 eacameron joined
16:47 ner0x652 joined
16:49 e14 joined
16:50 Achylles joined
16:50 mazeinmaze_ joined
16:51 xall_ joined
16:54 Guest71 joined
16:54 phi_ joined
16:55 <Deewiant> Is there any package with a UTF-8 codec supporting roundtripping of lone UTF-16 surrogates? Like RoundtripFailure in https://hackage.haskell.org/package/base- (but without having to use a GHC.* module that only operates in IO land)
16:55 eacameron joined
16:56 <erisco> come one come all to IO Land, where anything is possible!
16:57 eazar001 joined
17:00 albertus1 joined
17:00 <phi_> Does anyone know a good encoding of free algebra over a monoid? I want a type T a b where a is the base field, and b is a monoid. The best I can think of is Map b a but I can the multiplication in T a b being pretty.
17:01 <erisco> phi_, I had the question of what qualifies as a free algebra and I was particularly wondering about monoid, so if you have any knowledge to offer that'd be great
17:01 jgertm joined
17:02 <erisco> for example, is Maybe a free algebra over a monoid? I don't know
17:02 teqwve joined
17:02 teqwve left
17:02 eschnett joined
17:02 patbecich joined
17:03 zargoertzel joined
17:03 <phi_> @erisco I am talking about unital associative algebra i.e vector space with associative multiplication
17:03 <lambdabot> Unknown command, try @list
17:03 <erisco> okay, I don't know what that is, but could you explain what a free algebra is?
17:04 <abhiroop> Are there any examples of actually parsing binary data using binary or cereal or attoparsec available? I could not find anything
17:04 enitiz_ joined
17:05 <phi_> By free algebra I just mean that the basis elements are the elements of the monoid and we multiplication is just the multiplication of the monoid extended by linearity
17:05 <centril> is there any operator :: (a, b) -> (c, d) -> ((a,c), (b, d)) ?
17:05 <centril> in base or any other popular package
17:06 Hexagenic joined
17:06 <centril> also: :: (a, a) -> (a -> b) -> (b, b)
17:07 zcourts joined
17:08 <tippenein> abhiroop: most things I've ever done look similar to this https://gist.github.com/niteria/5565110
17:10 <erisco> centril, not any operator I am aware of but these are easily defined tacitly, I think
17:10 <tippenein> centril: this one's close: Data.Tuple.HT mapPair :: (a -> c, b -> d) -> (a, b) -> (c, d)
17:10 <tippenein> n/m, not really
17:10 <centril> erisco: sure sure, i just wanted a ready one to not make up my own notation
17:11 Guest71 joined
17:11 <tippenein> (***) :: (a -> a') -> (b -> b') -> (a, b) -> (a', b')
17:11 <centril> tippenein: ye, but (***) is not what I want ^^
17:12 <Deewiant> :t join (***) :: (a -> b) -> (a, a) -> (b, b)
17:12 <lambdabot> (a -> b) -> (a, a) -> (b, b)
17:12 <Deewiant> :t join bimap :: (a -> b) -> (a, a) -> (b, b)
17:12 <lambdabot> (a -> b) -> (a, a) -> (b, b)
17:12 eklavya joined
17:12 <Deewiant> I prefer the latter but YMMV
17:12 <centril> I want to do: (`div` 2) * (id &&& (+1))
17:13 <centril> for some operator *
17:13 <jmcarthur> :t biliftA2 (,) (,) :: (a, b) -> (c, d) -> ((a,c), (b, d))
17:13 <lambdabot> error:
17:13 <lambdabot> • Variable not in scope:
17:13 <lambdabot> biliftA2
17:13 <jmcarthur> It's in Data.Biapplicative from the bifunctors package.
17:14 <centril> jmcarthur, Deewiant : cheers
17:14 <erisco> centril, what is that supposed to do, though?
17:14 <centril> :t (`div` 2) &&& (`div` 2) . (+1)
17:14 <lambdabot> Integral b => b -> (b, b)
17:14 <centril> erisco: ^
17:15 <erisco> so (`div` 2) * (id &&& (+1) = (`div` 2) &&& (`div` 2) . (+1) ?
17:15 <centril> erisco: yes
17:16 skeuomorf joined
17:16 vaibhavsagar joined
17:16 ph88^ joined
17:17 eazar001 joined
17:17 osa1 joined
17:17 <jmcarthur> I think it's pretty well known that StdGen is not a very good PRNG. Is there an alternative that still has a RandomGen instance?
17:18 tobhe joined
17:18 <erisco> hm, why not (h &&& i) * (f &&& h) = h . f &&& i . h ?
17:19 <jmcarthur> I see tf-random, but am not sure how to evaluate it.
17:19 <centril> erisco: that repeats h
17:19 <erisco> so what, use join
17:20 <centril> erisco: like ?
17:20 <erisco> :t join (&&&)
17:20 <lambdabot> Arrow a => a b c' -> a b (c', c')
17:20 mda1 joined
17:21 jathan joined
17:22 <centril> erisco: so this is a join on the (-> b) monad ?
17:22 a3Dman joined
17:22 <erisco> yes
17:22 <erisco> I don't know if * is implementable as I stated it, but you want something as regular as that
17:23 <erisco> really you'd just use ***
17:23 FreeBirdLjj joined
17:24 sleffy joined
17:24 <erisco> > (join (***) (`div` 2) . (id &&& (+1))) 5
17:24 <lambdabot> (2,3)
17:25 <centril> erisco: right, and we can just say (*) = join (***)
17:25 <erisco> no, * = .
17:27 <erisco> pictorially, &&& splits one line into a pair of lines, and *** maps a pair of lines
17:27 <jmcarthur> I'll just go with tf-random for now, because I see indications that it's pretty high quality, but I'm a little sad that it's probably pretty slow. I'm pretty sure there has been some more recent work on splittable PRNGs that should be pretty fast, but I don't remember how to find it.
17:27 splanch joined
17:27 <erisco> these operations are concatenated with (.)
17:27 phi__ joined
17:27 mstruebing joined
17:27 <erisco> once you have the pair of lines you can keep using *** to map them
17:28 <centril> erisco: (*) f g = join (***) f . g
17:28 <erisco> so (h *** i) . (f *** g) = h . f *** i . g
17:28 <erisco> but I don't think you can get something similar for &&& because of the types
17:28 kuribas joined
17:29 PennyNeko joined
17:29 <erisco> eh, no, I wouldn't define that centril
17:30 insitu joined
17:30 conal joined
17:32 <erisco> at most I would give a name for join (***)
17:32 <erisco> I don't see the purpose of including function composition in it
17:32 marsam joined
17:34 meghnath joined
17:35 caumeslasal joined
17:36 enitiz joined
17:36 Rodya_ joined
17:37 Levex joined
17:39 abhiroop joined
17:39 phi_ joined
17:39 Kerogaz joined
17:41 MindlessDrone joined
17:43 <erisco> phi_, I can't follow the jargon there, sorry
17:44 ublubu joined
17:45 itachi joined
17:45 <erisco> phi_, I don't know what "multiplication of the monoid extended by linearity" means
17:47 <phi_> @erisco no problem. The basic idea is this: an element of Free algebra is of the form sum_{i}(a_{i},b_{i}) where b is an element of monoid and a the element of base field
17:47 <lambdabot> Unknown command, try @list
17:48 <erisco> what does it mean for an element to be of that form?
17:50 jsgrant-_ joined
17:50 Goplat joined
17:51 <phi_> This means that I have a scalar multiplication which is a formal multiplication (aka tupling) between an element of my base field and an element of monoid. Then an arbitrary element is a formal sum of elements obtained in this way.
17:52 <phi_> So morally this is like Set(a,b)
17:52 epsilonhalbe joined
17:52 epsilonhalbe left
17:52 MindlessDrone joined
17:53 fizruk joined
17:53 Lord_of_Life joined
17:54 <erisco> why you say "an element of Free algebra" are you saying "a Free algebra"?
17:54 <phi_> But I also need to define multiplication between two such elements and I do this by just expanding and for term of the expansion using multiplication of base field and mconcat of the monoid
17:55 <phi_> Free Algebra is a type
17:55 <erisco> as in, "an element of Real" is the same as "a Real"
17:55 <erisco> okay
17:56 Lord_of_Life joined
17:57 <erisco> and so the actual type we choose only has to be isomorphic to this sum of tuples, right?
17:57 ph88^ joined
17:57 lambdafan joined
17:58 <phi_> Yes but we need to cut down by the relation imposed such as (a,b)+(c,b) = (a+c,b)
17:59 <erisco> okay
18:01 chaosmasttter joined
18:04 dan_f joined
18:05 insitu joined
18:06 <erisco> phi_, and what about (a,x)+(b,y) ?
18:07 <phi_> That a,b,x,y are all distinct that is just a formal sum
18:07 darjeeling_ joined
18:08 <phi_> if a and b are same then it is a*(x+y)
18:08 <erisco> no sorry I asked incorrectly
18:08 <erisco> I mean in our free algebra, what is the sum of these?
18:08 marsam left
18:09 conal joined
18:09 <erisco> so one element is from another monoid, and one is from our base field
18:10 <phi_> It is just this. There is no way to reduce this for arbitrary a,b,x,y. That is roughly what it means to be free here.
18:10 <phi_> The monoid and base field are both fixed
18:10 tmlm joined
18:10 JuanMiguel joined
18:11 <phi_> so a and b are both elements of base field and x , y come from the monoid
18:11 <erisco> okay, I am struggling to go between your definition and the implementation
18:11 <erisco> but I am back to my earlier confusion which can't be what free algebras are supposed to be
18:11 <erisco> let me see if I can dig itup
18:11 <phi_> I don't have an implementation, it is what I want.
18:12 <erisco> I know
18:12 xall_ joined
18:12 ertesx joined
18:12 <erisco> well I can't remember where I put it so I will just retype it
18:14 <erisco> here: http://lpaste.net/354212
18:14 <erisco> you can play this game for every type class
18:15 <erisco> then also you get eval :: Monoid a => FreeMonoid a -> a
18:16 richi235 joined
18:17 <erisco> you don't necessarily need the reduction of Mempty's there either and can instead offload it to ==
18:18 <erisco> phi_, you can add another monoid in there along for the ride. It should be easy to adapt, but I don't know if this relates at all to what you're thinking of
18:18 <phi_> This is a free monoid but my question would be more like if it is possible to encode associativity in the type as well
18:19 <erisco> what is an example of that? or any other law?
18:19 <erisco> I don't understand how associativity of mappend can be encoded in the type FreeMonoid a
18:20 <erisco> would that mean the only type-correct implementation of mappend is associative?
18:20 sboosali joined
18:21 Wuzzy joined
18:22 <phi_> I don't know how to encode it, but in this case you can write an Eq instance that makes Mappend (a (Mappend b c)) == Mappend ((Mappend a b) c)
18:22 Mysterious_Light joined
18:22 <phi_> A free algbra has more such relations and I was wondering if someone has a good way of dealing with them
18:23 <ph88^> i'm trying to write a parser which parses like this https://bpaste.net/show/f499ac22b819 but i'm getting a bit confused, i used parsers before, but i don't know how to start with this one
18:23 Mysterious_Light joined
18:23 mda1 joined
18:24 <erisco> phi_, ah, so that equality must be decidable without inspecting the values of a
18:25 <erisco> phi_, or did I misunderstand?
18:25 patbecich joined
18:25 <ph88^> i'm gonna give it a shot, hold on
18:26 <erisco> otherwise, if I can just write instance (Eq a) => Eq (FreeMonoid a) it is easy
18:27 patbecich joined
18:27 patbecich joined
18:28 splanch joined
18:28 <erisco> I suppose it should also be realised that FreeMonoid doesn't have any values of a, heh
18:28 lordcirth joined
18:28 TheLemonMan joined
18:28 <phi_> What I meant was you can probably export some smart constructor such that using them you can't observe the difference between mappend (a (mappend b c)) and mappend ((mappend a b) c)
18:28 abhiroop joined
18:28 <erisco> and in that case it is easy to write the instance without Eq a
18:29 mda1 joined
18:32 <phi_> I see that now and I also think it is not quite the right FreeMonoid. I think FreeMonoid is actually just [a] with mconcat being concat. And it is associative.
18:33 <erisco> what makes it the right one?
18:35 <_sras_> I was a function to strip tags from a piece of possible html and extract only the text content. The 'Hakyll' package has a function for this, it feels a bit massive dependency for just one function. Is compiler smart enough to just include code for this function, and leave the rest of the package, in the final executble?
18:35 <phi_> In my mind at least (not sure what the rigorous definition is) Free version of some algebraic structure A is just some instance of A which has no relations expect those implied by the definition of A
18:35 crobbins joined
18:36 <erisco> is it the case there are multiple or is one actually wrong?
18:36 Rodya_ joined
18:37 <geekosaur> _sras_, it works like any other linker, because this is up tot he linker. dynamic libs get linked completely (but you don't really care as it's shared), static libs link only what's needed
18:37 <erisco> I am guessing the problem with my FreeMonoid is that, in terms of the "moral set" you spoke of, it is empty
18:37 _sg joined
18:38 <erisco> because there are no free terms related to base terms
18:38 <phi_> In the version you put up the only possible values are Mempty, Mappend Mempty Mempty , Mappend (Mappend Mempty Mempty) Mempty and so on which should all be Mempty
18:38 <phi_> I mean using the laws of Monoid they should all be Mempty
18:38 <erisco> then it may as well be instance Monoid (Proxy a)
18:38 e14 joined
18:39 <_sras_> geekosaur: So what does that mean?
18:39 <geekosaur> it would even split modules up with --split-objs (--split-sections in ghc 8.2 which is even better) but this is unusual for non-core libs because it's slower and more complex
18:39 <erisco> yes, that's right, but what makes this wrong? well I can't see how it is from your description
18:39 <erisco> other than it is trivially correct
18:39 <geekosaur> um
18:39 <erisco> whereas with [a] you do have a related free term for every base term
18:40 splanch joined
18:40 <erisco> i.e. x:[] relates to x
18:41 <_sras_> geekosaur: I mean, should I worry about the size of the dependency?
18:41 <geekosaur> "yes if hakyll is bulit statically, no if it is built dynamically, if it is built dynamically *stop worrying about it*, and which one you get depends on how ghc was built. if this does not make sense to you, stop worrying about it"
18:41 <erisco> phi_ is this the correct way to look at it?
18:41 <geekosaur> _sras_, in a world where dynamic linking is normal, your question makes no sense
18:41 <phi_> x is not an element of [a] only x:[] is
18:41 NikolajK joined
18:41 <geekosaur> libraries always get pulled in completely because that's how they work
18:42 NikolajK left
18:42 <erisco> I didn't say it was, that isn't what I meant
18:42 <geekosaur> this is true of *any* language that produces native code. The answer will not differ for Haskell or C or C++ or rust or golang or ...
18:42 <erisco> I am pointing out the difference between my FreeMonoid a and [a]
18:42 <erisco> with FreeMonoid a the relation of free terms to base terms is empty
18:43 abhiroop joined
18:43 <erisco> so it is a trivial free algebra (I am conjecturing), whereas for every x :: a there is x:[] :: [a]
18:45 splanch joined
18:45 <erisco> that is how I am qualifying the difference between the two. otherwise I don't see why we care between the two
18:46 <phi_> FreeMonoid and Free Algebra over a monoid are two very different things. The monoid in a Free Algebra is not necessarily free
18:46 <_sras_> geekosaur: Guess I will just go into the source and just copy paste what ever there is..
18:46 <geekosaur> sigh
18:46 rios joined
18:46 <geekosaur> ok, hellbent on micromanagement. buuild a statci ghc
18:47 <geekosaur> make sue to build the rest of the os static too, even though you will in fact end up wasting space that way but it will look smaller to you
18:47 <erisco> phi_, well you said FreeMonoid was correct at one point. can you clarify what is wrong about it now?
18:47 FreeBirdLjj joined
18:48 akfp joined
18:48 <akfp> is there a function for lists that work like grep -A 3 - i.e. give me a context of 3 elements before and after the element?
18:49 <erisco> and let me also change FreeMonoid a so it has a non-empty relation
18:49 <phi_> I was wrong, the problem is that by your FreeMonoid has only one value, which is a relation (or restriction) not required by definition of monoid.
18:50 serendependy joined
18:50 chaosmasttter joined
18:50 <phi_> But according to http://comonad.com/reader/2015/free-monoids-in-haskell/ even my intuition about List being the free monoid is wrong.
18:50 <erisco> if it does not require it then having it does not make it wrong
18:50 <erisco> not-a-requirement is not the same as requiring the absence
18:51 e14 joined
18:51 <phi_> But that is what Free part means at least morally.
18:52 <erisco> well I tried to be specific about what that moral was. why do you object to my specification?
18:53 <_sras_> geekosaur: Are you saying I should include all of Hakyll for this function, stripTags, here https://hackage.haskell.org/package/hakyll-
18:54 crobbins joined
18:56 Levex joined
18:57 augur joined
18:57 <erisco> okay, the whole argument is predicated on this: " If (ordinary) lists were the free monoid, there would be a unique monoid homomorphism from lists to snoc lists."
18:57 <erisco> why can this be assumed?
18:58 <erisco> also they say "the free monoid" as though there can only be one
18:59 levex_ joined
18:59 insitu joined
19:00 <erisco> if I could get a clear understanding of what qualifies as a free algebra this wouldn't be so confusing
19:00 splanch joined
19:00 ludat joined
19:01 dawehner joined
19:02 presiden joined
19:03 <erisco> they bother to define "single :: a -> SL a" and a law "h [x] = single x" so I suspect my qualifier earlier is on point
19:03 <erisco> though if so then it is required that this exist for a free algebra
19:04 jmiven joined
19:05 geekosaur joined
19:05 Bin4ry joined
19:05 <erisco> though there must be a more precise way of saying it, because I think, say, single = const y for some y :: SL a wouldn't be satisfactory
19:05 <erisco> such as why not single = const Empty
19:06 brynedwards joined
19:06 <erisco> " a function that embeds a into SL a"
19:06 <erisco> so whatever "embeds" means
19:07 Achylles joined
19:07 alexelcu joined
19:08 msko joined
19:08 darkSeid_ joined
19:08 _sg2 joined
19:08 <erisco> so then I can imply that if X a is a monoid and there is a function f :: a -> X a which embeds a in X a, then it is candidate as a free algebra (i.e. those are required but not sufficient)
19:09 Netwolf joined
19:10 <erisco> but then I have a difficult time piecing together the rest of it, because then it seems to say that if I can come up with any two candidates and I cannot find a homomorphism between them then neither is a free algebra
19:10 Welkin joined
19:10 FreeBird_ joined
19:13 jayshua joined
19:14 eacameron joined
19:15 lifter joined
19:16 ccomb joined
19:16 FreeBirdLjj joined
19:16 <lifter> I use evil and general, and SPC is my leader key. My leader key doesn't work when in Help mode, however. Is there an easy way to get it to work?
19:21 biglama joined
19:21 <erisco> lifter, what are you talking about again?
19:21 ij left
19:21 <lifter> Sorry I asked in the wrong room! :(
19:22 akfp left
19:23 perrier-jouet joined
19:23 oisdk joined
19:24 Fairy joined
19:24 cfricke joined
19:25 Levex joined
19:27 Mysterious_Light joined
19:27 abhiroop joined
19:28 connrs joined
19:33 lifter joined
19:35 ericdwhite joined
19:36 Jesin joined
19:36 splanch joined
19:37 vtomole joined
19:37 ccomb joined
19:37 Rodya_ joined
19:37 ziocroc joined
19:38 msl09 joined
19:38 <msl09> I have a question
19:38 <msl09> In this expression
19:38 <msl09> [1,2] >>= \n -> ['a','b'] >>= \ch -> return (n,ch)
19:39 <msl09> I expected it to be evaluated as
19:39 <msl09> ([1,2] >>= \n -> ['a','b']) >>= (\ch -> return (n,ch))
19:40 <msl09> because haskell is left associative
19:40 <msl09> but instead it's evaluated as [1,2] >>= (\n -> ['a','b'] >>= \ch -> return (n,ch))
19:40 <glguy> operators have whatever associativity you specify
19:41 <glguy> and in this case the rule for parsing lambda expressions is winning out
19:41 <Sornaensis> what part of haskell is the worst
19:41 <msl09> what's the rule for parsing lambdas?
19:41 <qmm> https://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/ <- since the crux of this article is that you become distracted, i think there needs to be a "why learning category theory makes you a worse haskell programmer"
19:42 <qmm> i need to be writing haskell, but i'm too much interested in category theory :P
19:42 <glguy> lambda span as far right as they can
19:42 <msl09> hmm
19:43 <msl09> is there a place where I can find those rules?
19:43 <Sornaensis> yea, the ghc source I guess
19:44 stef_204 joined
19:44 <msl09> o_o
19:44 <msl09> I guess I'll never know then
19:45 <Sornaensis> msl09: https://hackage.haskell.org/package/haskell-src- <-- Haskell98 AST
19:46 Deide joined
19:46 fizruk joined
19:50 robertkennedy joined
19:52 <qmm> which convention for naming a function which returns a Maybe is suggested: mSomething, maybeSomething , or something?
19:52 <erisco> no one knows. we only learn of syntaxes experimentally
19:52 <erisco> at least that is how I feel when I program C++ :P
19:53 <erisco> qmm, somethingMaybe has been used
19:54 <MarcelineVQ> msl09, Sornaensis, erisco: https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-220003 "The grammar is ambiguous regarding the extent of lambda abstractions, let expressions, and conditionals. The ambiguity is resolved by the meta-rule that each of these constructs extends as far to the right as possible."
19:55 <erisco> that is not uncommon to say
19:56 <erisco> you state an ambiguous grammar for simplicity's sake and you either ignore the fact because it doesn't matter or you disambiguate by other means (which they've done the latter)
19:57 <Cale> Minimal munch would be so annoying
19:57 bollu joined
19:59 <Welkin> safe head has been called headMay, safeHead, etc.
19:59 <Welkin> the m- prefix is often used for pattern matching
20:00 <Welkin> muser <- <some action>
20:00 ompaul joined
20:00 <Welkin> then you match on muser for Maybe user or Nothing
20:00 <Welkin> er
20:00 <Welkin> Just user*
20:00 eacameron joined
20:00 <erisco> what if your context also includes people who muse?
20:01 <Welkin> mmuser
20:01 <erisco> but without uncertainty
20:01 Aruro joined
20:02 hybrid joined
20:02 insitu joined
20:03 <erisco> I have started using underscores a little bit
20:05 <Welkin> how terrible
20:06 <erisco> sometimes you want something like a suffix, and that is a standard notation for it
20:06 <erisco> like p_min and p_max rather than pMin and pMax
20:08 anuxivm left
20:08 Levex joined
20:09 ego joined
20:10 Lyraz joined
20:11 falafel joined
20:11 FreeBirdLjj joined
20:12 skeuomorf joined
20:13 dfeuer joined
20:13 ner0x652 joined
20:15 Fairy joined
20:17 leothrix joined
20:21 mmachenry joined
20:25 yinn joined
20:26 crobbins joined
20:27 <bennofs> minP maxP
20:31 coot joined
20:31 magneticduck joined
20:31 augur joined
20:32 Philonous joined
20:34 Itkovian joined
20:34 dawehner joined
20:37 splanch joined
20:38 crobbins joined
20:38 Rodya_ joined
20:38 <Sornaensis> @info Rational
20:38 <lambdabot> Rational
20:40 xyther joined
20:41 <geekosaur> no @info or :info in lambdabot
20:45 <robertkennedy> Can you express every unary function in the form `type Nat c fi fo = forall i. c i => fi i -> fo i`? Ie `show :: Nat Show Identity (Const String)`?
20:47 <lambdafan> binary operators take two values, unary operators take one value, what do you call an operator that takes no value
20:47 <rotaerk> a value
20:48 <lambdafan> nullary?
20:48 <geekosaur> nullary, yes
20:48 <lambdafan> wow nulary is a word
20:48 <lambdafan> nullary
20:48 <lambdafan> huh
20:49 <rotaerk> robertkennedy, what about functions where there is more than one class constraint?
20:49 mac10688 joined
20:50 hvr joined
20:51 <rotaerk> I guess you could just make a new class that inherits them, and use it as a proxy for them
20:51 zcourts joined
20:51 <robertkennedy> rotaerk: you could create a new type `type TwoConstraint a = (C1 a, C2 a)`? But then you're partially implying a type
20:51 <robertkennedy> No yeah you can. `class (C1 a, C2 a) => C a`
20:53 eacameron joined
20:54 <rotaerk> right
20:55 Destol joined
20:56 Levex joined
20:57 coot joined
20:58 <erisco> infinitary
20:58 zcourts joined
20:59 <erisco> is printf... arbitary?
20:59 <geekosaur> xview api functions when you forget the trailing ..., 0, 0
20:59 <geekosaur> :p
21:01 marcopullo joined
21:02 splanch joined
21:03 bollu joined
21:03 deepfire joined
21:05 takle joined
21:05 Mon_Ouie joined
21:07 Achylles joined
21:07 eacameron joined
21:07 splanch joined
21:08 <mniip> robertkennedy, yes
21:08 <mniip> but fi/fi don't have to be functors
21:08 <mniip> and it's not an iso
21:09 strykerkkd joined
21:11 armyriad joined
21:11 eacameron joined
21:12 takle joined
21:13 <robertkennedy> You mean what I've described isn't isomorphic to function type signatures?
21:13 ozgura joined
21:14 ozgura joined
21:15 ozgura joined
21:16 ozgura joined
21:16 BlueShark joined
21:17 ozgura joined
21:19 Mysterious_Light joined
21:19 takle joined
21:20 conal joined
21:21 <BlueShark> \x -> x x - what is this supposed to mean?
21:21 <BlueShark> I don't have any Haskell knowledge, ELI5 :p
21:25 <hpc> it's a function that takes a thing as a parameter
21:25 <hpc> let's name it 'x'
21:25 <hpc> and produces the value of x applied to itself
21:25 <hpc> as a function
21:26 eacameron joined
21:26 <BlueShark> Does it have any connection with hex?
21:26 <hpc> hex?
21:26 <BlueShark> hexadecimal?
21:26 <BlueShark> \x
21:26 <Cale> no
21:26 <hpc> oh, nothing to do with that
21:26 <Cale> \ is ascii art for the Greek letter λ
21:27 <Cale> which is a traditional notation for introducing a function
21:27 <hpc> and x itself could be any identifier
21:27 <hpc> \bananas -> bananas bananas
21:27 <Cale> The function's parameters go between the \ and the ->
21:27 <Cale> and then the result of applying the function is to the right of the ->
21:27 <Cale> > (\x -> x^2) 5
21:27 <lambdabot> 25
21:27 <BlueShark> An example would be really nice.
21:28 <mniip> hey Magnap
21:28 <Cale> > (\x -> 10 * x) 5
21:28 <lambdabot> 50
21:28 <thimoteus> :t \ bananas -> bananas bananas
21:28 <lambdabot> error:
21:28 <lambdabot> • Occurs check: cannot construct the infinite type: t ~ t -> t1
21:28 <lambdabot> • In the first argument of ‘bananas’, namely ‘bananas’
21:28 <Cale> > (\x y z -> x + y + z) 1 10 100
21:28 <lambdabot> 111
21:28 <mniip> BlueShark: hahahaha
21:28 <Cale> map (\x -> x^2) [1..10]
21:28 <mniip> did they make it a hint
21:28 <Cale> > map (\x -> x^2) [1..10]
21:28 <BlueShark> mniip: lol
21:28 <lambdabot> [1,4,9,16,25,36,49,64,81,100]
21:28 Mysterious_Light joined
21:28 wtetzner joined
21:28 <BlueShark> mniip: yes
21:29 frankpf joined
21:29 <thimoteus> > (\ x y -> x y) (+ 1) 3
21:29 <lambdabot> 4
21:30 jgt joined
21:31 systemfault joined
21:32 bjz joined
21:32 arawack joined
21:34 eacameron joined
21:34 armyriad joined
21:37 conal joined
21:39 Rodya_ joined
21:39 bollu joined
21:39 coot joined
21:40 mr_moist joined
21:41 Tesseraction_x joined
21:41 gugah joined
21:42 mr_moist left
21:43 ebzzry joined
21:52 silver_ joined
21:52 hiratara joined
21:54 splanch joined
21:58 mekeor joined
22:05 yellowj joined
22:05 yrdz joined
22:06 Cir0X joined
22:07 kickliter joined
22:08 kickliter left
22:11 sboosali joined
22:11 phyrex1an joined
22:12 phyrex1an1 joined
22:13 louispan joined
22:13 bjz joined
22:14 robertkennedy joined
22:17 ubsan_ joined
22:18 marr joined
22:19 jgertm joined
22:23 conal joined
22:24 enitiz joined
22:24 ericsagnes joined
22:27 sboosali joined
22:29 <Jello_Raptor> Is there a haskell library somewhere (probably in GHC?) that lets me mess around with thunks more directly? It doesn't look like such a thing exists but I'd like to be sure.
22:29 K4L1 joined
22:30 fizbin joined
22:31 <ezyang> what do you mean by "mess around directly"
22:31 hiratara joined
22:32 Big_G joined
22:32 l4m8d4 left
22:32 jgt joined
22:33 <Jello_Raptor> view unforced thunks at runtime, though I think what I want to do (lazily create mutable objects only when they're needed, while keeping track of a network of references ala observableSharing)
22:33 conal joined
22:34 <Jello_Raptor> is doable with unsafePerformIO, and being very very careful.
22:35 aarvar joined
22:36 <ezyang> You could try programming with IVars instead
22:36 <ezyang> An IVar is a write once mutable variable
22:37 Rainb joined
22:39 Rodya_ joined
22:40 robkennedy joined
22:41 <Jello_Raptor> nope, what I need is the ability to crate LVars on the the fly. I'm playing around with possible APIs/implementation structures for a dynamic propagator network. I want a user to be able to write propagators that are lazy in however many variables, and where the system doesn't actually create an LVar until it's needed.
22:41 <benzrf> what is an lvar?
22:42 <ezyang> well, an LVar is a lattice variable, Lindsey Kuper's thesis work
22:42 <Jello_Raptor> Paper => http://dl.acm.org/citation.cfm?id=2502326, Package => http://hackage.haskell.org/package/lvish
22:42 <ezyang> they generalize IVars
22:42 argent0 joined
22:43 <Jello_Raptor> mhmm, but the expectation is that the value in them will alwys grow monotonically with respect to some partial order, and the values stored in them form a commutative monoid
22:44 aarvar joined
22:45 <Jello_Raptor> commutative, idempotent monoid*
22:45 <Squarism> i found this GHC.IO.Handle - does "stderr" has handle defined globally?
22:45 <ezyang> yes it's a global handle
22:46 <Squarism> does it have a name?
22:46 <Squarism> ezyang, ?
22:46 LuckyRawApe joined
22:46 ludat joined
22:46 <ezyang> uh... stderr?
22:46 <ezyang> :t System.IO.stderr
22:46 <lambdabot> GHC.IO.Handle.Types.Handle
22:47 <Squarism> ok thanks
22:51 <lyxia> Jello_Raptor: Hqve you seen this relevant SO question http://stackoverflow.com/questions/28687384/test-if-a-value-has-been-evaluated-to-weak-head-normal-form
22:51 hmoorerg joined
22:52 jao joined
22:53 itachi joined
22:54 eacameron joined
22:54 Kundry_Wag joined
22:54 nomicflux joined
22:55 <Jello_Raptor> lyxia: right, that's similar to the unsafePerformIO solution I thought of. But it's good to see I'm on the right track, at least iff this how i want to structure the final system.
22:56 zcourts_ joined
22:58 robertkennedy joined
23:00 Koterpillar joined
23:04 ash__ joined
23:05 ash__ left
23:09 <lyxia> Jello_Raptor: The second answer seemed closest to it.
23:16 WhiskyRyan joined
23:18 conal joined
23:18 mizu_no_oto joined
23:19 _Mzungu_ joined
23:19 theDon_ joined
23:20 nomicflux joined
23:20 mizu_no_oto joined
23:21 sw1nn joined
23:21 meba joined
23:23 markus1209 joined
23:23 markus1219 joined
23:23 nakal joined
23:24 WhiskyRyan joined
23:26 robkennedy joined
23:27 mrler joined
23:27 sophiag joined
23:34 WhiskyRyan joined
23:35 <sophiag> this is my first time using a GADT and i'm getting some errors i don't understand calling its data constructors: http://lpaste.net/354215
23:35 np356 joined
23:38 zero_byte joined
23:38 louispan joined
23:40 splanch joined
23:41 <mniip> sophiag, well first of all NumOp is a binary constructor
23:41 <mniip> and you're applying it to a binary function
23:42 <mniip> a similar mistake is in EqOp and BoolOp
23:43 <mniip> sophiag, I can't exactly see what you were trying to do here
23:43 <sophiag> mniip: i don't understand the latter part of that. the return types of those functions match, except wrapped in Maybes. i tried testing it without the Maybes and got the same errors
23:44 <mniip> ignoring contexts and equational constraints, what you've defined is
23:44 mrjake joined
23:44 <mniip> data OpT a = NumOp a a | EqOp (OpT a) (OpT a) | BoolOp Bool Bool
23:46 <sophiag> oh... so the problem is in how i'm writing the constructors? as mentioned, this is my first time working with GADTs
23:46 <mniip> what are you trying to say
23:46 <mniip> I mean, what do you want to express with your code
23:47 <sophiag> well, if you're saying that's what OptA translates into then it's clearly not correct
23:47 <tobiasBora> Hello,
23:47 <tobiasBora> I've a strange problem with regexp:
23:47 <sophiag> before i made it a GADT it looked like this: data OpT a = (Num a, Fractional a) => NumOp (a -> a -> a) | (Eq a) => EqOp (a -> a -> Bool) | BoolOp (Bool -> Bool -> Bool)
23:47 <tobiasBora> (regexp and unicode)
23:47 <tobiasBora> If I do:
23:47 <tobiasBora> import Text.Regex as REG
23:48 <tobiasBora> str = "🔶@BO.com
23:48 <tobiasBora> "
23:48 <mniip> tobiasBora, you might want to pastebin if it's long
23:48 <mniip> @where lpaste
23:48 <lambdabot> http://lpaste.net/
23:48 jmcarthur joined
23:49 oisdk joined
23:49 <mniip> sophiag, what should the 'a' in OpT imply?
23:50 np356 joined
23:51 <sophiag> the variables in the data constructors
23:51 <tobiasBora> mniip: It was 3 lines, but I put it here: http://lpaste.net/354218
23:51 <mniip> sophiag, that's not enough information
23:52 <tobiasBora> And the problem is that basically, the unicodes char like "\128310" match the regexp "^([a-zA-Z0-9])$" which is really weird!
23:52 conal joined
23:53 <sophiag> mniip: can you correct my understanding then? i was under the impression variable in type constructors corresponded to the same variable in data constructors
23:53 <Koterpillar> > len "\128310"
23:53 <lambdabot> error:
23:53 <lambdabot> • Variable not in scope: len :: [Char] -> t
23:53 <lambdabot> • Perhaps you meant one of these:
23:53 <Koterpillar> > length "\128310"
23:53 <lambdabot> 1
23:54 zcourts joined
23:55 <* geekosaur> wonders which backend was used there, and if it speaks utf8
23:55 <mniip> tobiasBora, what module are you using for Text.Regex
23:55 <tobiasBora> geekosaur: I think it's supposed to be emoji from instagram...
23:56 <mniip> what comes to mind is that in PCRE [a-z] really means isAlpha
23:56 <mniip> which will match unicode chars too
23:56 <tobiasBora> mniip: What do you mean? I really wrote in my code (or in ghci) the code I paste
23:56 <geekosaur> ...
23:56 <dmwit> tobiasBora: https://wiki.haskell.org/Regex_Posix "If you want a bug-free and/or portable POSIX extended regular expression library to use from Haskell, then regex-posix will not help you. You should use the regex-tdfa package instead."
23:57 <geekosaur> you are very confused. nobody is talking about *your* code, but the package you imported Text.Regex from (if you didn't specify one, you get to go find ghc's compile log to see which one it picked).
23:57 <mniip> errrr
23:57 <mniip> package
23:57 <mniip> is the word I was looking for
23:57 <geekosaur> and if it's from regex-posix, there's a very good chance it fails in bizarre ways with UTF8
23:58 <mniip> yes
23:58 fDev2179 joined
23:58 <mniip> sophiag, in GADT you write out the type of the constructor
23:58 <geekosaur> if it's from pcre, you need to make sure the pcre library it used was built with utf8 support (some platforms don't, or force you to install a specific package to get the utf8 one)
23:58 robertkennedy joined
23:59 <tobiasBora> dmwit: Ok I'll try it thank you!
23:59 <mniip> sophiag, like, a proper type
23:59 louispan joined
23:59 <geekosaur> tdfa is slower because it's pure haskell, but it is guaranteed to work correctly
23:59 <fDev2179> I've written some simple functions which can generate a uniform N-dimensional grid. I'd like a critique if someone has the time.
23:59 <mniip> sophiag, my question regarding what you want the tyvar in 'OpT a' be is the key point of using GADTs
23:59 lambda-11235 joined
23:59 <tobiasBora> geekosaur: Indeed I was confused
23:59 <fDev2179> Here's the code: https://pastebin.com/23wnPVSX
23:59 <mniip> you could have nontrivial logic behind the typing of your datatype
23:59 <mniip> that is the whole point of GADTs