~jojo/Carth

62fba59d33f9b5543b677439b267602254e5ae25 — JoJo 2 years ago 244edd0
Minor changes
2 files changed, 7 insertions(+), 7 deletions(-)

M src/Ast.hs
M src/SrcPos.hs
M src/Ast.hs => src/Ast.hs +2 -1
@@ 28,6 28,7 @@ import Data.Map (Map)
import Data.List
import Data.Bifunctor
import Control.Lens (makeLenses)
import Control.Arrow ((>>>))

import Misc
import SrcPos


@@ 148,7 149,7 @@ instance Pretty TVar where


fvExpr :: Expr -> Set Id
fvExpr = onPosd $ \case
fvExpr = unpos >>> \case
    Lit _ -> Set.empty
    Var x -> Set.singleton x
    App f a -> fvApp f a

M src/SrcPos.hs => src/SrcPos.hs +5 -6
@@ 2,7 2,6 @@ module SrcPos
    ( SrcPos(..)
    , WithPos(..)
    , HasPos(..)
    , onPosd
    , unpos
    , dummyPos
    , sourcePosPretty


@@ 18,6 17,11 @@ newtype SrcPos = SrcPos SourcePos

data WithPos a = WithPos SrcPos a


class HasPos a where
    getPos :: a -> SrcPos


instance Show a => Show (WithPos a) where
    showsPrec p (WithPos _ a) = showsPrec p a
instance Eq a => Eq (WithPos a) where


@@ 27,14 31,9 @@ instance Ord a => Ord (WithPos a) where
instance Pretty a => Pretty (WithPos a) where
    pretty' d = pretty' d . unpos

class HasPos a where
    getPos :: a -> SrcPos

instance HasPos (WithPos a) where
    getPos (WithPos p _) = p

onPosd :: (a -> b) -> WithPos a -> b
onPosd f = f . unpos

unpos :: WithPos a -> a
unpos (WithPos _ a) = a