Skip to content

Commit

Permalink
Include Id in prelude.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Grant Jeffries committed Nov 4, 2019
1 parent e6a99a6 commit d4e0cbb
Show file tree
Hide file tree
Showing 33 changed files with 27 additions and 59 deletions.
1 change: 0 additions & 1 deletion bowtie-blueprint/src/Bowtie/Blueprint.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Bowtie.Blueprint where

import Bowtie.Lib.Id
import Bowtie.Lib.Prelude

import qualified Bowtie.Type.AST as Type.AST
Expand Down
1 change: 0 additions & 1 deletion bowtie-js/src/Bowtie/JS/AST.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Bowtie.JS.AST where

import Bowtie.Lib.Id
import Bowtie.Lib.Prelude

-- h/t PureScript
Expand Down
1 change: 0 additions & 1 deletion bowtie-js/src/Bowtie/JS/Imperativize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Bowtie.JS.Imperativize where

import Bowtie.JS.AST
import Bowtie.Lib.Environment
import Bowtie.Lib.Id
import Bowtie.Lib.OrderedMap (OrderedMap)
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
Expand Down
1 change: 0 additions & 1 deletion bowtie-js/src/Bowtie/JS/Serialize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Bowtie.JS.Serialize
) where

import Bowtie.JS.AST
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude

import qualified Data.Text as Text
Expand Down
1 change: 0 additions & 1 deletion bowtie-visualize/src/Bowtie/Visualize/GraphConstraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module Bowtie.Visualize.GraphConstraints where

import Bowtie.Infer.Constraints
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
import Bowtie.Type.AST
Expand Down
3 changes: 1 addition & 2 deletions bowtie/bowtie.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.18
--
-- see: https://github.com/sol/hpack
--
-- hash: e7bc26b76c7c6decea4f8480aaf9046bf3bc39db02244bad3baad02ce95c1190
-- hash: 06e4c7b376d5a49b162fc81cf1e96b8f72f6dea96f0d13be1c83b7a4ec6aaa40

name: bowtie
version: 0.0.0
Expand All @@ -28,7 +28,6 @@ library
Bowtie.Lib.Builtin
Bowtie.Lib.Environment
Bowtie.Lib.FreeVars
Bowtie.Lib.Id
Bowtie.Lib.OrderedMap
Bowtie.Lib.Prelude
Bowtie.Lib.TypeScheme
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Core/Expr.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Core.Expr where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Type.AST

Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/Assumptions.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Bowtie.Infer.Assumptions where

import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Type.AST

Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/BottomUp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Bowtie.Infer.BottomUp where
import Bowtie.Infer.Assumptions
import Bowtie.Infer.Constraints
import Bowtie.Lib.Environment
import Bowtie.Lib.Id
import Bowtie.Lib.OrderedMap (OrderedMap)
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/Constraints.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Infer.Constraints where

import Bowtie.Infer.Substitution
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
import Bowtie.Type.AST
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/Elaborate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Bowtie.Infer.Elaborate where
import Bowtie.Infer.Infer
import Bowtie.Infer.Substitution
import Bowtie.Lib.Environment
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Surface.AST
import Control.Monad.State.Class
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/Generalize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Bowtie.Infer.Generalize where

import Bowtie.Infer.Substitution
import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
import Bowtie.Type.AST
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/Infer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Bowtie.Infer.Constraints
import Bowtie.Infer.Solve
import Bowtie.Infer.Substitution
import Bowtie.Lib.Environment
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Surface.AST
import Control.Monad.Except
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/Substitution.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Infer.Substitution where

import Bowtie.Lib.Environment
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
import Bowtie.Surface.AST
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Infer/Unify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Bowtie.Infer.Unify where

import Bowtie.Infer.Substitution
import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Surface.AST

Expand Down
2 changes: 1 addition & 1 deletion bowtie/src/Bowtie/Lib/Builtin.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Bowtie.Lib.Builtin where

import Bowtie.Lib.Id
import Bowtie.Lib.Prelude

int :: Id
int =
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Lib/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module Bowtie.Lib.Environment where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme

Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Lib/FreeVars.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Bowtie.Lib.FreeVars where

import Bowtie.Lib.Id
import Bowtie.Lib.Prelude

class FreeVars a where
Expand Down
20 changes: 0 additions & 20 deletions bowtie/src/Bowtie/Lib/Id.hs

This file was deleted.

17 changes: 17 additions & 0 deletions bowtie/src/Bowtie/Lib/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Numeric.Natural as X (Natural)
-- Local stuff:

import Control.Monad.Except
import Control.Monad.State.Class
import GHC.Stack.Types (HasCallStack)
import System.Directory (listDirectory)
import System.Exit (exitFailure)
Expand All @@ -48,6 +49,22 @@ import qualified Data.Text as Text
import qualified Data.Text.IO as TIO
import qualified Prelude

newtype Id
= Id Text
deriving stock (Eq, Ord, Show, Generic)
deriving newtype (Hashable)
deriving anyclass (NFData)

