Answers http://stackoverflow.com/questions/10373318/mixing-in-a-trait-dynamically.
Compile as follows: scalac Common_1.scala Macros_2.scala scalac Common_1.scala Test_3.scala -cp
Tested in 2.10.0
===Common_1.scala===
Answers http://stackoverflow.com/questions/10373318/mixing-in-a-trait-dynamically.
Compile as follows: scalac Common_1.scala Macros_2.scala scalac Common_1.scala Test_3.scala -cp
Tested in 2.10.0
===Common_1.scala===
{-# LANGUAGE DeriveDataTypeable, RecordWildCards, UndecidableInstances, GeneralizedNewtypeDeriving #-}
module Data.IxSet.Identified where
-- Block the standard prelude
import Prelude ()
-- Import a much more useful prelude from `classy-prelude` package
import ClassyPrelude
import Data.SafeCopy
import Data.List | |
import qualified Data.Set as Set | |
import Criterion.Main | |
import System.Random | |
import Control.Applicative | |
import qualified Data.MultiSet as MultiSet | |
absDiffImpl :: (Eq a) => [a] -> [a] -> Bool | |
absDiffImpl a b = null $ absDiff a b |
import Data.List
import qualified Data.Set as Set
import Criterion.Main
import System.Random
import Control.Applicative
main :: IO ()
#Anonymous records. A solution to the problems of record-system.
Please, beware that the proposal that follows has been implemented as a library.
The current record system is notorious for three major flaws:
It does not solve the namespacing problem. I.e., you cannot have two records sharing field names in a single module. E.g., the following won't compile:
data A = A { field :: String }
#!/usr/bin/env runghc -w | |
-- | |
-- A replacement of "runghc", which uses a compiler instead of interpreter, | |
-- thus allowing you to specify some important compiler flags, e.g. "-O2". | |
-- | |
-- USAGE: | |
-- | |
-- runmakeghc SCRIPT_PATH [COMPILER_OPTIONS] [-- SCRIPT_OPTIONS] | |
-- |
-- | | |
-- Migrate from any version to any other higher version. | |
migrate :: (Word, Word) -> EitherT Text (Tx s) () | |
migrate = | |
\case | |
(0, 1) -> -- Execute statements, which create the DB in initial state. | |
(1, 2) -> -- Execute statements, which alter the DB to migrate from version 1 to 2. | |
(2, 3) -> -- Execute statements, which alter the DB to migrate from version 2 to 3. | |
(3, 4) -> throwError $ "Trying to migrate to an inexistent version" | |
(from, to) |
<dependency> | |
<groupId>org.deeplearning4j</groupId> | |
<artifactId>deeplearning4j-core</artifactId> | |
<version>0.9.1</version> | |
</dependency> | |
<dependency> | |
<groupId>org.nd4j</groupId> | |
<artifactId>nd4j-api</artifactId> | |
<version>0.9.1</version> |
-- | | |
-- Application-wide service, which is merely a product of other services. | |
-- Shows how services can be de/composed and encapsulated. | |
module Services.Main where | |
import qualified Services.Db as Db | |
import qualified Services.Metrics as Metrics | |
data Env = Env { | |
db :: Db.Env, |