bitonic 2017-02-22 05:45:11
When I do `cabal repl`, is there a way to expose all packages in the package db for usage?
ski 2017-02-22 05:45:13
(i recall reading something similar to "figuring out which parts of the code were used to compute a particular component of the result" in a paper for Mercury. was it "Vimer", perhaps ?)
jstolarek 2017-02-22 05:45:13
ski: yes, this is about debugiing a compiled program rather than figuring out why a program does not compile
ski 2017-02-22 05:46:26
"Divide-and-query and subterm dependency tracking in the Mercury declarative debugger" by Ian MacLarty,Zoltan Somogyi,Mark Brown in 2005-09 at
ski 2017-02-22 05:46:30
i think
jstolarek 2017-02-22 05:48:09
thanks
jstolarek 2017-02-22 05:48:16
I'll take a look - might be related
bitonic 2017-02-22 05:49:33
Or in other words, is there a flag that undoes `-hide-all-packages`?
mbrock 2017-02-22 06:04:37
it's both fun and sad to run into seeming limitations of the type system
mbrock 2017-02-22 06:05:32
I have functions like ``frob :: (HasFoo s foo, HasBar foo Bar) => ...'' and these Has- constraints are quite repetitive, so I want to factor them out using the constraint kind
mbrock 2017-02-22 06:06:25
but when I try, I run into needing to do something like ``type HasFooBar s = forall foo. (HasFoo s foo, HasBar foo Bar)'' which fails explicitly because "Illegal polymorphic type; a constraint much be a monotype"
Creepster 2017-02-22 06:08:35
Hi all.
Creepster 2017-02-22 06:08:46
Lenses...
mbrock 2017-02-22 06:09:04
actually it might just make sense to pass all the "intermediate" type variables into the type alias anyway, it's just a bit of boilerplate I'd like to avoid
Creepster 2017-02-22 06:09:07
Is there some combinator for filtering based on a predicate?
Creepster 2017-02-22 06:09:41
That is, for all monsters, decrease the health by 20, BUT ONLY IF THEIR RACE IS "OGRE"?
ski 2017-02-22 06:11:19
mbrock : hm, and you actually wanted higher-rank constraints here ?
ski 2017-02-22 06:11:41
mbrock : `frob :: (HasFoo s foo, HasBar foo Bar) => ...' suggests a non-higher-rank constraint ..
ski 2017-02-22 06:12:36
does `foo' (or `s') occur in `...' ?
Creepster 2017-02-22 06:12:36
I guess I'm looking for a traversal with a predicate... Hmm...
Creepster 2017-02-22 06:13:43
filtered! Good!
mbrock 2017-02-22 06:13:53
ski: in reality I have the constraint MonadState s m and ... is (say) "m ()"
ski 2017-02-22 06:14:10
with no other mention of `s' ?
ski 2017-02-22 06:14:31
(sounds strange)
ski 2017-02-22 06:15:01
.. i'm thinking that perhaps you want `exists' instead of `forall', above
ski 2017-02-22 06:15:41
otherwise, it should be possible to parameterize, as `type HasFooBar s foo = (HasFoo s foo, HasBar foo Bar)', and then use `HasFooBar s foo => ...'
ski 2017-02-22 06:16:09
("otherwise", as in, since `exists' in constraints aren't supported, except possibly in LHC ?)
mbrock 2017-02-22 06:16:23
ah, yes, that's what I think I'll have to do
ski 2017-02-22 06:16:46
ok
ski 2017-02-22 06:17:07
so, iiuc, my main point is then that you were really looking for `exists' here, not `forall'
platz 2017-02-22 06:17:22
is there a way to specify byte literals?
mbrock 2017-02-22 06:17:24
that's good to know, thanks
ski 2017-02-22 06:17:41
.. not that it makes a difference practically here -- but it's good to clear out such conceptual misconceptions
platz 2017-02-22 06:18:25
i.e. I have a sequence of bytes in hex e.g. "2E0FFA"
mbrock 2017-02-22 06:18:25
indeed, I just tossed in for all because I needed some way of introducing a variable, without thinking much
platz 2017-02-22 06:18:34
but i don't want to read this in from a file
ski 2017-02-22 06:19:44
mbrock : `forall' in constraints would be higher-rank constraints. e.g. as in `instance (forall a. Show a => Show (f a)) => Show (Fix f)'
ski 2017-02-22 06:20:15
(or in a type signature, as `blah :: (forall a. Show a => Show (f a)) => ..f..')
mbrock 2017-02-22 06:21:02
ah, right. But that's only allowed with a newtype, or something?
ski 2017-02-22 06:22:42
you could do `class Show1 f where showsPrec1 :: forall a. Show a => Int -> f a -> ShowS', with `Show1 f' replacing `forall a. Show a => Show (f a)'. but then you need to either manually instance `Show1', or do a generic instance (which perhaps isn't always wanted ?)
ski 2017-02-22 06:23:18
you could also pack dicts up with GADTs, replacing `forall a. Show a => Show (f a)' with an argument
ski 2017-02-22 06:23:39
(doesn't work for the `instance' case, but works for the function case)
ski 2017-02-22 06:23:57
possibly edwardk's `constraints' has something for this ..
mbrock 2017-02-22 06:25:22
I basically need to read something to understand what the whole idea of higher rank anything is all about
mbrock 2017-02-22 06:25:34
also I'm in a taxi on my phone thinking hard ;)
ski 2017-02-22 06:26:15
understanding higher-rank first requires understanding polymorphism (properly)
ski 2017-02-22 06:26:53
(and understanding existentials (if not their ramifications) is also related, so one might as well try to grasp them at the same time)
ski 2017-02-22 06:27:50
mbrock : i'd offer to try to explain the important basic points here and now .. but perhaps it'd be hard to follow from the backseat (i hope at least not the driver's seat ;) of a cab ?
mbrock 2017-02-22 06:32:13
ski: I've arrived safely and acquired a bottle of chocolate cocoa porter so conditions are perfect
ystael 2017-02-22 06:32:13
In Emacs haskell-mode, is there a way to tell C-c C-l (`haskell-process-load-file`) that I want it to use my `test-suite` stack target (with test dependencies) instead of `library`?
ski 2017-02-22 06:33:55
mbrock : well, first thing to realize is that it's not the presence of a type variable in the type of something, that makes it polymorphic. it's the presence of `forall'
mbrock 2017-02-22 06:35:27
and `forall` is inserted implicitly so that people aren't forced to understand this stuff, right
ski 2017-02-22 06:36:02
(oh, and types like `[a] -> [a]' or `forall a. a -> a' are not "polymorphic types". a value having the latter type would be polymorphic, the type is not polymorphic. one could call the type a "universal" type, or a `forall'-type. there is a concept of "polymorphic type", but it's doesn't crop up that often. i'm mentioning this because people often confuse the terminology here)
ski 2017-02-22 06:36:10
mbrock : that's the short story, yes
ski 2017-02-22 06:36:23
in the long run, you need to understand `forall' anyway :)
ski 2017-02-22 06:36:40
take e.g.
ski 2017-02-22 06:36:46
length :: [a] -> Int
mbrock 2017-02-22 06:37:16
I have vague memories from school about how typed lambda calculus actually has forall as a capital lambda or something, i.e. you make "functions from type to type"
ski 2017-02-22 06:37:33
in *most* situations, when there's a free type variable, here `a', in a type *signature*, that means it's implicitly bound, by a `forall a.' at the front of the type, just after the `::' of the signature
threshold 2017-02-22 06:37:39
07:39 < lpaste_> threshold pasted "Scotty app: replace liftIO with lift, replace pure uid with uid createUser returns Maybe [T.Text]"
threshold 2017-02-22 06:37:56
07:39 < lpaste_> threshold pasted "Scotty app: replace liftIO with lift, replace pure uid with uid createUser returns Maybe [T.Text]"
ski 2017-02-22 06:38:09
the exception to "most" is in case the type variable is *already* in scope
threshold 2017-02-22 06:38:11
07:39 < lpaste_> threshold pasted "Scotty app: replace liftIO with lift, replace pure uid with uid createUser returns Maybe [T.Text]" at http://lpaste.net/352867
threshold 2017-02-22 06:38:16
Expected type: Web.Scotty.Internal.Types.ActionT L.Text IO [T.Text]
threshold 2017-02-22 06:38:20
Actual type: Web.Scotty.Internal.Types.ActionT L.Text Maybe [T.Text]
threshold 2017-02-22 06:38:55
I am not trying to align the types. I did that yesterday with the help of Koterpillar
threshold 2017-02-22 06:39:23
I am trying to refactor and make createUser have a less gruesome type :)
threshold 2017-02-22 06:39:34
I don't understand why the line "result <- lift $ createUser email" has an expected type of eb.Scotty.Internal.Types.ActionT L.Text IO [T.Text]
threshold 2017-02-22 06:39:51
Ultimately, I think it would be nice to return a User as suggested by Koterpillar, but this is a start
ski 2017-02-22 06:40:07
mbrock : well, the capital lamda thing is actually an explicit notation in (value) *expressions* for constructing a polymorphic value. it can be described as a function mapping an input type to an output value. e.g. `id : forall a. a -> a; id = /\ a. \(x : a). x'
mbrock 2017-02-22 06:40:46
ski: ah, ok, good clarification
ski 2017-02-22 06:41:36
in Haskell, the capital lambda there (and the corresponding application of a polymorphic value to a *type*) is implicit (but there's now an extension where you can write `id @Bool False' ..)
ski 2017-02-22 06:41:57
mbrock : anyway, here's an example of the exception
ski 2017-02-22 06:42:04
@src Functor
lambdabot 2017-02-22 06:42:04
class Functor f where
lambdabot 2017-02-22 06:42:05
fmap :: (a -> b) -> f a -> f b
ski 2017-02-22 06:42:24
`a' and `b' are not already scope before that type signature, but `f' *is* !
ski 2017-02-22 06:42:36
hence that type signature (inside the class) really means
ski 2017-02-22 06:42:46
fmap :: forall a b. (a -> b) -> f a -> f b
ski 2017-02-22 06:43:08
considering `fmap' as any freestanding operation, the signature would be
ski 2017-02-22 06:43:26
fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b
ski 2017-02-22 06:43:31
which is just another way to spell
ski 2017-02-22 06:43:38
fmap :: forall f a b. Functor f => (a -> b) -> f a -> f b
ski 2017-02-22 06:43:45
mbrock : does that make sense ?
mbrock 2017-02-22 06:44:00
yeah, that makes sense
ski 2017-02-22 06:44:11
also consider something like
ski 2017-02-22 06:44:20
@src Maybe
lambdabot 2017-02-22 06:44:20
data Maybe a = Nothing | Just a
ski 2017-02-22 06:44:38
here, one can *think* of the `a' here being bound by an implicit `forall' as in
ski 2017-02-22 06:44:56
data forall a. (Maybe a = Nothing | Just a)