Commit 635e0f13 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Change kind of functor types to (* -> *)

This allows a more flexible implementation for the functor-expression
parser and other conveniences.

This commit doesn't remove the old types but temporarily adds new ones
with a different name. This is to simplify the transition to the new
types.
parent 4582b75b
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
module Data.Functors where
import Data.RefinementInterface
import Data.Functors.Powerset (powerset)
import Data.Functors.FixedProduct (fixedproduct)
import Data.Functors.MonoidValued (intValued, realValued)
import Data.Functors.Powerset (powerset, Powerset')
import Data.Functors.FixedProduct (FixedProduct', fixedproduct)
import Data.Functors.MonoidValued (MonoidValued', intValued, realValued)
import Text.Parser.Functor
import Data.OpenUnion
registeredFunctors :: [[SomeFunctorParser]]
registeredFunctors =
......@@ -20,3 +22,8 @@ registeredFunctors =
where
f :: RefinementInterface a => FunctorParser a -> SomeFunctorParser
f = SomeFunctorParser
-- new interface
type AllFunctors
= Union '[ Powerset', FixedProduct', MonoidValued' Int, MonoidValued' Double]
......@@ -2,7 +2,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
module Data.Functors.FixedProduct (FixedProduct(..), fixedproduct) where
module Data.Functors.FixedProduct (FixedProduct(..), fixedproduct, FixedProduct') where
import Control.Monad (void)
......@@ -19,6 +19,12 @@ import Text.Parser.Functor
import qualified Text.Parser.Lexer as L
import Text.Megaparsec
-- new interface
data FixedProduct' a = FixedProduct' (Vector Text) a
-- old interface
newtype FixedProduct = FixedProduct (Vector Text)
deriving (Show)
......
......@@ -5,7 +5,7 @@
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE OverloadedStrings #-}
module Data.Functors.MonoidValued (intValued, realValued) where
module Data.Functors.MonoidValued (intValued, realValued, MonoidValued') where
import Text.Megaparsec
import Data.Vector (Vector)
......@@ -19,6 +19,14 @@ import Data.MorphismEncoding (Edge(Edge), Encoding)
import Text.Parser.Functor
import qualified Text.Parser.Lexer as L
-- new interface
data MonoidValued' m a where
RealValued' :: a -> MonoidValued' Double a
IntValued' :: a -> MonoidValued' Int a
-- old interface
data MonoidValued m where
RealValued :: MonoidValued Double
IntValued :: MonoidValued Int
......
......@@ -3,7 +3,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
module Data.Functors.Powerset (Powerset(..), powerset) where
module Data.Functors.Powerset (Powerset(..), powerset, Powerset') where
import Data.Vector (Vector)
import qualified Data.Vector as V
......@@ -14,6 +14,12 @@ import qualified Data.MorphismEncoding as Encoding
import Text.Parser.Functor
import qualified Text.Parser.Lexer as L
-- New interface
data Powerset' a = Powerset' a
-- Old interface
data Powerset = Powerset
deriving (Show)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment