Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find module ‘Text.Regex.Posix’

Tags:

haskell

I want to try doing regexes in GHCi. I tried loading the module

 :mod +Text.Regex.Posix

But got this error instead

<no location info>:
    Could not find module ‘Text.Regex.Posix’
    It is not a module in the current program, or in any known package.

But I should have Text installed

ghc-pkg find-module Text.Regex.Posix would give me

/usr/local/Cellar/ghc/7.8.4/lib/ghc-7.8.4/package.conf.d
/Users/a/.ghc/x86_64-darwin-7.8.4/package.conf.d

What do I do?

I have no problem with this though:

import Text.Read

Why?

like image 972
Help - I need somebody's help Avatar asked Apr 10 '15 13:04

Help - I need somebody's help


1 Answers

The problem is that you simply don't have the regex-posix package installed. This is the package that exports the Text.Regex.Posix module. Text.Read is exported by the base package which comes with every Haskell distribution.

You can see this by running ghc-pkg find-module Text.Read. To install the regex-posix package globally run the command cabal install regex-posix. If you don't want to install it globally or run into problems getting it to install, it would be better to try installing it with the same command in a sandbox after running cabal sandbox init in the directory of your choice.

like image 98
bheklilr Avatar answered Oct 06 '22 04:10

bheklilr