merijn 2017-01-31 03:48:46
ertes: That bleeds into too much work territory :p
ertes 2017-01-31 04:13:42
merijn: https://gist.github.com/esoeylemez/2d5f25681c3a41c3633bd2566ce61501
ertes 2017-01-31 04:13:50
not too much work =)
ertes 2017-01-31 04:14:22
printf "Blah % and blubb %." 3 5 :: String
merijn 2017-01-31 04:15:09
ertes: Yes, but that's terribad, because you don't check arguments ;)
ertes 2017-01-31 04:15:23
merijn: what do you mean?
ertes 2017-01-31 04:15:53
i'm only doing placeholdering, so there is really nothing to check
tsahyt 2017-01-31 04:22:28
Is there a way to get a heap profile from an application that I abort on the command line?
tsahyt 2017-01-31 04:23:18
nevermind, -hc actually works, it's -p that doesn't.
merijn 2017-01-31 04:24:30
It's time for my monthly "I wish Haskell had multi-patterns like Ocaml" dream
lep-delete 2017-01-31 04:25:14
example?
merijn 2017-01-31 04:25:57
case foo of { Foo | Bar -> doX; Baz | Quux -> doY; Xyzzy -> doZ }
lep-delete 2017-01-31 04:26:53
i c
merijn 2017-01-31 04:27:12
In haskell you end up having to write doX and doY twice
nitrix 2017-01-31 04:27:32
The compiler would be able to distinguish the multi-pattern from guards because of the capital letter...
merijn 2017-01-31 04:27:47
nitrix: Could even invent different syntax for multi-patterns
nitrix 2017-01-31 04:27:52
Yet I think it'd made the code harder to read. I'm too used to guards being associated to |
merijn 2017-01-31 04:28:03
I don't necessarily want the same syntax, just multi-patterns :)
nitrix 2017-01-31 04:28:27
merijn: Do we have patterns being able to fall through on success?
merijn 2017-01-31 04:28:38
nitrix: No
Billifischmaul 2017-01-31 04:29:51
hi, im new to Haskell and heard foldr can handle infinite lists, but when I try to feed foldr an infinite list it will freeze. What did I do wrong? http://lpaste.net/4324348858034290688
nitrix 2017-01-31 04:30:33
isFooOrBar Foo = True; isFooOrBar Bar = True; isFooOrBar _ = False; case () of _ | isFooOrBar -> ...
nitrix 2017-01-31 04:30:42
merijn: "Multi-patterns" :D
lpaste 2017-01-31 04:30:43
merijn pasted "simplify?" at http://lpaste.net/351824
merijn 2017-01-31 04:30:59
I have that, which annoys me to no end...
nitrix 2017-01-31 04:31:21
merijn: What about having the two patterns which simply calls the same body implementation in both cases?
nitrix 2017-01-31 04:31:33
I think that'd read nice too.
merijn 2017-01-31 04:32:04
nitrix: Yeah, usually, and that's mostly what I already have (see paste), but it still bothers me
nitrix 2017-01-31 04:33:20
Ah I see.
nitrix 2017-01-31 04:33:32
merijn: Could it be a sign that your data type needs to be split differently?
merijn 2017-01-31 04:33:56
nitrix: I could split it into a two-level ADT, but that'd make my SQL table annoying to work with
merijn 2017-01-31 04:34:04
nitrix: So if this was just Haskell, yes
nitrix 2017-01-31 04:34:11
data Foo = Board Bool | Video Bool -- Where Bool relates to the property of being an expension or something.
nitrix 2017-01-31 04:34:15
Now you could do:
nitrix 2017-01-31 04:34:29
case ty of Board _ -> ...; Video _ -> ...
ClaudiusMaximus 2017-01-31 04:34:37
Billifischmaul: what does 'distinct' do? if i remove distinct, i get a stack overflow, which i can solve by moving (h :) in front of the ifs instead of within each case
ertes 2017-01-31 04:37:07
Billifischmaul: (==) is your culprit
ertes 2017-01-31 04:37:16
Billifischmaul: use 'null'
ClaudiusMaximus 2017-01-31 04:37:22
Billifischmaul: in fact moving the h: outside the ifs is required to make the folded function productive, and thus the take 20 of the foldr terminate - otherwise it has to traverse the whole list to see whether t is null or not
ertes 2017-01-31 04:37:32
Billifischmaul: ah, no… it should work in this case
ertes 2017-01-31 04:37:55
Billifischmaul: anyway, your fold is strict in the second argument
Billifischmaul 2017-01-31 04:38:06
ClaudiusMaximus 2017-01-31 04:38:37
Billifischmaul: instead of if ... then h:... else h:... why not h : if ... then ... else ...
ertes 2017-01-31 04:39:24
> foldr (\x ys' -> case ys' of [] -> [x]; (y:ys) -> if x == y then y:ys else x:y:ys) [] "abbcddeeeeeef"
lambdabot 2017-01-31 04:39:27
"abcdef"
ertes 2017-01-31 04:39:32
> foldr (\x ys' -> case ys' of [] -> [x]; (y:ys) -> if x == y then y:ys else x:y:ys) [] [0..]
lambdabot 2017-01-31 04:39:35
*Exception: stack overflow
Billifischmaul 2017-01-31 04:41:53
ertes 2017-01-31 04:42:30
> foldr (\x go -> maybe (x : go (Just x)) (\y -> (if x == y then id else (x :)) (go (Just x)))) (const []) "abbcddeeeeeef" Nothing
lambdabot 2017-01-31 04:42:32
"abcdef"
ertes 2017-01-31 04:42:36
> foldr (\x go -> maybe (x : go (Just x)) (\y -> (if x == y then id else (x :)) (go (Just x)))) (const []) [0..] Nothing
lambdabot 2017-01-31 04:42:38
[0,1,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,2...
ertes 2017-01-31 04:42:47
as far as i see this can only be done with a stateful fold
ClaudiusMaximus 2017-01-31 04:43:30
> take 20 (foldr (\h t -> h : case t of [] -> [] ; yys@(y : ys) | h == y -> ys | otherwise -> yys) [] [x `div` 3 | x <- [1..]])
orion 2017-01-31 04:43:30
Are there any batch/job scheduling libraries/programs available specifically for Haskell?
lambdabot 2017-01-31 04:43:32
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
ertes 2017-01-31 04:44:43
ah, of course