Markov Chain generator I'm not sure if a Markov Chain generator is the proper term for this, really all it does is create the chain, it doesn't generate any text from it. The code is below, and I'd appreciate any feedback: bad practices, code smells, poor naming, anything at all really.

module Main where
import Data.List(find, delete)

type Chain = [Node]
data Node = Node {nPrefix :: String, nSuffixes :: [String]} deriving (Show, Eq, Read)

generateChain :: Int -&gt; [String] -&gt; Chain
generateChain n = foldl (learnSample n) []

learnSample :: Int -&gt; Chain -&gt; String -&gt; Chain
learnSample n chain sample = foldl learnGroup chain groups
    where groups = (groupings (n+1) . words) sample

learnGroup :: Chain -&gt; [String] -&gt; Chain
learnGroup chain group = 
    case find (\node -&gt; nPrefix node == prefix) chain of
        Just node -&gt; delete node chain ++ [Node prefix (nSuffixes node ++ [suffix])]
        Nothing   -&gt; chain ++ [Node prefix [suffix]]
    where 
        prefix = unwords $ init group
        suffix = last group

groupings :: Int -&gt; [a] -&gt; [[a]]
groupings n list 
    | length list &gt;= n = take n list : groupings n (drop 1 list)
    | otherwise        = []

main :: IO ()
main = print $ generateChain 1 ["a b a b a c a d"]
Looks good, the only thing I'd suggest is that since you don't really
rely on having strings as nodes, you can also generalise your
implementation to arbitrary chains, i.e. Chain Char for this particular
main function.  You'll need to change to a GADT (I think) but
otherwise the code would just need a few minor additional changes.