Skip to content

Instantly share code, notes, and snippets.

@rblaze
Created November 23, 2015 18:58
Show Gist options
  • Save rblaze/cf4beda255bbabd3506c to your computer and use it in GitHub Desktop.
Save rblaze/cf4beda255bbabd3506c to your computer and use it in GitHub Desktop.
Make it compile without creating extra modules. hs-boot is fine
module A where
data InnerType = InnerType { foo :: Int }
inVar :: OuterType
inVar = OuterType (InnerType 2)
module B where
import A
data OuterType = OuterType { bar :: InnerType }
outVar :: OuterType
outVar = OuterType (InnerType 1)
@qnikst
Copy link

qnikst commented Nov 23, 2015

qnikst@qwork ~/tmp/haskell/juick/cf4beda255bbabd3506c $ ghc A.hs B.hs
[1 of 3] Compiling A[boot]          ( A.hs-boot, A.o-boot )
[2 of 3] Compiling B                ( B.hs, B.o )
[3 of 3] Compiling A                ( A.hs, A.o )
qnikst@qwork ~/tmp/haskell/juick/cf4beda255bbabd3506c $ cat A.hs
module A where

import B

data InnerType = InnerType { foo :: Int }

inVar :: OuterType
inVar = OuterType (InnerType 2)
qnikst@qwork ~/tmp/haskell/juick/cf4beda255bbabd3506c $ cat A.hs-boot 
module A where

data InnerType = InnerType { foo :: Int }
qnikst@qwork ~/tmp/haskell/juick/cf4beda255bbabd3506c $ cat B.hs 
module B where

import {-# source #-} A

data OuterType = OuterType { bar :: InnerType }

outVar :: OuterType
outVar = OuterType (InnerType 1)

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