Search Haskell Channel Logs

Monday, February 6, 2017

#haskell channel featuring sjpet, geekosaur, dolio, slack1256, Koterpillar, ertes, and 9 others.

AWizzArd 2017-02-06 11:45:56
Tuplanolla: Yes. If / were used though…
geekosaur 2017-02-06 11:47:08
maksim_, it's badly phrased (but that's likely impossible to handle in any sane way) but I suspect some dependency in cabal.config requires file-embed-0.0.10 and that's being shown as if you had that in cabal.config directly
ertes 2017-02-06 11:47:59
what's a good name for an immutable reference? like a read-only IORef (its value can change, but only through external means)
ertes 2017-02-06 11:48:49
not really "immutable", but "read-only"
dolio 2017-02-06 11:50:15
CoYoneda IORef
Tuplanolla 2017-02-06 11:51:22
Just `Ref`?
jle` 2017-02-06 11:51:39
ROIORef
ertes 2017-02-06 11:51:42
dolio: close =)
ertes 2017-02-06 11:52:11
Tuplanolla: yeah, but unfortunately there is already a 'ref' library =)
ertes 2017-02-06 11:52:16
and yes, 'var' is taken, too =)
Tuplanolla 2017-02-06 11:52:22
Then `PureRef`?
jle` 2017-02-06 11:53:10
Source?
codedmart 2017-02-06 11:53:20
I am trying to understand how `pool` works. I am using it now, but what I am wondering is the difference between `withResource` and `takeResource`. My issue is that I have a long waiting blocking process that I run with my db, but the thread seems to die after one thing happens with the db.
sjpet 2017-02-06 11:53:29
Hello. If I have declared 'data Fluff = Foo String Int | Bar String Char', is there a one-liner (i.e. without pattern matching either constructor specifically) way of writing a function 'fluffLength :: Fluff -> Int' returning the length of the string?
jle` 2017-02-06 11:53:34
a read-only IORef could be a Source and a write-only IORef could be a Sink
sjpet 2017-02-06 11:53:53
it would seem _ does not work for data constructors
ertes 2017-02-06 11:54:02
hmm
ertes 2017-02-06 11:54:05
i'm inclined to call it Behaviour
jle` 2017-02-06 11:54:06
sjpet: there isn't quite a way that's built into the language
jle` 2017-02-06 11:54:26
well
jle` 2017-02-06 11:54:35
you could use record fields, but that's probably not ideal here
jle` 2017-02-06 11:54:51
might as well use something like getFluffString :: Fluff -> String
jle` 2017-02-06 11:55:01
and then use that for your fluffLength function
sjpet 2017-02-06 11:55:16
but then I'd have the same problem with getFluffString
jle` 2017-02-06 11:55:20
there are some libraries (like lens) that could use metaprogramming to generate getFluffString for you automatically
jle` 2017-02-06 11:55:25
sjpet: yeah, but at least you isolate the problem
sjpet 2017-02-06 11:55:31
yeah, it's something
jle` 2017-02-06 11:55:45
and you only would have to write it once
sjpet 2017-02-06 11:56:37
but perhaps there is a better way of classifying about a dozen different types of strings then..
Tuplanolla 2017-02-06 11:56:42
You can `declareLenses` and then `length . view str`, sjpet.
jle` 2017-02-06 11:57:02
yeah, if lens is already in your project, you might as well leverage it to auto-generate your accessors there
jle` 2017-02-06 11:57:20
alternatively, you can be evil
jle` 2017-02-06 11:57:31
fluffLength (unsafeCoerce->(Foo s _)) = length s
jle` 2017-02-06 11:57:36
(don't do that)
jle` 2017-02-06 11:57:52
er wait
jle` 2017-02-06 11:57:58
that doesn't work, sorry
Jinixt 2017-02-06 11:58:01
you can't just hand out a chainsaw and then say "don't use it"
Jinixt 2017-02-06 11:58:14
someone's bound to lose a leg
litho 2017-02-06 12:00:13
does anyone know of a good example of an MTL style rest api package on hackage?
sjpet 2017-02-06 12:00:42
I'll have a look at lens. It's not in my project currently but it might be of use later. Thanks.
Tuplanolla 2017-02-06 12:00:58
Consider `microlens` if it's too much, sjpet.
slack1256 2017-02-06 12:02:26
TIL: you don't have to import a module in ghci if you are gonna use just a single function. Just qualiafy completely ie: Data.Foldable.foldmap works otb
Koterpillar 2017-02-06 12:03:12
slack1256: it still has to be loaded, in your case perhaps it was through another module in your project
slack1256 2017-02-06 12:03:46
damn right. the Turtle library did it :-S
litho 2017-02-06 12:16:08
what's the best approach for making a typeclass that associates 'constant' data for each type?
Koterpillar 2017-02-06 12:16:35
litho: like Data.Default?
litho 2017-02-06 12:17:13
sort of
litho 2017-02-06 12:17:20
except that the 'default' value isnt polymorphic
monochrom 2017-02-06 12:17:49
If Data.Default doesn't solve your problem, you will have to explain your problem, because I certainly don't understand it otherwise.
litho 2017-02-06 12:17:49
right now I have a class with a function `class Resource a where prefix :: proxy a -> String`
litho 2017-02-06 12:18:27
this is for the purpose of an api client, end users need to give the client information on how to build the correct paths for their types in the API
monochrom 2017-02-06 12:18:56
I think I see. Better to make your own class.
litho 2017-02-06 12:19:02
I've done that
maksim_ 2017-02-06 12:19:03
geekosaur, why doesn't it tell me exactly which
litho 2017-02-06 12:19:16
however it causes issues when I try to write the actual api functions in a polymorphic manner
litho 2017-02-06 12:19:28
since I can't build proxies out of scratch :P
monochrom 2017-02-06 12:19:48
You can use Data.Proxy (comes with GHC).
litho 2017-02-06 12:20:13
http://lpaste.net/352156
monochrom 2017-02-06 12:20:17
I would for example call your method in a way like "prefix (Proxy :: Proxy Int)"
monochrom 2017-02-06 12:20:55
But even Data.Proxy is not compulsory. You can define your own "data Me a = Me" and now you get to say "prefix (Me :: Me Int)" too. Same difference.
litho 2017-02-06 12:21:05
I posted an example lpaste with my issue
monochrom 2017-02-06 12:21:50
You need ScopedTypeVariables.
litho 2017-02-06 12:21:55
the issue is that I'd like to make polymorphic accessor functions like `getAllResources` which would return an `m a`
litho 2017-02-06 12:22:04
hmm I have it turned on but it didn't seem to do the trick
lpaste 2017-02-06 12:22:35
monochrom annotated "example problem " with "example problem (annotation)" at http://lpaste.net/352156#a352157
monochrom 2017-02-06 12:22:39
Like that.
litho 2017-02-06 12:22:55
ah i actually need to quantify a and m explicitly
monochrom 2017-02-06 12:22:56
You need to add some "forall"s.
litho 2017-02-06 12:23:38
wow thanks, I thought scoped type variables was the answer but never understood how it worked
litho 2017-02-06 12:23:50
didn't realize i needed explicit forall