Skip to content

Instantly share code, notes, and snippets.

@bicycle1885
Created July 18, 2014 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bicycle1885/c4553dda851e4999d4c4 to your computer and use it in GitHub Desktop.
Save bicycle1885/c4553dda851e4999d4c4 to your computer and use it in GitHub Desktop.
deduction error
{-# LANGUAGE FlexibleContexts #-}
import qualified Data.Vector.Generic as G
fooG :: (G.Vector v Int) => Int -> v Int -> v Bool
fooG x = G.map (> x)
-- hello.hs:5:10:Could not deduce (G.Vector v Bool) arising from a use of ‘G.map’
-- from the context (G.Vector v Int)
-- bound by the type signature for
-- fooG :: G.Vector v Int => Int -> v Int -> v Bool
-- at hello.hs:4:9-50
-- In the expression: G.map (> x)
-- In an equation for ‘fooG’: fooG x = G.map (> x)
@bicycle1885
Copy link
Author

{-# LANGUAGE FlexibleContexts, Rank2Types, KindSignatures #-}
import qualified Data.Vector.Generic as G

fooG :: forall (v :: * -> *). (G.Vector v Bool, G.Vector v Int) => Int -> v Int -> v Bool
fooG x = G.map (> x)

@bicycle1885
Copy link
Author

{-# LANGUAGE FlexibleContexts, Rank2Types #-}
import qualified Data.Vector.Generic as G

fooG :: forall v. (G.Vector v Bool, G.Vector v Int) => Int -> v Int -> v Bool
fooG x = G.map (> x)

@ruicc
Copy link

ruicc commented Jul 18, 2014

{-# LANGUAGE FlexibleContexts #-}
import qualified Data.Vector.Generic as G

fooG :: (G.Vector v Bool, G.Vector v Int) => Int -> v Int -> v Bool
fooG x = G.map (> x)

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