[Haskell-beginners] Type assignment for List

Imants Cekusins imantc at gmail.com
Sun Aug 9 06:53:53 UTC 2015


Yi Lu is spot on right:

1. xs :: [Int]
Prelude> []:[1]
<interactive>:2:1:
    Non type-variable argument in the constraint: Num [t]
    (Use FlexibleContexts to permit this)
    When checking that ‘it’ has the inferred type
      it :: forall t. Num [t] => [[t]]

2. xs :: [[Float]]
Prelude> []:[[0.1]]
[[],[0.1]]

3. xs :: [[[Char]]]
Prelude> []:[[['a']]]
[[],["a"]]

4. xs :: [[[[Bool]]]]
Prelude> []:[[[[True]]]]
[[],[[[True]]]]


More information about the Beginners mailing list