Search Haskell Channel Logs

Saturday, February 4, 2017

#haskell channel featuring Profpatsch, Squarism, ph88, rockyw, hpc, AWizzArd, and 5 others.

erisco 2017-02-04 10:05:10
jle`, I am confused on Ord here... there is POrd and SOrd
erisco 2017-02-04 10:06:46
I would expect there to be something to compare two SNats and get the proof that they are LT, GT, or EQ
erisco 2017-02-04 10:07:20
I am not sure how that would look though, i.e. the handling the various cases, and can't figure out if this can be done between POrd and SOrd
erisco 2017-02-04 10:10:05
I guess it would be something like SNat n -> SNat m -> Decision (Compare n m :~: LT) and similar for the other cases
erisco 2017-02-04 10:11:00
IsTrue and :~: can't offer anything for branching
taktoa 2017-02-04 10:12:05
I need to convert a ByteString Builder to an Aeson Encoding in code that must work with aeson-0.13, which lacks an unsafeToEncoding method. Encoding is a newtype, so I tried Data.Coerce.coerce, but it complains that the data constructor for Data.ByteString.Builder.Builder is not in scope. Obviously I could just use unsafeCoerce, but is there a better way I can convince GHC these have the runtime representation?
hpc 2017-02-04 10:14:19
there is no aeson-0.13 afaict
hpc 2017-02-04 10:14:39
it goes from 0.11.3.0 to 1.0.0.0
taktoa 2017-02-04 10:16:05
yes I meant 0.11
erisco 2017-02-04 10:16:23
there is of course sCompare but this doesn't tell me anything about the nats I am comparing =\
erisco 2017-02-04 10:17:55
another design could be SNat n -> SNat m -> (IsTrue (Compare n m :~: LT) -> r) -> (IsTrue (Compare n m :~: EQ) -> r)
erisco 2017-02-04 10:18:01
-> (IsTrue (Compare n m :~: GT) -> r) -> r
taktoa 2017-02-04 10:18:16
btw is it possible to tell GHC "hey, focus your optimization efforts on this function, because I know it's hot"
taktoa 2017-02-04 10:18:33
I know there's {-# INLINE ... #-} but other than that
erisco 2017-02-04 10:19:25
though I am not sure how to actually implement that
rockyw 2017-02-04 10:20:13
hello
Squarism 2017-02-04 10:23:32
i manage to use "ix" to look up elements in my String indexed map using myMap^.ix "anIndex"
erisco 2017-02-04 10:23:44
oh maybe I am dead wrong about sCompare
Squarism 2017-02-04 10:24:38
...but it doesnt work for a map with indices of my own type. It actually complains the value (not keys) have no Monoid instance?
erisco 2017-02-04 10:26:24
of course... sCompare gives me Sing (Compare n m)... at least I think... the haddock is screwed up
erisco 2017-02-04 10:26:53
then when I pattern match on SLT, SEQ, or SGT this must give me that Compare n m ~ LT and so on respectively
erisco 2017-02-04 10:27:20
I still have a tough time intuiting this
ph88 2017-02-04 10:28:21
Squarism, ix ? where did you get that ?
geekosaur 2017-02-04 10:28:39
lens
Squarism 2017-02-04 10:28:44
ph88, lens library
ph88 2017-02-04 10:28:57
oh ok, can't help you then :D
Gurkenglas 2017-02-04 10:31:30
Squarism, is the value-type in the string indexed map a monoid?
Gurkenglas 2017-02-04 10:31:54
ix is a traversal, viewing a traversal collects all the results using the result type's monoid instance
Squarism 2017-02-04 10:31:56
Gurkenglas, yeps.. thats a list of int
Squarism 2017-02-04 10:32:17
oh ok
Gurkenglas 2017-02-04 10:32:45
If "anIndex" isn't in the map, you get back []. If you want Nothing in that case, use ^?. If you want to crash in that case, use ^?!
Profpatsch 2017-02-04 10:36:26
Is there something like a data structure explorer?
Profpatsch 2017-02-04 10:36:48
It's kind of hard exploring deeply nested structures with ghci
Profpatsch 2017-02-04 10:37:14
You have to import all the modules, you have to skip through the module docs and find out about the types &c.
Profpatsch 2017-02-04 10:37:31
I'm thinking of something that dasplays
Profpatsch 2017-02-04 10:37:48
displays the structure folded and I can expand sections I want to see.
Profpatsch 2017-02-04 10:38:18
Maybe with ihaskell?
Squarism 2017-02-04 10:39:36
Gurkenglas, thanks That workd
Squarism 2017-02-04 10:39:50
readability ftw : defender = forces^?!ix (faction_other attackFact)
taktoa 2017-02-04 10:40:06
oh, apparently aeson-0.11 does export unsafeToEncoding, it's just in Data.Aeson.Types instead of Data.Aeson.Encoding.Internal
AWizzArd 2017-02-04 10:41:17
In one forum comment I saw this: (n:) – is this some kind of allowed list destructuring?
AWizzArd 2017-02-04 10:41:36
More context: allWins (n:ns) = concatMap (map (n:) . allWins) $ take n $ tails ns
kubbe 2017-02-04 10:41:47
Hi! i am a beginner in the world of Haskell, so I have a question about the ' (single quote). Lets say that I have a function myFunc.. What does it mean when I write myFunc'? Is there a general rule regarding that?
erisco 2017-02-04 10:43:27
it is just another character you can use in your identifers
kubbe 2017-02-04 10:44:25
Oh, alright. I have tried to find something more about that since that seems to be very common in examples of sort. Read something about it usually is an accumulator(?), but im not sure. Thats why I asked! Thanks though
erisco 2017-02-04 10:44:33
so you might use it to mean "after some transformation" or inverse or strict or something like that