
I would simply like to use Data.String.Conversions, specifically the cs function while I'm in my global ghci REPL. Here's the code I'm working on (from here https://zacwood.me/posts/2020-12-29-dates-ihp/) parseDay' :: String -> Maybe Day parseDay' = parseTimeM True defaultTimeLocale "%Y-%m-%d" then mydate = getCurrentTime (Data.Time imported just fine.) parseDay' $ takeWhile ('T' /=) (cs mydate) My problem is I can import and expose Data.Time, but Data.String.Conversions will not import to my global REPL. Any tips on doing this project-based would be enlightening too. ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com

On Tue, Jun 29, 2021 at 05:39:42PM -0500, Galaxy Being wrote:
My problem is I can import and expose Data.Time, but Data.String.Conversions will not import to my global REPL. Any tips on doing this project-based would be enlightening too.
One thing that works is: $ cabal -z install --lib string-conversions Resolving dependencies... ... In order, the following will be built (use -v for more details): - utf8-string-1.0.2 (lib) (requires build) - string-conversions-0.4.0.1 (lib) (requires download & build) Completed utf8-string-1.0.2 (lib) ... Completed string-conversions-0.4.0.1 (lib) $ cabal repl -z λ> :set -package string-conversions package flags have changed, resetting and loading new packages... λ> import Data.String.Conversions as CS λ> :t cs cs :: ConvertibleStrings a b => a -> b λ> There are surely other ways, that you might prefer, but this should get you started. -- Viktor.

Sorry, but this didn't work for me. First, $ cabal -z install --lib string-conversions cabal: unrecognized 'install' option `-z' however, without -z it does run and performs an install as you indicate . . . but then the rest doesn't work, i.e., $ cabal repl -z
:set -package string-conversions <no location info>: error: Could not load module ‘Data.String.Conversions’ It is a member of the hidden package ‘string-conversions-0.4.0.1’. Perhaps you need to add ‘string-conversions’ to the build-depends in your .cabal file.
However, this did work
$ stack install string-conversions
tf8-string > using precompiled package
string-conversions> configure
string-conversions> Configuring string-conversions-0.4.0.1...
string-conversions> build
string-conversions> Preprocessing library for string-conversions-0.4.0.1..
string-conversions> Building library for string-conversions-0.4.0.1..
string-conversions> [1 of 2] Compiling Data.String.Conversions
...
then
$ stack ghci --package string-conversions
...
Prelude> import Data.String.Conversions as CS
Prelude CS> :t cs
cs :: ConvertibleStrings a b => a -> b
*But*, now I am able to follow your cabal way and it does work.
So this is very confusing for a beginner. But happy ending this time. Any
lessons I can learn from this? For example, why was this so difficult?
On Tue, Jun 29, 2021 at 6:44 PM Viktor Dukhovni
On Tue, Jun 29, 2021 at 05:39:42PM -0500, Galaxy Being wrote:
My problem is I can import and expose Data.Time, but Data.String.Conversions will not import to my global REPL. Any tips on doing this project-based would be enlightening too.
One thing that works is:
$ cabal -z install --lib string-conversions Resolving dependencies... ... In order, the following will be built (use -v for more details): - utf8-string-1.0.2 (lib) (requires build) - string-conversions-0.4.0.1 (lib) (requires download & build) Completed utf8-string-1.0.2 (lib) ... Completed string-conversions-0.4.0.1 (lib)
$ cabal repl -z λ> :set -package string-conversions package flags have changed, resetting and loading new packages... λ> import Data.String.Conversions as CS λ> :t cs cs :: ConvertibleStrings a b => a -> b λ>
There are surely other ways, that you might prefer, but this should get you started.
-- Viktor. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com

