Search Haskell Channel Logs

Thursday, February 23, 2017

#haskell channel featuring mekeor, yushyin, liste, lambdabot, barrucadu, qiange, and 10 others.

trkpa 2017-02-23 01:45:53
Wa
kgadek 2017-02-23 01:46:02
#haskell-offtopic ? :) also: there is this Slack that I even like but is proprietary and it consumes history and A LOT of ram. There's also mattermost, FLOSS competitor.
kgadek 2017-02-23 01:46:44
And if you want LaTeX rendering then probably MathJaX is the way to go. So browser-based client
trkpa 2017-02-23 01:46:50
What is the best practice in haskell when it comes to program error state? I remember seeing somewhere on reddit that people were "annoyed" by coding passing exceptions
barrucadu 2017-02-23 01:47:30
And gitter, and discord... there's one thing IRC has over all these newer alternatives: an established community.
Tuplanolla 2017-02-23 01:47:33
I'm unhappy as long as these systems neglect equations and diagrams or treat them as "possibly binary data". Everything remains broken, just like the web.
yushyin 2017-02-23 01:47:52
barrucadu: and xmpp with the MAM and MIX xep, and matrix.org
yushyin 2017-02-23 01:47:53
:D
liste 2017-02-23 01:50:20
trkpa: depends on what you mean by error state, but usually Either or ErrorT -- http://www.randomhacks.net/2007/03/10/haskell-8-ways-to-report-errors/
trkpa 2017-02-23 01:51:04
@liste Thank you! That link is very helpful
lambdabot 2017-02-23 01:51:04
No module "Thank you! That link is very helpful " loaded
stevenxl 2017-02-23 01:58:36
Hello. I'd like to create a function that takes an Integer and subtracts 3 from that Integer. I'm trying to use (- 3). But that leads to a type mismatch. If I convert the - operator to a function (-), there's no way for me to apply the "second" argument first. Unless I use reverse.
stevenxl 2017-02-23 01:58:45
Am I missing something obvious?
lyxia 2017-02-23 01:58:55
subtract 3
lyxia 2017-02-23 01:59:03
\x -> x - 3
lyxia 2017-02-23 01:59:13
(- 3) is parsed as the integer -3
hpc 2017-02-23 01:59:18
the "-" operator is a bit of a special case in the parser
mekeor 2017-02-23 01:59:24
or: flip (-) 3
stevenxl 2017-02-23 01:59:32
lyxia: thank you very much!
stevenxl 2017-02-23 02:00:18
OK. In general, when I'm creating sections - which I understand to be partially applied infix operators - it is possible to apply the first or the second argument, yes?
hpc 2017-02-23 02:01:55
yeah, in general what you tried will work
stevenxl 2017-02-23 02:03:47
:-)
stevenxl 2017-02-23 02:03:51
thank you
marekw2143 2017-02-23 02:05:35
https://bitbucket.org/chessRepo/c7/src/91d975663eeb8116dbfae437fe4ff297a586695b/main.hs?at=maybeList&fileviewer=file-view-default#main.hs-64
marekw2143 2017-02-23 02:05:53
I've got error: Couldn't match expected type 'ReaderT
marekw2143 2017-02-23 02:05:54
GameState Data.Functor.Identity.Identity t0'
marekw2143 2017-02-23 02:05:54
with actual type 'GameState -> Team'
marekw2143 2017-02-23 02:05:54
Probable cause: 'whoMoves' is applied to too few arguments
marekw2143 2017-02-23 02:06:27
as calculateNextMoves is a Reader type, then I guess "whoMoves" will get "GameState" instance as argument
qiange 2017-02-23 02:07:29
test!
robertkennedy 2017-02-23 02:15:03
:t liftA3
lambdabot 2017-02-23 02:15:07
Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
robertkennedy 2017-02-23 02:15:52
I often use an idiom like
robertkennedy 2017-02-23 02:16:30
(,) <$> f <*> g
robertkennedy 2017-02-23 02:16:41
I also often use
mniip 2017-02-23 02:16:50
"liftA2 (,) f g" is the same yes
hpc 2017-02-23 02:17:03
liftA3 f x y z = f <$> x <*> y <*> z
robertkennedy 2017-02-23 02:17:49
joinTuple ma mb = (,) <$> ma <*> mb
liste 2017-02-23 02:18:12
marekw2143: try whoMoves <$> ask
liste 2017-02-23 02:18:20
instead of whoMoves
mniip 2017-02-23 02:18:25
there actually is an alternative definition of applicative
mniip 2017-02-23 02:18:32
where joinTuple is a fundamental operation
robertkennedy 2017-02-23 02:19:05
How could I unify these for when `f :: a -> Maybe b`
robertkennedy 2017-02-23 02:19:13
Oh that would work too
liste 2017-02-23 02:19:39
marekw2143: "player <- whoMoves <$> ask" or "player <- fmap whoMoves ask"
marekw2143 2017-02-23 02:20:10
liste, thanks
marekw2143 2017-02-23 02:20:20
I've just wrapped "whoMoves" into reader monad
marekw2143 2017-02-23 02:22:37
liste, how can I know how fmap works for Reader?
liste 2017-02-23 02:23:50
marekw2143: Reader is instance of Monad, Functor is a superclass of Monad
liste 2017-02-23 02:24:15
marekw2143: and for "how", either reading the source or reasoning with the laws
robertkennedy 2017-02-23 02:25:03
But it does seem you should be able to find a nice way to build `uncurry joinTuple . ((,) <$> f <*> g)`
halogenandtoast 2017-02-23 02:29:50
If I have a function that returns a record (i.e. initialRecord) and I want 9 different records in an array how can I do this? I tried `replicate 9 initialRecord` but all 9 elements in the resulting List share memory.
halogenandtoast 2017-02-23 02:30:00
s/array/List/
liste 2017-02-23 02:30:35
halogenandtoast: why does it matter?
liste 2017-02-23 02:30:57
you can't mutate them anyway
halogenandtoast 2017-02-23 02:31:21
You are right, I'm doing something wrong somewhere else
halogenandtoast 2017-02-23 02:31:27
and my OOP self cried wolf
halogenandtoast 2017-02-23 02:32:15
Yup I see my problem, I'm trying to replace a single record in an array and I mapped using equality
halogenandtoast 2017-02-23 02:32:23
and of course they're all equal
halogenandtoast 2017-02-23 02:32:34
`let flags = map (\x -> if (x == f) then f' else x) (gameFlags g) `
halogenandtoast 2017-02-23 02:33:24
so I either have to use the index (which I'm not thrilled about since that feels like an unsafe operation) or I can gives the flags some attribute to make them unique
halogenandtoast 2017-02-23 02:33:58
or lenses..., are there any other options, or is one of those options typically the "best"
Tuplanolla 2017-02-23 02:38:35
Why do you need "copies" of the same record?
halogenandtoast 2017-02-23 02:42:14
I want different records, they all start with the same state
halogenandtoast 2017-02-23 02:42:52
I'm emulating a boardgame, there are nine flags, which can contain cards played by one of two players on respective sides and potentially one player who owns the flag.
halogenandtoast 2017-02-23 02:43:30
so I'm trying to implement `updateGame` which takes the game, which player, which card they'll play, and which flag they'll play it to
halogenandtoast 2017-02-23 02:45:07
I assume I've architected my solution wrong and I'm just too daft to understand how to architect it better.