danza 2017-01-30 06:48:19
anybody can help me building a sum type with a list?
byorgey 2017-01-30 06:48:58
danza: I don't understand what you mean. What are you trying to do?
osa1 2017-01-30 06:48:58
so I need a state to collect values unintentionally read while checking if the Producer is exhausted
danza 2017-01-30 06:48:58
for example `MyType = Int | [Int]` ... not sure about the proper syntax
byorgey 2017-01-30 06:49:08
danza: ah, you need data constructors
byorgey 2017-01-30 06:49:26
data MyType = ConstructorName1 Int | ConstructorName2 [Int] and so on
byorgey 2017-01-30 06:49:36
you can pick your own constructor names of course.
danza 2017-01-30 06:49:44
i see
danza 2017-01-30 06:49:49
thanks byorgey!
byorgey 2017-01-30 06:50:01
danza: the fact that there is a list in it is irrelevant, it's the same no matter what is contained in it
byorgey 2017-01-30 06:50:04
sure!
danza 2017-01-30 06:53:24
but then ... how can i accept either an Int or a [Int] as the argument of a function?
infandum 2017-01-30 06:53:47
danza: f :: MyType
infandum 2017-01-30 06:54:27
then you could pattern match (ConstructorName1 x) or (ConstructorName2 xs)
danza 2017-01-30 06:55:10
sure but, let's say that `f` could have either Int or [Int] as a parameter, without the Constructors ... is this even possible?
cocreature 2017-01-30 06:55:59
danza: no that's not possible
infandum 2017-01-30 06:56:03
without constructors? No idea. I don't think it should
lep-delete 2017-01-30 06:56:09
i think it would be possible but not worth it
infandum 2017-01-30 06:56:13
that would destroy the point of static typing
danza 2017-01-30 06:56:15
i was trying to solve this test http://careers.citrusbyte.com/apply/5DcIgp/Experienced-Frontend-Engineer in Haskell: "Write some code that will flatten ..."
jophish 2017-01-30 06:56:20
s
Cale 2017-01-30 06:57:34
danza: That question doesn't quite make sense in the context of Haskell. All the elements of a Haskell list must have the same type
danza 2017-01-30 06:57:53
you are right
danza 2017-01-30 06:58:15
meh
infandum 2017-01-30 06:58:23
That list looks scary
Cale 2017-01-30 06:58:26
danza: So either there's a weird instance of Num for lists, or that's informal notation for some kind of tree data type.
infandum 2017-01-30 06:58:30
It shouldn't be a list, it should be a tree
infandum 2017-01-30 06:58:48
yeah, what Cale said
danza 2017-01-30 06:58:49
right, it's not Haskell ... one is just free to pick the language they want
danza 2017-01-30 06:59:46
i dove in without noticing the nonsense of doing so ^^;
infandum 2017-01-30 06:59:49
the input would either be a list of list of lists or a tree
infandum 2017-01-30 07:00:11
I vote tree
nitrix 2017-01-30 07:01:22
:t [] :: [forall a. Show a => a]
lambdabot 2017-01-30 07:01:24
error:
lambdabot 2017-01-30 07:01:24
• Illegal polymorphic type: forall a. Show a => a
lambdabot 2017-01-30 07:01:24
GHC doesn't yet support impredicative polymorphism
Cale 2017-01-30 07:01:40
"Write this function on lists which nobody in the real world ever actually wants, but which dynamically typed languages all seem to provide regardless."
nitrix 2017-01-30 07:02:17
@let data Foo = forall a. Show a => mkFoo a
lambdabot 2017-01-30 07:02:18
Parse failed: Illegal data/newtype declaration
infandum 2017-01-30 07:02:29
pretty much. That list is prone to so many errors
nitrix 2017-01-30 07:02:52
Fixed the typo.
infandum 2017-01-30 07:03:09
I would never go more than 2 of the same type deep, otherwise there must be some better representation
nitrix 2017-01-30 07:03:16
:t [] :: [Foo] -- How come I'm allowed to use this datatype, but the other one is impredicative?
lambdabot 2017-01-30 07:03:18
[Foo]
danza 2017-01-30 07:03:48
"prote to so many errors" so are also dynamically typed languages, but a lot of people in the real world are available to pay real money for writing in those, unfortunately :)
danza 2017-01-30 07:05:06
i shouldn't be ranting here. Thanks for guiding me :)
infandum 2017-01-30 07:05:07
danza: Yes and no. They are paid to write *well* written programs (I assume). Just because the language lets you get away with stuff like that doesn't mean it's convention.
Cale 2017-01-30 07:05:31
nitrix: The thing you're not allowed to do is instantiate a type parameter (to anything other than a function type) with a polymorphic type.
Cale 2017-01-30 07:06:12
nitrix: For function types, the ability to do that is provided by the RankNTypes extension.
Cale 2017-01-30 07:06:46
nitrix: Even if you were allowed to have that type, there are not many values of type Show a => a
Cale 2017-01-30 07:07:16
(it's basically just bottom, since Show a gives you no way to create values of type a)
implementation 2017-01-30 07:07:50
and there is absolutely no reason why [forall a. Show a => a] should be preferred over [String]
glguy 2017-01-30 07:19:54
Except that Show provides more operations than show
ph88 2017-01-30 07:36:30
lyxia, are you still around ?
ph88 2017-01-30 07:37:52
the docs say stuff like "In the case for :+:, we produce False or True depending on whether the constructor of the value provided is located on the left or on the right" .. just that i don't want to have my value created by the position of the constructor .. but on the actual value
mpickering 2017-01-30 07:38:35
Hello, how can I pass options to GHC when running stack exec? I want to pass -ddump-simpl but it seems stack just ignores this option
ph88 2017-01-30 07:39:40
mpickering, --ghc-options 'option here'
mpickering 2017-01-30 07:42:58
ok, I tried that now and I look at the actual command run with -v and the options are not passed