On Tue, Jun 29, 2021 at 10:18:47PM -0500, Galaxy Being wrote:
Sorry, but this didn't work for me. First,
$ cabal -z install --lib string-conversions cabal: unrecognized 'install' option `-z'
You must have a materially older version of cabal-install than I do. The "-z" option makes "cabal" ignore any local ".cabal" or "cabal.project" files, and operate in the "global" project.
From "cabal install --help":
... -z --ignore-project Ignore local project configuration ... If I previously wrote "cabal -z install ...", the more strictly correct syntax would probably be "cabal install -z ...", perhaps your version of cabal supports the latter (but quite possibly neither).
$ cabal repl -z
:set -package string-conversions <no location info>: error: Could not load module ‘Data.String.Conversions’ It is a member of the hidden package ‘string-conversions-0.4.0.1’. Perhaps you need to add ‘string-conversions’ to the build-depends in your .cabal file.
Something is missing from the above. I see no attempt to load the module, and yet an error about failure to load it. If "cabal repl" did accept the "-z" option,
$ stack install string-conversions
then
$ stack ghci --package string-conversions
[...]
*But*, now I am able to follow your cabal way and it does work.
So this is very confusing for a beginner. But happy ending this time. Any lessons I can learn from this? For example, why was this so difficult?
It is tricky because cabal operates in a sanboxed mode by default, and because GHC and GHCi don't by default have any knowledge of cabal's package store. The Haskell tool chain is somewhat fragmented, but IIRC there are plans afoot to reduce some of the friction. I use Cabal 3.4, and it does what I need. Others use stack which meets their needs. GHC is agnostic, and ghci mostly knows just about the packages bundled with GHC, except when cabal or stack create GHC "environment" files that specify the package-db locations which GHC is then able to use. Someone else who understands the space better may be able to give a more detailed answer, and perhaps share any plans to improve toolchain integration. -- Viktor.

There's this devilish thing where an initial install of cabal goes to
/usr/bin/cabal, but then a subsequent update
$ cabal install cabal-install
puts things in my ~/.cabal/bin/
Once I adjusted my PATH to go to ~/.cabal/bin/cabal first, then
cabal -z install --lib string-conversions
works with the -z. And now everything works accordingly. My /usr/bin/cabal
was version 3.0...
On Tue, Jun 29, 2021 at 10:40 PM Viktor Dukhovni
On Tue, Jun 29, 2021 at 10:18:47PM -0500, Galaxy Being wrote:
Sorry, but this didn't work for me. First,
$ cabal -z install --lib string-conversions cabal: unrecognized 'install' option `-z'
You must have a materially older version of cabal-install than I do. The "-z" option makes "cabal" ignore any local ".cabal" or "cabal.project" files, and operate in the "global" project.
From "cabal install --help":
... -z --ignore-project Ignore local project configuration ...
If I previously wrote "cabal -z install ...", the more strictly correct syntax would probably be "cabal install -z ...", perhaps your version of cabal supports the latter (but quite possibly neither).
$ cabal repl -z
:set -package string-conversions <no location info>: error: Could not load module ‘Data.String.Conversions’ It is a member of the hidden package ‘string-conversions-0.4.0.1’. Perhaps you need to add ‘string-conversions’ to the build-depends in your .cabal file.
Something is missing from the above. I see no attempt to load the module, and yet an error about failure to load it. If "cabal repl" did accept the "-z" option,
$ stack install string-conversions
then
$ stack ghci --package string-conversions
[...]
*But*, now I am able to follow your cabal way and it does work.
So this is very confusing for a beginner. But happy ending this time. Any lessons I can learn from this? For example, why was this so difficult?
It is tricky because cabal operates in a sanboxed mode by default, and because GHC and GHCi don't by default have any knowledge of cabal's package store. The Haskell tool chain is somewhat fragmented, but IIRC there are plans afoot to reduce some of the friction.
I use Cabal 3.4, and it does what I need. Others use stack which meets their needs. GHC is agnostic, and ghci mostly knows just about the packages bundled with GHC, except when cabal or stack create GHC "environment" files that specify the package-db locations which GHC is then able to use.
Someone else who understands the space better may be able to give a more detailed answer, and perhaps share any plans to improve toolchain integration.
-- Viktor. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com

On Jun 29, 2021, at 8:18 PM, Galaxy Being
wrote: So this is very confusing for a beginner. But happy ending this time. Any lessons I can learn from this? For example, why was this so difficult?
All you needed to do is the following, and nothing else (no directly invoking cabal, etc.):
$ stack ghci --package string-conversions
I tried it just now and it works. Jeff
participants (3)
-
Galaxy Being
-
Jeff Clites
-
Viktor Dukhovni