Last active
December 18, 2015 03:18
Revisions
-
Blaisorblade revised this gist
Jun 5, 2013 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,5 +15,19 @@ instance Changing Integer where apply = (+) diff = (-) -- Fails: v :: Delta Integer v = diff 2 1 {- Error: DeltaInt.hs:21:5: Couldn't match type `Delta a0' with `Integer' Expected type: Delta Integer Actual type: Delta a0 In the return type of a call of `diff' In the expression: diff 2 1 In an equation for `v': v = diff 2 1 Failed, modules loaded: none. -} -
Blaisorblade created this gist
Jun 5, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ {-# LANGUAGE TypeFamilies #-} module DeltaInt where class Changing a where -- Using type families here is a bit convenient, but means risking trouble later. type Delta a nil :: a -> Delta a apply :: a -> Delta a -> a diff :: a -> a -> Delta a instance Changing Integer where type Delta Integer = Integer nil = const 0 apply = (+) diff = (-) v :: Delta Integer v = diff 2 1