Failed to try function "permutations" in ghci (Haskell)

736 views Asked by At

I am trying to walk through the functions in Data.List of the Haskell stardard library and get an error when trying "permutations". What am I missing here? Thanks.

Prelude> map (\b-> b*b) [1,2,3]
[1,4,9]
Prelude> permutations "abc"

<interactive>:1:0: Not in scope: `permutations'
2

There are 2 answers

1
Matthew Manela On BEST ANSWER

That library page you linked to is for the base libraries version 4 which come with GHC version 6.10. Are you sure you are running GHC 6.10? If you are running the previous version 6.8 then there will not be a permutations function in Data.List.

0
Mark Rushakoff On

Data.List.permutations was released in GHC 6.10.1. Chances are you have an earlier version. But if you did have the correct version, you would have to load the Data.List module like this:

Prelude> :m +Data.List
Prelude Data.List> permutations "abc"
["abc","bac","cba","bca","cab","acb"]