Search Haskell Channel Logs

Tuesday, March 7, 2017

#haskell channel featuring lambdabot, ertes, cris_, ski, Mike_G, merijn, and 7 others.

ertes 2017-03-07 03:03:52
@let pattern J x = 0 :+ x
lambdabot 2017-03-07 03:03:54
.L.hs:167:9: error: Not in scope: data constructor 'J'
bennofs1 2017-03-07 03:04:04
:t 2 + (0 :+ 1)
lambdabot 2017-03-07 03:04:07
RealFloat a => Complex a
bennofs1 2017-03-07 03:04:16
:t 2 + (0 :+ 3.0)
lambdabot 2017-03-07 03:04:18
RealFloat a => Complex a
c_wraith 2017-03-07 03:05:01
Mike_G: you could trivially write a data type that worked that way. It just wouldn't be Data.Complex.Complex
ertes 2017-03-07 03:05:03
or even just a regular function 'i'
cris_ 2017-03-07 03:05:27
hi ertes , i have added a .gitignore file to my repo folder , however, after i type $ git commit -am "commit 6" , and also push it again to github , the "dist" folder is still there
c_wraith 2017-03-07 03:05:47
cris_: wrong channel?
byorgey 2017-03-07 03:42:21
Rodenbach: how would you want to show it?
Rodenbach 2017-03-07 03:43:02
byorgey: as the String ""
tdammers 2017-03-07 03:43:11
the problem is that your show implementation cannot really look inside the function, because the only things you can do with function values is apply them, and pass them around
byorgey 2017-03-07 03:43:13
Rodenbach: no, that is not possible.
ski 2017-03-07 03:43:23
`myAdd' is indistinguishable from `(+)' itself
tdammers 2017-03-07 03:43:35
neither will give you the function name, nor the implementation details
ski 2017-03-07 03:43:45
function values don't carry around names
ski 2017-03-07 03:44:18
(just like a list like `[2,3,5,7]' doesn't know what names it may be known under, in different parts of the program)
Rodenbach 2017-03-07 03:44:19
I know about ghci's :m + Text.Show.Functions
byorgey 2017-03-07 03:44:37
Rodenbach: perhaps you might be interested in doing something like data MyFunctions = MyAdd | MySub | ... and then have a list of [MyAdd, MyAdd] which you can Show just fine. Then define an interpreter MyFunctions -> (Int -> Int -> Int) or something like that
Rodenbach 2017-03-07 03:44:38
That's not what I'm looking for. Okay, so I'll work around it.
Rodenbach 2017-03-07 03:45:01
byorgey: possibly I will do this.
tdammers 2017-03-07 03:45:02
Rodenbach: why do you need this Show instance? What is the problem you are trying to solve?
Rodenbach 2017-03-07 03:46:16
tdammers: I am evolving Programs in a Genetic Programming system that I'm implementing.
napping 2017-03-07 03:46:56
ski: are you sure there's nothing interesting in the info table?
max3 2017-03-07 03:47:12
why doesn't everything derive Show by default?
Rodenbach 2017-03-07 03:48:16
tdammers: and it would be nice to see which functions are part of the genome.
napping 2017-03-07 03:48:16
Rodenbach: then you will need your own type of syntax trees to actually do the mutuataions
byorgey 2017-03-07 03:48:16
Rodenbach: yes, in that case, I think you almost certainly want to define a data type representing the abstract syntax of your programs, rather than representing them directly as functions
napping 2017-03-07 03:48:16
and those can be Show no problem
ski 2017-03-07 03:48:16
max3 : not everything can be made an instance of `Show' (in a sensible fashion)
Rodenbach 2017-03-07 03:48:16
Oki.
max3 2017-03-07 03:48:16
ski, at worst you could have a memory address
merijn 2017-03-07 03:48:16
max3: You assume functions HAVE a memory address
byorgey 2017-03-07 03:48:16
max3: but the spirit of Show is that it should produce valid Haskell expressions, which could be pasted into ghci
ski 2017-03-07 03:48:16
napping : are info tables in the report ?
merijn 2017-03-07 03:48:16
byorgey: Even if you throw out that assumption it's hard to do sensibly
Mike_G 2017-03-07 03:48:16
Is it possible to make GHC interpret `3.2i' as a value of some new type without Template Haskell?
byorgey 2017-03-07 03:48:16
merijn: oh, I agree
merijn 2017-03-07 03:48:16
Mike_G: If you wrap it in a quasi quoter, yes
napping 2017-03-07 03:48:16
ski: they may be in your implementation