Created
June 22, 2014 16:49
-
-
Save mlen/23f61025c385f8538539 to your computer and use it in GitHub Desktop.
Revisions
-
mlen revised this gist
Jun 22, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 @@ -1,3 +1,6 @@ [1 of 1] Compiling Main ( GADTs.hs, interpreted ) GADTs.hs:15:22: Could not deduce (b1 ~ b) from the context ((1 + b) ~ (1 + b1)) bound by a pattern with constructor -
mlen created this gist
Jun 22, 2014 .There are no files selected for viewing
This file contains hidden or 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,21 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeOperators #-} import GHC.TypeLits data Stack :: * -> Nat -> * where Nil :: Stack t 0 Cons :: a -> Stack a b -> Stack a (1 + b) deriving instance Show a => Show (Stack a b) pop :: Stack a (1 + b) -> (a, Stack a b) pop (Cons a b) = (a, b) push :: a -> Stack a b -> Stack a (1 + b) push = Cons empty :: Stack t 0 empty = Nil This file contains hidden or 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,21 @@ Could not deduce (b1 ~ b) from the context ((1 + b) ~ (1 + b1)) bound by a pattern with constructor Cons :: forall a (b :: Nat). a -> Stack a b -> Stack a (1 + b), in an equation for ‘pop’ at GADTs.hs:15:6-13 ‘b1’ is a rigid type variable bound by a pattern with constructor Cons :: forall a (b :: Nat). a -> Stack a b -> Stack a (1 + b), in an equation for ‘pop’ at GADTs.hs:15:6 ‘b’ is a rigid type variable bound by the type signature for pop :: Stack a (1 + b) -> (a, Stack a b) at GADTs.hs:14:8 Expected type: Stack a b Actual type: Stack a b1 Relevant bindings include b :: Stack a b1 (bound at GADTs.hs:15:13) pop :: Stack a (1 + b) -> (a, Stack a b) (bound at GADTs.hs:15:1) In the expression: b In the expression: (a, b)