Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Created June 22, 2014 01:39
Show Gist options
  • Select an option

  • Save hughfdjackson/f13b2ca2eaae390b9b2f to your computer and use it in GitHub Desktop.

Select an option

Save hughfdjackson/f13b2ca2eaae390b9b2f to your computer and use it in GitHub Desktop.
import List (foldl, map)
data Acceptable = X { x: Int } | XY { y: Int, x: Int }
list : [Acceptable]
list = [X { x = 10 }, XY { x = 20, y = 10 }]
type Xable a = { a | x: Int }
sumX : [Xable a] -> Int
sumX = foldl (+) 0 . map .x
main = asText <| sumX list
@hughfdjackson
Copy link
Copy Markdown
Author

Fails compilation with:

Type error on line 14, column 23 to 27:
       list

  Expected Type: Acceptable
    Actual Type: Xable a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment