Skip to content

Instantly share code, notes, and snippets.

@madgen
Created June 16, 2018 13:09
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 madgen/a402a2c0e86b0387c71d96f1098d4ec9 to your computer and use it in GitHub Desktop.
Save madgen/a402a2c0e86b0387c71d96f1098d4ec9 to your computer and use it in GitHub Desktop.
How does type inference works on this?
module MinskyGADT where
import Data.Array
import qualified Data.ByteString as BS
import Data.Word (Word8)
data GArrayLike a where
GArray :: Array Int a -> GArrayLike a
GBytes :: BS.ByteString -> GArrayLike Word8
gLength (GArray a) = snd (bounds a)
gLength (GBytes b) = BS.length b
-- :t gLength
-- gLength :: GArrayLike e -> Int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment