This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> "{ /* hello */ def foo(bar: Int) = bar }".parse[Term].get | |
| res0: scala.meta.Term = { /* hello */ def foo(bar: Int) = bar } | |
| scala> res0 transform { case q"bar" => q"baz" } | |
| x.origin: Parsed(Input.String("{ /* hello */ def foo(bar: Int) = bar }"),Scala211,[18..21) in Input.String("{ /* hello */ def foo(bar: Int) = bar }")) | |
| x : foo | |
| x.origin: Transformed(bar) | |
| x : baz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Contravariant f where | |
| fmap :: (b -> a) -> f a -> f b | |
| newtype Predicate a = Predicate { runPredicate :: a -> Bool } | |
| instance Contravariant Predicate where | |
| fmap f (Predicate a) = Predicate (a . f) | |
| data MyOrdering = LT | EQ | GT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Monad | |
| class Profunctor p where | |
| dimap :: (a -> b) -> (c -> d) -> p b c -> p a d | |
| -- lmap :: (a -> b) -> p b c -> p a c | |
| -- rmap :: (c -> d) -> p b c -> p b d | |
| instance Profunctor (->) where | |
| -- dimap :: (a -> b) -> (c -> d) -> (->) b c -> (->) a d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ def id[A](x: A): A = x | |
| defined function id | |
| @ def k[A, B](x: A, y: B): A = x | |
| defined function k | |
| @ def a[A, B](f: A => B, x: A): B = f(x) | |
| defined function a | |
| @ a((x: Int) => x + 1, 1) |
OlderNewer