This file contains 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
{-# LANGUAGE DataKinds, TypeOperators, GADTs, KindSignatures, RankNTypes, ScopedTypeVariables #-} | |
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-} | |
import GHC.TypeLits | |
import Data.Type.Equality(type (==), (:~:)(Refl)) | |
-- Vector of type t and length n. | |
data Vec t (n :: Nat) where | |
VNil :: Vec t 0 | |
VCons :: t -> Vec t n -> Vec t (n+1) |
This file contains 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
{-# LANGUAGE DataKinds, TypeOperators, GADTs, KindSignatures, RankNTypes, ScopedTypeVariables #-} | |
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-} | |
import GHC.TypeLits | |
import Data.Proxy | |
import Data.Type.Equality(type (==), (:~:)(Refl)) | |
import Unsafe.Coerce | |
-- Vector of type t and length n. | |
data Vec t (n :: Nat) where |
This file contains 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
{-# LANGUAGE DataKinds, TypeOperators, GADTs, KindSignatures, RankNTypes #-} | |
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-} | |
import GHC.TypeLits | |
import Data.Proxy | |
import Data.Type.Equality(type (==), (:~:)(Refl)) | |
import Unsafe.Coerce | |
data Vec t (n :: Nat) where | |
VNil :: Vec t 0 |
This file contains 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
{-# LANGUAGE DataKinds, TypeOperators, GADTs, KindSignatures, RankNTypes #-} | |
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-} | |
import GHC.TypeLits | |
import Data.Proxy | |
import Data.Type.Equality(type (==), (:~:)(Refl)) | |
import Unsafe.Coerce | |
data Vec t (n :: Nat) where | |
VNil :: Vec t 0 |
This file contains 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
{-# LANGUAGE DataKinds, TypeOperators, GADTs, KindSignatures, RankNTypes #-} | |
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-} | |
import GHC.TypeLits | |
import Data.Proxy | |
import Data.Type.Equality(type (==), (:~:)(Refl)) | |
import Unsafe.Coerce | |
data Vec t (n :: Nat) where | |
VNil :: Vec t 0 |
This file contains 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
/* Version 1 */ | |
f0 = A4*X0*X0*X0*X0 + A3*X0*X0*X0 + A2*X0*X0 + A1*X0 + A0; | |
/* Version 2 */ | |
a[4]=A4; a[3]=A3; a[2]=A2; | |
a[1]=A1; a[0]=A0; | |
for(i=0;i<5;i++){ | |
b[i]=0; |
This file contains 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
data Tree a = Node a [Tree a] | |
| Leaf a | |
build :: Monad m => (a -> m [a]) -> a -> m (Tree a) | |
build get_sons a = do sons <- get_sons a | |
case sons of | |
[] -> return $ Leaf a | |
lst -> do trees <- sequence $ map (build get_sons) lst | |
return $ Node a trees |
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Language.C.Data.InputStream | |
import Language.C.Syntax.AST | |
import Language.C.Data.Position | |
import Language.C.Parser | |
import Language.C.Pretty | |
parse exp = execParser_ expressionP exp nopos |
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Language.C.Data.InputStream | |
import Language.C.Syntax.AST | |
import Language.C.Data.Position | |
import Language.C.Parser | |
import Language.C.Pretty | |
parse exp = execParser_ expressionP exp nopos |
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Language.C.Data.InputStream | |
import Language.C.Syntax.AST | |
import Language.C.Data.Position | |
import Language.C.Parser | |
import Language.C.Pretty | |
parse exp = execParser_ expressionP exp nopos |