Problems Using Haskell Group

I am studying Haskell in advance in the next semester, and I am delaying group testing . I tried directly in WinGHCi and wrote the function to a text file. Reading the documentation (haskell.org, zvon.org) I can see that the Data.List module is required , so I did the following in WinGHCi :

:l Data.List

But I get the error :: module 'Data.List is a batch module

Then I wrote a function using a text editor as follows:

import Data.List
group "aaaabbbbbbbccddd"

I get an error again when loading (compiling):

_Haskell.hs:2:1:
Parse error: naked expression at top level
Perhaps you intended to use TemplateHaskell_

I am a complete beginner in functional programming. I will be very grateful for your help in solving my problem.

Sincerely.

+4
1

GHCI , , .

Prelude> import Data.List
Prelude Data.List> group "aaaaabbbbbbcccccddd"
["aaaaa","bbbbbb","ccccc","ddd"]

: . .

import Data.List

testGroup :: (Eq a) => [a] -> [[a]]
testGroup lst = group lst

.

~/temp ❯❯❯ ghci h.hs
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( h.hs, interpreted )
Ok, modules loaded: Main.
*Main> testGroup [2]
[[2]]
+5

Source: https://habr.com/ru/post/1648803/


All Articles