-- | Note making this a field of @id@ since then it would
-- be printed every time an @Id@ is shown.
unId :: Id -> Text
unId (Id t) =
t

genVar :: MonadState Int m => m Id
genVar =
state (\n -> (Id (show n), n + 1))

{-# WARNING error "'error' remains in code" #-}
error :: HasCallStack => [Char] -> a
error =
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Lib/TypeScheme.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Lib.TypeScheme where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Surface.AST

Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Surface/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Bowtie.Surface.AST
) where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.OrderedMap
import Bowtie.Lib.Prelude
import Bowtie.Type.AST
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Surface/Desugar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Bowtie.Surface.Desugar
) where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.OrderedMap (OrderedMap)
import Bowtie.Lib.Prelude hiding (all, rem)
import Bowtie.Surface.AST
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Surface/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Bowtie.Surface.Parse
, dirtyParseAST
) where

import Bowtie.Lib.Id
import Bowtie.Lib.OrderedMap (OrderedMap)
import Bowtie.Lib.Prelude hiding (many, some)
import Bowtie.Surface.AST
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Type/AST.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Type.AST where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude

import qualified Data.Set as Set
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Type/Kindcheck.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Type.Kindcheck where

import Bowtie.Lib.Environment
import Bowtie.Lib.Id
import Bowtie.Lib.OrderedMap (OrderedMap)
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Type/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module Bowtie.Type.Parse
, parseTest
) where

import Bowtie.Lib.Id
import Bowtie.Lib.Prelude hiding (many, some)
import Bowtie.Type.AST
import Control.Applicative.Combinators.NonEmpty
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Untyped/Erase.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Untyped.Erase where

import Bowtie.Core.Expr
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude

import qualified Bowtie.Untyped.Expr as U
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Untyped/Eval.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Untyped.Eval where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Untyped.Expr
import Safe.Exact (zipExactMay)
Expand Down
1 change: 0 additions & 1 deletion bowtie/src/Bowtie/Untyped/Expr.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Bowtie.Untyped.Expr where

import Bowtie.Lib.FreeVars
import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Data.HashMap.Strict (HashMap)

Expand Down
1 change: 0 additions & 1 deletion bowtie/test/Bowtie/Surface/InferSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Bowtie.Surface.InferSpec where
import Bowtie.Infer.Elaborate
import Bowtie.Infer.Substitution
import Bowtie.Lib.Environment
import Bowtie.Lib.Id
import Bowtie.Infer.Infer
import Bowtie.Lib.Prelude
import Bowtie.Lib.TypeScheme
Expand Down
8 changes: 4 additions & 4 deletions bowtie/test/Test/Quoted/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

module Test.Quoted.AST (quotedAST) where

import Bowtie.Lib.Prelude
import Bowtie.Surface.AST
import Bowtie.Surface.Parse
import Data.Data
import Language.Haskell.TH.Quote
import Prelude
import Test.Quoted.Expr (liftDataWithText, trimLeadingNewline)

import qualified Data.Text as Text
Expand All @@ -21,7 +21,7 @@ quotedAST =
{ quoteExp =
liftDataWithText . dirtyParseAST . Text.pack . trimLeadingNewline

, quotePat = \_ -> error "quotedAST: quotePat not defined"
, quoteType = \_ -> error "quotedAST: quoteType not defined"
, quoteDec = \_ -> error "quotedAST: quoteDec not defined"
, quotePat = \_ -> panic "quotedAST: quotePat not defined"
, quoteType = \_ -> panic "quotedAST: quoteType not defined"
, quoteDec = \_ -> panic "quotedAST: quoteDec not defined"
}
9 changes: 4 additions & 5 deletions bowtie/test/Test/Quoted/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ module Test.Quoted.Expr
, trimLeadingNewline
) where

import Bowtie.Lib.Id
import Bowtie.Lib.Prelude
import Bowtie.Surface.AST
import Bowtie.Surface.Parse
import Data.Data
import Data.Text (Text)
import Language.Haskell.TH
import Language.Haskell.TH.Quote
import Language.Haskell.TH.Syntax (lift)
import Prelude

import qualified Bowtie.Type.AST as TYP
import qualified Data.Text as Text
Expand All @@ -35,9 +34,9 @@ quotedExpr =
{ quoteExp =
liftDataWithText . dirtyParseExpr . Text.pack . trimLeadingNewline

, quotePat = \_ -> error "quotedExpr: quotePat not defined"
, quoteType = \_ -> error "quotedExpr: quoteType not defined"
, quoteDec = \_ -> error "quotedExpr: quoteDec not defined"
, quotePat = \_ -> panic "quotedExpr: quotePat not defined"
, quoteType = \_ -> panic "quotedExpr: quoteType not defined"
, quoteDec = \_ -> panic "quotedExpr: quoteDec not defined"
}

-- This and liftText from: https://stackoverflow.com/a/38182444
Expand Down

0 comments on commit d4e0cbb

Please sign in to comment.