File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ module Data.Functor.Mu
6
6
) where
7
7
8
8
import Prelude
9
- import Data.TacitString as TS
10
9
10
+ import Control.Alt (class Alt , (<|>))
11
+ import Control.Alternative (class Plus , empty )
11
12
import Data.Eq (class Eq1 , eq1 )
12
13
import Data.Newtype (class Newtype )
13
14
import Data.Ord (class Ord1 , compare1 )
15
+ import Data.TacitString as TS
14
16
15
17
-- | `Mu f` is the least fixed point of a functor `f`, when it exists.
16
18
newtype Mu f = In (f (Mu f ))
@@ -49,3 +51,9 @@ instance ordMu :: (Eq1 f, Ord1 f) => Ord (Mu f) where
49
51
-- extra quotes from appearing.
50
52
instance showMu :: (Show (f TS.TacitString ), Functor f ) => Show (Mu f ) where
51
53
show (In x) = show $ x <#> (show >>> TS .hush)
54
+
55
+ instance semigroupMu :: Alt f => Semigroup (Mu f ) where
56
+ append (In x) (In y) = In (x <|> y)
57
+
58
+ instance monoidMu :: Plus f => Monoid (Mu f ) where
59
+ mempty = In empty
You can’t perform that action at this time.
0 commit comments