Search Haskell Channel Logs

Monday, February 27, 2017

#haskell channel featuring lispy, _Adluc_, typedeph, monochrom, jle`, ludat,

adelbertc 2017-02-27 12:52:50
anyone here used `hint` before? Trying to do `runInterpreter $ interpret "5" (as :: Int)` but am getting `Left(WontCompile [GhcError {errMsg = "
c_wraith 2017-02-27 12:53:31
adelbertc, you need to set imports. yes, even for the Prelude
adelbertc 2017-02-27 12:53:50
c_wraith: ah, trying
ludat 2017-02-27 12:56:05
hi everyone, is there some standard lib for writing CLI apps?
c_wraith 2017-02-27 12:56:46
adelbertc, the reason Int is present in the string being interpreted is the way hint handles making sure the interpreter is well-typed. it more or less rewrites the String to "(5)::Int", and then Int isn't in scope because the Prelude isn't automatically in scope.
adelbertc 2017-02-27 12:57:02
ludat: like a cmd line parser? i like optparse-applicative
ludat 2017-02-27 12:57:52
adelbertc, no, I mean like interactive cli apps, like bash or pgcli
adelbertc 2017-02-27 12:57:57
c_wraith: hm should it just be `loadModules ["Prelude"]` ?
_Adluc_ 2017-02-27 12:59:08
ludat: try repline
_Adluc_ 2017-02-27 12:59:18
ludat: https://hackage.haskell.org/package/repline
c_wraith 2017-02-27 12:59:47
adelbertc, no, loadModules is for adding files to interpret into scope.
c_wraith 2017-02-27 13:00:01
adelbertc, you want setImports
adelbertc 2017-02-27 13:00:06
oh right
adelbertc 2017-02-27 13:01:07
c_wraith: sweet that worked
adelbertc 2017-02-27 13:01:08
thanks!
c_wraith 2017-02-27 13:01:40
you're welcome. :)
ludat 2017-02-27 13:01:53
_Adluc_, that should work, thanks!
typedeph 2017-02-27 13:05:42
how does one initialize an immutable array? the array function example has a typo and its correct version fails for me with an ambiguity error
typedeph 2017-02-27 13:06:04
by immutable array I mean Data.Array.IArray
c_wraith 2017-02-27 13:07:23
fix the ambiguity. specify the type variables it's telling you are ambiguous.
ludat 2017-02-27 13:07:36
IArray isn't an interface?
c_wraith 2017-02-27 13:08:19
this isn't C#
c_wraith 2017-02-27 13:08:49
though it actually is a class. it just stands for Immutable array
c_wraith 2017-02-27 13:09:09
in contrast to MArray
typedeph 2017-02-27 13:09:34
and how exactly would I do that for the most trivial example, the typeclass reads cycliclly: :: (Ix i, IArray a e) => (i, i) -> [(i, e)] -> a i e
lispy 2017-02-27 13:09:39
and class here means typeclass not an OOP class
typedeph 2017-02-27 13:09:48
e depends on an IArray but I want to construct an IArray
c_wraith 2017-02-27 13:10:48
typedeph, IArray isn't a type. you'll need to pick which type you actually want.
kadoban 2017-02-27 13:11:48
typedeph: You pick either Array Something SomethingElse, like Array Int Int would be common. Or UArray Int Int
jle` 2017-02-27 13:22:28
Typedeph_: do you know about typeclasses?
monochrom 2017-02-27 13:27:27
The IArray class is pretty much locked (you can't implement your own instance). You can only pick existing instances, and the choice is limited.
monochrom 2017-02-27 13:28:19
This class is invented mainly to give uniform function names over Array and UArray. That's all.
monochrom 2017-02-27 13:29:20
If you don't already know "class", it's just for giving uniform function names such as "+" that works for Int, Double, and Word.